I know that when a proc ends all the LOCALS are cleared up but what about the arguments? Will they be cleaned up my masm when et is called.
Posted on 2002-02-03 11:39:58 by Quantum
Yes, the STDCALL method which most windows API functions use, adjust the stack to eliminate the arguments. MASM hides most of this from the programmer making changes to PROCs easier, and use of them less error prone.
Posted on 2002-02-03 12:03:28 by bitRAKE
The most notable exception to this rule is:
wsprintfA function that has C calling conventions...

so you have to balance the stack at the end for this function (add esp,nr_params*4)
Posted on 2002-02-03 12:21:56 by BogdanOntanu
Only if you use a gay assembler. Works wonderfully automatically
in masm.
Posted on 2002-02-03 16:00:39 by f0dder

basically the stack is temporary storage space for parameters and local variables that is constructed at the beginning of the procedure. The caller pushes the parameters onto the stack and the proc has the space for locals allocated on the stack so when a procedure is finished, neither the locals or the arguments are accessible as the top of the stack is reset back to another location.


Posted on 2002-02-03 17:16:27 by hutch--
fodder, what is "a gay" assembler? :D

i was doing it even when i used MASM, i guess i missed something, like i should define the PROC C instead of STDCALL is that it? ...
Posted on 2002-02-04 01:13:59 by BogdanOntanu
To: Super Moderator
From: Super Swine
The method he mentioned only worked with invoke.
And you're right about C type - it needed to be declared with proto.
SomeCconvProc proto C :DWORD,:VARARG
invoke SomeCconvProc h,a,g

will result in
push g
push a
push h
call SomeCconvProc
add esp 12 ;! automatically generated!

But if you forget either C in proto or use invoke it will not be generated by MASM.
I think TASM could do it too.

Posted on 2002-02-04 05:35:32 by The Svin