x86 Assembly set of \'push\'es and \'pusha\' difference?

Answer

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
...

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.

All x86 Questions

Ask your interview questions on x86

Write Your comment or Questions if you want the answers on x86 from x86 Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---