I can't understand this question.
"The content of the top of memory stack is 5320. The content of the stack pointer(SP) is 3560. A two-word call subroutine instruction is located in memory at address 1120 followed by the address field of 6720 at location 1121. What are the contents of PC, SP and the top of the stack :
- Before the call instruction is fetched from the memory
- After the call instruction is executed.
- After the return from subroutine"
1.Before the call instruction is fetched , the PC holds the address of the call instruction in memory that is 1120 . At that time the SP = 3560 and M[SP] = 5320.
2.After the call instruction is decoded and executed , the PC is incremented (PC = PC + 1) , and is equal to 1121 , which is the return address , and is stored on the top of the stack. Suppose , the stack pointer decreases by 1 for each push (SP = SP - 1) , and increases by 1 for each pop (SP = SP + 1). So, The SP value would be 3560 - 1 = 3559 , and M[3559] = 1121 (return address).
3.After the subroutine has finished executing , the return address is transferred to PC (PC = M[SP]) and SP is incremented(pop) (SP = SP + 1) So , now PC = 1121 and SP = 3559 + 1 = 3560 , and the M[SP] = M[3560] = 5320.
By far , this is all I know , as being a beginner.
My question is :
1. Is what I did right ?
2. If not then explain why.
3. If yes then what is the significance of the other values that don't serve any role in computation?