Apoligies if I misunderstand your question... in an interrupt handler you
have to preserve any register you modify including flags... then not only
must the stack be balanced to RET back to a interrupted routine, you also
have to restore flags and registers before you return from interrupt.

Imagine you are a foreground routine happily doing some operations and
unbeknownst to you (as they do) a hardware interrupt happens. The only
thing placed on the stack before interrupt starts executing is the
instruction pointer of the interrupt routine. No registers, because the CPU
doesn't know what registers will be damaged by the interrupt handler.

Really every subroutine has to do stack balancing, and only modify system
variables / hardware state in a careful way within the system design.

But not balancing the stack or not restoring flags or registeres in an
interrupt handler can create some very hard to track down bugs.

I'd guess all interrupt handlers are going to push psw, since almost all
interrupt handler logic is complicated enough to have flags get modified
even as only a side-effect that the logic doesn't care about.

-- John.

>

Reply via email to