The GATE Grind

GATE 2021 EC – Question 42

Digital Circuits · Computer Organization · 2 marks · Multiple choice

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

  1. $R_1=40$H, $R_2=30$H, $R_3=25$H
  2. $R_1=25$H, $R_2=30$H, $R_3=40$H
  3. $R_1=30$H, $R_2=40$H, $R_3=25$H
  4. $R_1=40$H, $R_2=25$H, $R_3=30$H

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.