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
The stack is last-in first-out. After the three pushes the stack holds $25$H, $30$H, $40$H (top). The first POP loads $R_1=40$H, the second loads $R_2=30$H and the last loads $R_3=25$H.