In a microprocessor-8085 we run the command CALL 3000H . The program counter (PC) is equal to (PC)=2000H and the stack pointer is equal to (SP)=4000H. In the middle of the execution of the command we have an RST 5.5 interruption. I want to define the new values of PC and SP. I also want to find the contents of the stack and the operations happening before and after the routine return.
I consider that since the interruption takes place after the start of the command CALL 3000H, the command will be completed. After it finishes, the interruption takes place. Program counter (PC) needs to be stored at the stack so that the program can return to the point that the call was made. This means that (SP) is adjusted. Program counter (PC) will take the value (PC) = 002CH after the RST 5.5 interruption.
Is my approach correct? If so , I am still a bit confused with the stack pointer (SP) and the stack. What's exactly going to happen with the adjustment of the stack and the (SP) value?
You’re right that since the interrupt arrived after the start of the call instruction, the instruction will complete and then the interrupt will be serviced.
So, first the stack pointer is decremented by 2, the PC of the instruction after the call (2003h) is stored at 3ffeh, and the PC is loaded with the destination of the call (3000h).
Then the interrupt is serviced: the SP is decremented again, to 3ffch, the PC (3000h) is stored there, and the PC is loaded with the interrupt handler address.