Consider the following program segment. Here and are the general purpose registers.
Assume that the content of memory location is and the content of the register is The content of each of the memory locations from to is The program is loaded from the memory location All the numbers are in decimal.
Assume that the memory is byte addressable and the word size is bits. If an interrupt occurs during the execution of the instruction “INC R3”, what return address will be pushed on to the stack?
View worked solution
Answer: C
Since the memory is byte-addressable and the word size is , each word occupies bytes of memory. We can calculate the starting memory address of each instruction starting from location :
| Instruction | Size (words) | Size (bytes) | Memory Address Range |
|---|---|---|---|
MOV R1,(3000) |
2 | to | |
LOOP: MOV R2,(R3) |
1 | to | |
ADD R2,R1 |
1 | to | |
MOV (R3),R2 |
1 | to | |
INC R3 |
1 | to | |
DEC R1 |
1 | to | |
BNZ LOOP |
2 | to | |
HALT |
1 | to |
When an interrupt occurs during the execution of an instruction (here, INC R3), the processor completes the execution of that current instruction. The return address pushed onto the stack is the address of the next sequential instruction to be executed, which is DEC R1 starting at address .
Free practice · Your answers on this page are not saved.
