CODE | Resulting stack (High address)
PUSH RAX | RAX's value
PUSH RBX | RBX's value
CALL CODE | RET address
That would result in a stack shown on the right. And if I want to get at the pushed RAX/RBX values than I need to first put the address that CALL put there somewhere safe and return it to the stack before RET.
Am I missing anything else? Considering I have been programming in Assembly for two years and only found this out now I have a feeling that there might be more. Or that I got this wrong.
Developer of CDE the Cooperative Driver Environment <No website currently>
PUSH RAX | RAX's value
PUSH RBX | RBX's value
CALL CODE | RET address
...
CODE:
mov eax,[esp] ;eax = return address
mov eax,[esp+4] ;eax = first parameter on stack
add eax,[esp+8] ;eax = sum of parameters = returned value
ret ;For "C calling convention" where caller cleans up their own stack
ret 4*2 ;For "Pascal calling convention" where callee cleans up the stack
It gets a little messier if you're preserving registers and using local variables though (and much worse once you start looking at 64-bit calling conventions).
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
I decided to forego a predefined calling convention and implement a pre-made one later. I'm just using something simple that I thought up so I can get to writing my code.
But I ran into several interrupt resulting issues whenever I tried to retrieve the variables. Now I know why.
Developer of CDE the Cooperative Driver Environment <No website currently>