I have quite a simple question - why is it that when a function is being called we PUSH signature attributes onto the stack
THEN the function being called, instead of POP'ing the data off the stack, it uses direct stack pointer instructions - eg
push somecrap
call afunction
afunction:
.....(obligatory stack instructions)
mov eax,dword ptr ss:[esp+somcrapSTACKLOCATION]
...
turbo_nutter,
The simple answer is that the last item PUSHed is the return address. That will be the first thing POPed, and unless you save it, you will be unable to return to where the subroutine was called. Also a stack read can be done any number of times, but a POPed value has to be saved if you want to use it more than once. Ratch
nutter,
As long as the function you call balances the stack on exit or with C the stack is balanced by the caller, what you push before your call can be popped after the stack cleanup. With STDCALL you normall use RET NUMBER to balace the stack where with a C call you do an ADD ESP, number after the call has returned.
nice one! thanks - makes things a lot more clear!