Similar questions 1 more →
Input/Output, DMA & Interrupts
![Question 63, GATE 2004: A CPU has user registers R1,R2,R3. Program in order (operation; instruction size in words): MOV R1,5000 (R1←Memory[5000];2); MOV R2,(R1) (R2←Memory[R1];1); ADD R2,R3 (R2←R2+R3;1); MOV 6000,R2 (Memory[6000]←R2;2); HALT (machine halts;1). Memory is byte-addressable with 32-bit words and the program starts at decimal 1000. If an interrupt occurs after HALT has executed, what decimal return address is saved on the stack?
Options:
(A) 1007
(B) 1020
(C) 1024
(D) 1028](../../assets/questions/CS-2004-Q63-1.webp)
![Question 63, GATE 2004: A CPU has user registers R1,R2,R3. Program in order (operation; instruction size in words): MOV R1,5000 (R1←Memory[5000];2); MOV R2,(R1) (R2←Memory[R1];1); ADD R2,R3 (R2←R2+R3;1); MOV 6000,R2 (Memory[6000]←R2;2); HALT (machine halts;1). Memory is byte-addressable with 32-bit words and the program starts at decimal 1000. If an interrupt occurs after HALT has executed, what decimal return address is saved on the stack?
Options:
(A) 1007
(B) 1020
(C) 1024
(D) 1028](../../assets/questions/CS-2004-Q63-2.webp)
![Question 63, GATE 2004: A CPU has user registers R1,R2,R3. Program in order (operation; instruction size in words): MOV R1,5000 (R1←Memory[5000];2); MOV R2,(R1) (R2←Memory[R1];1); ADD R2,R3 (R2←R2+R3;1); MOV 6000,R2 (Memory[6000]←R2;2); HALT (machine halts;1). Memory is byte-addressable with 32-bit words and the program starts at decimal 1000. If an interrupt occurs after HALT has executed, what decimal return address is saved on the stack?
Options:
(A) 1007
(B) 1020
(C) 1024
(D) 1028](../../assets/questions/CS-2004-Q63-3.webp)
Answer & solution
Answer: D (no official key was published)
1. The five instructions occupy 2+1+1+2+1=7 words. Each word is 32 bits=4 bytes, so the program occupies 28 bytes starting at 1000.
2. Under the ordinary next-instruction-PC convention, after fetching/executing HALT the saved return address is 1000+28=1028. HALT itself begins at 1024;1007 would confuse word and byte addressing.
3. Teaching check: Instruction start addresses are 1000,1008,1012,1016,1024. HALT occupies one four-byte word, so the next sequential address is 1028. Saving 1024 would resume at HALT itself; saving 1007 wrongly treats byte-addressed memory as word-addressed.