GATE CSE 2021 Set 1 Q65: Memory location 3010 after a loop of array updates
- Computer Organization and Architecture
- 2 marks
- NAT
- No negative marking
Question
Consider the following instruction sequence where registers R1, R2 and R3 are general purpose and MEMORY[X] denotes the content at the memory location X.
Assume that the content of the memory location 5000 is 10, and the content of the register R3 is 3000. The content of each of the memory locations from 3000 to 3010 is 50. The instruction sequence starts from the memory location 1000. All the numbers are in decimal format. Assume that the memory is byte addressable.
After the execution of the program, the content of memory location 3010 is ________.
| Instruction | Semantics | Instruction Size (bytes) |
|---|---|---|
| MOV R1, (5000) | R1 ← MEMORY[5000] | 4 |
| MOV R2, (R3) | R2 ← MEMORY[R3] | 4 |
| ADD R2, R1 | R2 ← R1+R2 | 2 |
| MOV (R3), R2 | MEMORY[R3] ← R2 | 4 |
| INC R3 | R3 ← R3+1 | 2 |
| DEC R1 | R1 ← R1-1 | 2 |
| BNZ 1004 | Branch if not zero to the given absolute address | 2 |
| HALT | Stop | 1 |
Try it: numerical answer: type the value
Show answer and explanation
Answer: 50 (official GATE 2021 final answer key)
Concept used: Trace the loop: address 1004 is the second instruction, and R1 counts the iterations down from 10.
First step: The loop body runs 10 times with R3 = 3000, 3001, …, 3009: is 3010 ever written?
Full step-by-step solution
Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.
Share this question
Source: official GATE 2021 Set 1 CS question paper and final answer key, organised by IIT Bombay. Question paper · Answer key
More Computer Organization and Architecture PYQs
- 2026 Session 1 · Q14Match addressing modes with high-level data elements
- 2026 Session 1 · Q15Instruction sequence for Z = X + Y on a load-store machine
- 2026 Session 1 · Q16Register dependency that causes a data hazard
- 2026 Session 1 · Q36IEEE 754 single-precision sum of 35C00000 and 34A00000
- 2026 Session 1 · Q38Tag length: direct-mapped vs K-way set-associative cache
- 2026 Session 1 · Q54Impossible TLB / page table / cache event sequences