Yes, pusha
and popa
are functionally equivalent, if only because they push/pop all registers. However, is it necessary to do so for a simple DOS Interrupt call?
Transferring to an Interrupt Routine
...
- It is the responsibility of the interrupt routine to restore any registers it uses
(http://www.shsu.edu/csc_tjm/spring2001/cs272/interrupt.html)
As with all operations, do as much as is needed and nothing more. An interrupt call must preserve registers - apart from the ones that are documented to change. Regular status calls return their result in AX
and may change the flags, and change nothing else. If an interrupt changes anything else (ds:dx
, for example), it should be stated so in its documentation.
In your code, using ah=09 / int 21
, the only change is
Return: AL = 24h
and so all other registers can safely be assumed "stored".
There is a reason an interrupt preserves as much as possible. Globally, an interrupt (the "real" ones, not the user-invoked) may happen any time while other code is running.
There is also a good reason not to use pusha/popa
indiscriminately. Your stack has a limited size -- sure, it's large, but so is the number of routines that can be nested. And in 32- and 64-bit code the registers are way larger as well.
Every single routine should preserve only those registers that are known to change, and mirroring that, you should only save the ones you will need later before you call such a routine. In the example code there are none, so you can safely remove all pushing and popping.