Assembly – returns the location of the program counter after the interrupt handler?
Hi, I want to know where the program counter is when the program returns from the interrupt service program? I know that when an interrupt event occurs, the PC is pushed onto the stack But what address is pushed to the next or the same address on the stack (only one is executed)? When we have
first instruction; interrupt event here; go inside the ISR; exit ISR; second instruction;
or
first instruction; interrupt event here; go inside the ISR exit ISR; first instruction;
I mean, does the PC point to the instruction executed before the ISR entry or to the next instruction (after returning from the ISR)? I hope you understand the idea
Solution
Because the interrupt cannot be processed before the CPU is in a precisely fixed state, if an interrupt occurs in the middle of an instruction, it will jump to the interrupt vector program after executing the instruction
Therefore, when returning from the interrupt process, the PC will point to the instruction after the first one
first instruction fetch (PC is updated meanwhile) first instruction decode interrupt is raised first instruction execution ** Now and only Now the cpu checks for a possible interrupt ** interrupt is present,pushing PC on stack and other things jump to interrupt address execution of interrupt return from interrupt (pop of PC and other things) second instruction fetch ...