Hello, i am now working on my interrupt handlers and currently i am pushing all the registers onto the stack and popping them all of before iret'ing however in IA-32 there are the popa and pusha instructions which do all this i imagine that they are faster and i am wondering if there is a similar pair of instructions in AMD64.
I have read the AMD manuals all i can gather from there is that the popa and pusha op-codes have been reassigned. Does anyone know of a equivalent pair of instructions that exist in AMD64 (long mode)?
thanks
no pusha or similar instruction in AMD64?
no pusha or similar instruction in AMD64?
The BBC micro could have become the world standard - it was so ahead of its time
Unfortunately, there's not an equivalent. I use the following macros suggested by the NASM manual:
With these, you can provide the registers to push and pop in the same order, which makes things a bit easier to remember.
Cheers,
Adam
Code: Select all
%macro multipush 1-*
%rep %0
push %1
%rotate 1
%endrep
%endmacro
%macro multipop 1-*
%rep %0
%rotate -1
pop %1
%endrep
%endmacro
Cheers,
Adam
thank you AJ, i got interrupts working today (they would have worked first time if i had known that NASM wasn't cleaver enough to automatically use the long mode iret op-code, i had to manually specify iretq in the end)
The BBC micro could have become the world standard - it was so ahead of its time
Re: no pusha or similar instruction in AMD64?
I like the solution, but I'd like to know if (E)SP needs any special handling? I refer to the Intel opcode reference http://www.intel.com/content/dam/www/pu ... 325383.pdf, page 4-274.
The PUSHA instruction saves the SP to a temporary variable and then puts it on the stack. Is it sufficient to just push SP first? Thanks.
The PUSHA instruction saves the SP to a temporary variable and then puts it on the stack. Is it sufficient to just push SP first? Thanks.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: no pusha or similar instruction in AMD64?
There's actually no need to push/pop RSP specifically in long mode. An interrupt already does that for you in all cases, and any properly paired push/pop to RSP will only add or subtract 8 from it since pushes and pops implicitly use RSP.