Hi Pelle,
Poasm adjusts the stack to store the local variables and the shadow space of the X64 calling convention. For example :
main PROC a1:QWORD,a2:QWORD,a3:QWORD,a4:QWORD,a5:QWORD PARMAREA=4*SIZEOF QWORD
LOCAL temp1:QWORD
LOCAL temp2:QWORD
LOCAL temp3:QWORD
.
.
Poasm translates this to :
sub rsp, 72
My attempt to get the value of the substracted amount :
https://forum.pellesc.de/index.php?msg=41979
The purpose of this operation is to save correctly the volatile registers rcx,rdx,r8 and r9 to the shadow space of the calling procedure. My method is to get the allocation from the statement add rsp,X before ret.
Kindly, could you implement an internal equate like @StackRes ( stack reservation ) simplifying the access to the shadow space? It would be the coder's responsiblity to preserve this equate and take in account the volatile registers pushed to the stack by main PROC uses rsi edi etc.
An example :
main PROC a1:QWORD,a2:QWORD,a3:QWORD,a4:QWORD,a5:QWORD PARMAREA=4*SIZEOF QWORD
LOCAL temp1:QWORD
LOCAL temp2:QWORD
LOCAL temp3:QWORD
.
.
Poasm emitting @StackRes:
mov rax,@StackRes
mov temp3,rax
mov QWORD PTR [rsp+rax+8],rcx
mov QWORD PTR [rsp+rax+16],rdx
.
.