Hi I am wondering where the program counter goes when the program returns from interrupt service routine? I know when the interrupt event occurs the PC is pushed into the st
There are 2 types of interrupts : a) Software interrupt- caused due to some critical problems like division by zero during execution of an instruction (say i th instruction) in a program(say program is Divide 2 number).
How is this handled by CPU?
Very much like an exception in Java. In this case the interrupt request is immediately handled(current i th instruction is not finished). current PC value( pointing to address of i+1 th instruction) is saved in some location. Interrupt is processed and after serving interrupt,it returns for of execution division program to finish i+1 th instruction and rest of instructions.
b) Hardware interrupt - processor is running a program when some input arrived from a keyboard (for example) or some other hardware.
How is this handled by CPU?
In this case CPU doesn't immediately serve interrupt request .It first completes the execution of current i th instruction, saves PC current value (pointing to address of i+1 th instruction) in some location . Then it listens to that interrupt, finish it and later comes back to old program instruction i+1 .