This is necessary because after the processor responds to an interrupt, it needs to know how to resume execution of whatever it was doing when it got interrupted.
Right before the processor saves the address of the instruction to resume to, it also disables interrupt. This is done automatically. This practice is common to most processors and MCUs because it is tricky to handle another interrupt when a processor is in the process of responding to the first one.
An ISR is typically short and does not take much time to complete. At the completion of an ISR, a special return instruction is used. This instruction returns to the saved address on the stack. This allows the processor resume execution of code that was interrupted. However, this special instruction also reenables interrupt after the address to resume to is retrieved.
This way, even if there are multiple devices request interrupts, we only need enough space to save one single instruction address.
Copyright © 2006-02-15 by Tak Auyeung