Lab_test2
Lab_test2
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.
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