Skip to content
Official PYQ · 2007

GATE CS 2007 Q72 — I/O Interface: Interrupt and DMA Mode

Explain with AI

Consider the following program segment. Here R1, R2\text{R1, R2} and R3\text{R3} are the general purpose registers.
InstructionOperation Instruction Size(no. of words)MOV R1,(3000)R1←M[3000]2LOOP:MOV R2,(R3)R2←M[R3]1ADD R2,R1R2←R1 + R21MOV (R3),R2M[R3]←R21INC R3R3←R3 + 11DEC R1R1←R1 – 11BNZ LOOPBranch on not zero2HALTStop1\small \begin{array}{|c|l|l||c|} \hline & \text{Instruction} & \text{Operation }& \text{Instruction Size} \\ & & & \text{(no. of words)} \\ \hline & \text{MOV R1,(3000)} & \text{R1} \leftarrow \text{M[3000]} & 2 \\ \hline \text{LOOP:}& \text{MOV R2,(R3)} & \text{R2} \leftarrow \text{M[R3]} & 1 \\ \hline & \text{ADD R2,R1} & \text{R2} \leftarrow \text{R1 + R2} & 1 \\ \hline & \text{MOV (R3),R2} & \text{M[R3]} \leftarrow \text{R2} & 1 \\ \hline& \text{INC R3} & \text{R3} \leftarrow \text{R3 + 1} & 1 \\ \hline & \text{DEC R1} & \text{R1} \leftarrow \text{R1 – 1} & 1 \\ \hline& \text{BNZ LOOP} & \text{Branch on not zero} & 2 \\ \hline & \text{HALT} & \text{Stop} & 1 \\ \hline\end{array}

Assume that the content of memory location 30003000 is 1010 and the content of the register R3\text{R3} is 20002000. The content of each of the memory locations from 20002000 to 20102010 is 100100. The program is loaded from the memory location 10001000. All the numbers are in decimal.

Assume that the memory is word addressable. After the execution of this program, the content of memory location 20102010 is:

Choose one option
View worked solution

Answer: A

To find the content of memory location 20102010 after execution, let's trace the loop iterations step-by-step:

  • Initial values: R1=M[3000]=10R1 = M[3000] = 10, and R3=2000R3 = 2000.
  • Iteration 1:
    • R2←M[2000]=100R2 \leftarrow M[2000] = 100
    • R2←100+10=110R2 \leftarrow 100 + 10 = 110
    • M[2000]←110M[2000] \leftarrow 110
    • R3←2001R3 \leftarrow 2001, R1←9R1 \leftarrow 9
  • Iteration 2: Modifies M[2001]M[2001], increments R3R3 to 20022002, and decrements R1R1 to 88.
  • …\dots
  • Iteration 10: Starts with R1=1R1 = 1 and R3=2009R3 = 2009.
    • R2←M[2009]=100R2 \leftarrow M[2009] = 100
    • R2←100+1=101R2 \leftarrow 100 + 1 = 101
    • M[2009]←101M[2009] \leftarrow 101
    • R3←2010R3 \leftarrow 2010, R1←0R1 \leftarrow 0

Since R1=0R1 = 0, the BNZ LOOP condition fails, and the program terminates. Throughout the entire execution, the memory location 20102010 is never written to. Thus, its content remains at its initial value of 100100.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore I/O Interface: Interrupt and DMA Mode questions