flat assembler
Message board for the users of flat assembler.
Index
> Main > Popad: Procedure epilogue question |
Author |
|
revolution 26 Oct 2016, 04:15
MrFox wrote: My idea is to directly modify 'EAX' in the stack before popping (not sure if all machines use the same order). |
|||
26 Oct 2016, 04:15 |
|
MrFox 26 Oct 2016, 04:24
Yay, thanks!
Pushad/popad work with 32bit registers. What can I use in case of 64bit code? (I'm trying to think of portability) |
|||
26 Oct 2016, 04:24 |
|
revolution 26 Oct 2016, 04:27
The is no 64-bit equivalent of PUSHA or POPA. You can use individual PUSH/POP or adjust RSP and directly save/restore registers to/from the stack with MOV.
|
|||
26 Oct 2016, 04:27 |
|
MrFox 26 Oct 2016, 04:37
Oops, ok, thanks!!!
|
|||
26 Oct 2016, 04:37 |
|
neville 26 Oct 2016, 10:48
revolution wrote: The is no 64-bit equivalent of PUSHA or POPA. You can use individual PUSH/POP or adjust RSP and directly save/restore registers to/from the stack with MOV. _________________ FAMOS - the first memory operating system |
|||
26 Oct 2016, 10:48 |
|
revolution 26 Oct 2016, 11:06
neville wrote: [rant]Yet another example of the half-baked X86-64bit implementation, "thanks" to AMD for developing it and "thanks" to Intel for falling asleep and dropping the ball. Although it's completely incompatible with X86 maybe IA64 would've been better after all. Too late now though... the last Itanium processor was produced about 4 years ago?[/rant] But the code generated from C compilers also has a large influence upon which instructions are deemed important. Perhaps C doesn't make much use of PUSHA and POPA so they were excised in favour of improving other more used portions of the CPU. |
|||
26 Oct 2016, 11:06 |
|
CandyMan 26 Oct 2016, 11:40
I am using such a PUSHA/POPA substitute:
Code: AnyCode: CALL PushAll ;... CALL PopAll RET PushAll: XCHG R15,[RSP] PUSH R14 PUSH R13 PUSH R12 PUSH R11 PUSH R10 PUSH R9 PUSH R8 PUSH RBP PUSH RSI PUSH RDI PUSH RDX PUSH RCX PUSH RBX PUSH RAX PUSH R15 MOV R15,[RSP+15*8] RET PopAll: POP R15 POP RAX POP RBX POP RCX POP RDX POP RDI POP RSI POP RBP POP R8 POP R9 POP R10 POP R11 POP R12 POP R13 POP R14 XCHG [RSP],R15 RET _________________ smaller is better |
|||
26 Oct 2016, 11:40 |
|
AsmGuru62 26 Oct 2016, 14:54
Order is same.
I use it always: Code: virtual at 0 regsAtPopa: .reg_EDI dd ? .reg_ESI dd ? .reg_EBP dd ? .Skip dd ? .reg_EBX dd ? .reg_EDX dd ? .reg_ECX dd ? .reg_EAX dd ? end virtual ... mov [esp + regsAtPopa.reg_EAX], ... return value ... popa ret You can also return other registers while preserving the rest. |
|||
26 Oct 2016, 14:54 |
|
MrFox 29 Oct 2016, 13:29
Thanks, guys!
I'm now using "mov [esp+28], eax" and it works just fine! |
|||
29 Oct 2016, 13:29 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.