GATE CS 2021 Set 1 — Question 65
Go beyond PYQs with Success TrackerAI-powered personalised practice and doubt support. Unlimited practice on eligible plans; AI usage limits apply.NAT+2 / -0HardInstruction FormatsInstructions & Addressing ModesComputer Organization & ArchitectureAddressing Modes
Computer Organization & Architecture → Instructions & Addressing Modes → Addressing Modes
Last updated
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 |
Correct answer
50 to 50
Solution
The program executes as follows:
The loop starts at address 1004 and continues while R1 is not zero (
1.Initialization:
-
MOV R1, (5000): Loads value 10 into R1. - R3 is given as 3000.
- Memory locations 3000 to 3010 are initialized to 0.
The loop starts at address 1004 and continues while R1 is not zero (
BNZ 1004).- Iteration 1:
-
MOV R2, (R3): R2 = Mem[3000] = 0. -
ADD R2, R1: R2 = 0 + 10 = 10. -
MOV (R3), R2: Mem[3000] = 10. -
INC R3: R3 becomes 3001. -
DEC R1: R1 becomes 9. - Iteration 2:
-
MOV R2, (R3): R2 = Mem[3001] = 0. -
ADD R2, R1: R2 = 0 + 9 = 9. -
MOV (R3), R2: Mem[3001] = 9. -
INC R3: R3 becomes 3002. -
DEC R1: R1 becomes 8. - ...
- Iteration 10:
- R1 is 1. R3 is 3009.
-
MOV R2, (R3): R2 = Mem[3009] = 0. -
ADD R2, R1: R2 = 0 + 1 = 1. -
MOV (R3), R2: Mem[3009] = 1. -
INC R3: R3 becomes 3010. -
DEC R1: R1 becomes 0. -
BNZ 1004: R1 is 0, so the branch is NOT taken.
- The program halts.
- The memory location 3010 was never written to (the last write was to 3009).
- Since Mem[3010] was initialized to 0, it remains 0.
Continue learning with Success Tracker
A step still unclear? Work through it with support
Use Success Tracker to ask about the reasoning, then try another GATE CS question to check your understanding.
AI-powered practice· Unlimited practice on eligible plans
- PYQs with solutions
- Attempt available previous-year questions, then compare your reasoning with the worked solution. Coverage varies by stream.
- Practice that adapts
- Choose a topic, work on weaker areas and bookmark questions to revisit. Your attempts feed your progress tracking.
- AI doubt support
- Ask follow-up questions about a step or concept while practising, instead of stopping at the final answer.
Unlimited practice is available on eligible plans. Free practice and AI usage have limits; check the current plan allowances before choosing.
This page stays readable without an account. AI responses can be wrong; check them against the solution and source material.
More questions on Instructions & Addressing Modes
2026 Set 1 Q14Match each addressing mode in List I with a data element or an element of a data structure (in…2026 Set 1 Q15Consider a processor P whose instruction set architecture is the load-store architecture. The…2026 Set 1 Q16Which one of the following dependencies among the register operands of different instructions can…2026 Set 2 Q18Consider the following two statements about interrupt handling mechanisms in a CPU. S1: In…2026 Set 1 Q38The size of the physical address space of a processor is bytes. The capacity of a cache…