In a certain computer system, there is special instruction implemented to call…
PYQ GATE 1989Modified — slightly modified from the official paper; see the solution
In a certain computer system, there is special instruction implemented to call subroutines. The instruction is
JSR Reg.Sub
Microsequence: Temp ← Sub; SP ← (SP)+2; (SP) ← (Reg); Reg ← (PC); PC ← (Temp)
Where Temp is an internal CPU register; Sub is calling routine address specification; Reg is any register in the system; SP is stack pointer; PC is program counter; (SP) refers to the contents of SP.
The system supports indirect addressing and autoincrement addressing modes. PC can be used as a link register. Sub field in the JSR instruction allows any operand specification, including the use of stack pointer along with some addressing modes.
Explain how you would implement co-routine using the JSR instruction. Show the control flow diagram and the contents of the stack before and after the call.
For this question, assume Sub is evaluated as a target address before any stack update; SP ← (SP)+2 advances a byte-addressed upward-growing stack by 2 bytes; (SP) ← (Reg) stores the old link-register value at the new top. Use a dedicated link register L, distinct from PC, and assume both coroutine entry addresses are initialized.
Sign up free to check your answer
Sign up freeLoading lesson…

