847 views
3 votes
3 votes
Consider following program

MOV R1,5000

MOV R2,2000

ADD R2,R2,R3     //Interrupt raised here, Mem Add of this instruction is 1008

 

Now when ISR is served and program resumes from ADD instruction(1008), R1 and R2 will have different values then intended. How is it taken care of?

case 1: All register values are stored before interuptt and replaced.

case 2: Program begins execution from MOV R1,5000 after interuptt is served.

1 Answer

2 votes
2 votes
the answer is in how interrupts are handled in cpu. after every instruction the interrupt flag are checked. if there is a interrupt then all the values of register and as well as program counter are stored in special registers. and the interrupt vector address is pushed onto the stack. and after the service . all the pc and the registers are again set to the earlier position ,and no need to restart the program.

Related questions