flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
bitRAKE 25 Aug 2020, 19:41
Stacks move backward from high memory to low memory.
Also, since the top dword on the stack is undefined, it's best to PUSH RAX for case of EAX. The method you suggest is needed when wanting to preserve the high dword data, but by definition low stack values are undefined. This is why I created register alias' - to ease macro creation. Prior to that I was passing strange parameters like: <RAX,EAX>, RAX:EAX, etc. and using MATCH to break out that condition. Seems like you are going from 32-bit to 64-bit, though. fasm source has some examples of doing that in .\source\linux\x64\modes.inc There are some fasm specific caveats though. |
|||
![]() |
|
revolution 26 Aug 2020, 00:48
If you really need to emulate 32-bit push in 64-bit mode then do this:
Code: lea rsp,[rsp-4] mov dword [rsp],my_value Code: lea rsp,[rsp-4] mov [rsp],eax ;any 32-bit register |
|||
![]() |
|
Roman 26 Aug 2020, 04:11
Thanks.
But I have many 32 bit code with push/pop. And I won't rewrite all this to 64 bits |
|||
![]() |
|
revolution 26 Aug 2020, 04:54
It you accept that 32-bit pushes must be promoted to 64-bit (as bitRAKE suggested) then you can do something like this:
Code: macro push thing { if thing in <eax,edx,ecx,ebx,esp,ebp,esi,edi> use32 push thing use64 else push thing end if } ;test it use64 irp reg, ax,cx,dx,bx,sp,bp,si,di { push r#reg push e#reg } push 0 push 4*5 |
|||
![]() |
|
Roman 26 Aug 2020, 06:00
Thanks.
Work in 64 bits |
|||
![]() |
|
revolution 26 Aug 2020, 06:32
This might be more useful:
Code: macro push thing { irp reg, ax,cx,dx,bx,sp,bp,si,di \{e\#reg equ r\#reg\} push thing restore eax,ecx,edx,ebx,esp,ebp,esi,edi } ;test it use64 irp reg, ax,cx,dx,bx,sp,bp,si,di { push r#reg e#reg } push 0 4*5 qword[rax] |
|||
![]() |
|
Roman 26 Aug 2020, 06:40
Nice ! Very nice !
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.