GATE 2021 EC – Question 42
The content of the registers are $R_1=25$H, $R_2=30$H and $R_3=40$H. The following machine instructions are executed.
PUSH{R1}
PUSH{R2}
PUSH{R3}
POP{R1}
POP{R2}
POP{R3}
After execution, the content of registers $R_1$, $R_2$, $R_3$ are
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: (A) $R_1=40$H, $R_2=30$H, $R_3=25$H
Explanation
A stack is last-in, first-out (LIFO).
- PUSH R1, R2, R3 stores 25H, 30H, 40H in that order; 40H is on top.
- POP R1 takes the top: $R_1=40$H.
- POP R2 takes the next: $R_2=30$H.
- POP R3 takes the last: $R_3=25$H.