GATE / CS ARCHIVE

GATE CSE 2007 / QUESTION 73

Return address after interrupting INC

Computer Organization & Architecture · Input/Output, DMA & Interrupts · Full GATE CSE 2007 paper

GATE 2007, Q73 2 marks · MCQ
Report issue

Input/Output, DMA & Interrupts

Question 73, GATE 2007: R1,R2,R3 are general-purpose registers. The program, operation, and size in words are:
MOV R1,(3000): R1←M[3000], 2 words
LOOP: MOV R2,(R3): R2←M[R3], 1 word
ADD R2,R1: R2←R1+R2, 1 word
MOV (R3),R2: M[R3]←R2, 1 word
INC R3: R3←R3+1, 1 word
DEC R1: R1←R1−1, 1 word
BNZ LOOP: branch if the result is nonzero, 2 words
HALT: stop, 1 word.
Initially M[3000]=10, R3=2000 and each location 2000–2010 contains 100. The program begins at location 1000; all these numbers are decimal.
Now assume byte-addressable memory and 32-bit words. If an ordinary interrupt occurs while INC R3 executes, what return address is pushed onto the stack?
Options:
(A) 1005
(B) 1020
(C) 1024
(D) 1040
Question 73, GATE 2007: R1,R2,R3 are general-purpose registers. The program, operation, and size in words are:
MOV R1,(3000): R1←M[3000], 2 words
LOOP: MOV R2,(R3): R2←M[R3], 1 word
ADD R2,R1: R2←R1+R2, 1 word
MOV (R3),R2: M[R3]←R2, 1 word
INC R3: R3←R3+1, 1 word
DEC R1: R1←R1−1, 1 word
BNZ LOOP: branch if the result is nonzero, 2 words
HALT: stop, 1 word.
Initially M[3000]=10, R3=2000 and each location 2000–2010 contains 100. The program begins at location 1000; all these numbers are decimal.
Now assume byte-addressable memory and 32-bit words. If an ordinary interrupt occurs while INC R3 executes, what return address is pushed onto the stack?
Options:
(A) 1005
(B) 1020
(C) 1024
(D) 1040
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Approach. Sum instruction lengths through the completed INC, multiply by four bytes per word, and add the program base. An ordinary interrupt resumes at the next instruction, not at the interrupted instruction’s starting address.

2. Derivation and interpretation. Instructions up through INC occupy 2+1+1+1+1=6 words. At 4 bytes per word, the next instruction DEC R1 is at byte address 1000+6*4=1024. An ordinary interrupt is serviced after the current instruction completes and saves the next instruction address, so C. The INC itself starts at 1020.

Original paper, page 18