Consider the following program segment for a hypothetical CPU having three user registers and Consider that the memory is byte addressable with size bits, and the program has been loaded starting from memory location (decimal). If an interrupt occurs while the CPU has been halted after executing the HALT instruction, the return address (in decimal) saved in the stack will be
View worked solution
Answer: D
To find the return address saved in the stack, we need to determine the memory address of the instruction immediately following the HALT instruction.
1. Understand the Word Size
The memory is byte-addressable, and the word size is . Therefore, each word occupies bytes of memory.
2. Calculate Memory Allocation for Each Instruction
The program starts at memory location (decimal). We calculate the address range for each instruction based on its size in words:
- Instruction 1:
MOV R1, 5000- Size:
- Address range: to
- Instruction 2:
MOV R2, (R1)- Size:
- Address range: to
- Instruction 3:
ADD R2, R3- Size:
- Address range: to
- Instruction 4:
MOV 6000, R2- Size:
- Address range: to
- Instruction 5:
HALT- Size:
- Address range: to
3. Determine the Return Address
During the fetch phase of the HALT instruction (located at address ), the Program Counter () is automatically incremented to point to the next instruction address:
When an interrupt occurs after executing the HALT instruction, the CPU saves the current value of the onto the stack as the return address. Thus, the saved return address is .
Free practice · Your answers on this page are not saved.
