0% found this document useful (0 votes)
5 views2 pages

Lab_test2

The document outlines the guidelines and tasks for the CS204 Computer Architecture Lab Test 2 scheduled for February 23, 2024. It includes instructions for naming code files, submission rules, and penalties for late submissions and plagiarism. The test consists of two main tasks: implementing a recursive solution for the Tower of Hanoi puzzle and creating a Queue data structure in Assembly language, with specific points allocated for each part of the tasks.

Uploaded by

2022mcb1318
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Lab_test2

The document outlines the guidelines and tasks for the CS204 Computer Architecture Lab Test 2 scheduled for February 23, 2024. It includes instructions for naming code files, submission rules, and penalties for late submissions and plagiarism. The test consists of two main tasks: implementing a recursive solution for the Tower of Hanoi puzzle and creating a Queue data structure in Assembly language, with specific points allocated for each part of the tasks.

Uploaded by

2022mcb1318
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CS204 - Computer Architecture

Lab Test 2
Date: 23rd Feb 2024
Time: 4.00PM - 7.00PM IST (150 Mins)
Max. points: 55 points. Weightage: 4%
General Guidelines:
(i) Name your codes as rollno q1.txt and rollno q2.txt
(ii) Follow both the timeline and naming convention. We might consider deduction of points if they are not
followed.
(iii) First two lines in each file should be - Your name, Roll no.
(iv) Include comments in the code for improved readability. This will help you to recollect your logic for
reuse and during evaluation.
(v) DO NOT use any pseudo instructions. Every time you use a pseudo instruction in your code, 1 point
would be deducted from your score.
(vi) Submit before the deadline. Late submissions will be penalized - Beyond 7PM, for every 2 minutes, 1
point will be deducted from your score.
(vii) Plagiarism will be treated seriously.

Task 1: Recursive program for Tower of Hanoi puzzle. (15 + 5 + 5 points)


Tower of Hanoi (TOH) is a mathematical puzzle where we have three (say, A, B and C) rods
and n disks of different sizes. Though its a well known puzzle that you might already be
aware of, I am reiterating it for better clarity.
The objective of the puzzle is to move the entire stack of disks to another rod, obeying the
following simple rules:
1. Only one disk can be moved at a time.
2. Each move consists of taking the upper disk from one of the stacks and placing it on the
top of another stack, i.e., a disk can only be moved if it is the uppermost disk on a stack.
3. No disk can be placed on top a smaller disk.

Your job is to write a recursive procedure to solve TOH. You should store all the valid
moves you make in the process at the location specified by register x10. Follow a convention
to store a word of data that will represent a move. For example, when you have moved disk
1 from rod A to rod B, you can simply store 0x0000 01AB at the given location. The next
move will be written in the next word and so on. In the end, one can look at the memory
and can see the sequence of steps followed in the solution.
For your benefit, pseudo code of Tower of Hanoi is given below: Pseudo code:
TOH( n, from rod, to rod, help rod) {
if (n == 1) {
print: Move disk 1 from rod "from rod" to rod "to rod"
return;
}
TOH(n-1, from rod, help rod, to rod);
print: Move disk "n" from rod "from rod" to rod "to rod"
TOH(n-1, help rod, to rod, from rod);
}

Marks split up: 10 points for the core recursion logic. 5 points for storing the moves
properly. 5 points for the output.
Task 2: Implementing the Queue data structure in Assembly (30 Points)
Implement a Queue like structure at location 0x10000100 using Enqueue(), Dequeue(), Over-
flow(), Underflow(), Size() procedures.
Input:
1. Maximum Queue size, say 20.
2. Sequence of operations given as a string at location 0x10000500: E E D E S D E S ...
E stands for Enqueue, D stands for Dequeue, S stands for Size.
3. Sequence of data corresponding to the enqueue operations above, at location 0x10000600:
10 20 6 7 ...
Implementation hint:
Your driver procedure should pick one character at a time from the input string, identify the
operation, pick the remaining arguments from second string and then call the appropriate
procedure. Once the operation is done, the driver procedure will move to the next character.
Output:
1. Store strings “E Success”, “D Success” upon successful enqueue and dequeue operation,
respectively, at location 0x10000200.
2. For Size(), store the current queue size in register x15.
3. If hit underflow (overflow), store -1 (-2), respectively in register x10, and exit (reach
fall-thru code with proper restoration of stack pointer).

Marks split: 5 points for the driver procedure, 4 points for each procedure and 1 point for
the output of each procedure. Overall: 5 + 4*5 + 1*5

All the best!

You might also like