Consider the following program segment. Here R1, R2 and R3 are the general…

2007

Consider the following program segment. Here R1, R2 and R3 are the general purpose registers.

image.png

Assume that the content of memory location 3000 is 10 and the content of the register R3 is 2000. The content of each of the memory locations from 2000 to 2010 is 100. The program is loaded from the memory location 1000. All the numbers are in decimal.

Consider the data given in above question. Assume that the memory is word addressable. After the execution of this program, the content of memory location 2010 is:

Answer: A. 100Key idea: determine how many times the loop runs and which memory addresses it updates. Step-by-step execution: MOV R1, (3000) sets R1 = M[3000] = 10. The…

  1. A.

    100

  2. B.

    101

  3. C.

    102

  4. D.

    110

Attempted by 33 students.

Show answer & explanation

Correct answer: A

Key idea: determine how many times the loop runs and which memory addresses it updates.

Step-by-step execution:

  • MOV R1, (3000) sets R1 = M[3000] = 10.

  • The loop body (for each iteration) does:

    • R2 ← M[R3] (initially 100), then R2 ← R1 + R2, and M[R3] ← R2.

    • R3 is incremented by 1 and R1 is decremented by 1.

Because R1 starts at 10, the loop runs exactly 10 times. R3 starts at 2000, so the loop writes to addresses 2000, 2001, …, 2009 (one address per iteration).

Values written on each iteration:

  1. Iteration 1 (R1=10): address 2000 ← 100 + 10 = 110

  2. Iteration 2 (R1=9): address 2001 ← 100 + 9 = 109

  3. Iteration 3 (R1=8): address 2002 ← 100 + 8 = 108

  4. Iteration 4 (R1=7): address 2003 ← 100 + 7 = 107

  5. Iteration 5 (R1=6): address 2004 ← 100 + 6 = 106

  6. Iteration 6 (R1=5): address 2005 ← 100 + 5 = 105

  7. Iteration 7 (R1=4): address 2006 ← 100 + 4 = 104

  8. Iteration 8 (R1=3): address 2007 ← 100 + 3 = 103

  9. Iteration 9 (R1=2): address 2008 ← 100 + 2 = 102

  10. Iteration 10 (R1=1): address 2009 ← 100 + 1 = 101

Since only addresses 2000 through 2009 are updated, memory location 2010 is never modified and therefore retains its original value 100.

Final answer: 100

Explore the full course: Isro

Loading lesson…