flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
bitRAKE
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
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
Thanks.
But I have many 32 bit code with push/pop. And I won't rewrite all this to 64 bits |
|||
![]() |
|
revolution
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
Thanks.
Work in 64 bits |
|||
![]() |
|
revolution
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
Nice ! Very nice !
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.