hi experts :rolleyes: ,

anyone can let me know, where can i find a tutorial on how to pass parameter to stack
for each calling convention?

thanks,
de_ep :alright:
Posted on 2002-10-22 16:18:23 by de_ep
de_ep,

in most instances the assembler handles it for you and MASM normally handles C and STDCALL conventions. Pascal convention depends on which version you are after, the old one is rarely used in 32 bit windows, left to right pushes but in recent times, Microsoft have redefined it the same as STDCALL.

STDCALL is an easy one, push parameters in reverse order, call the function, function handles the stack entry and exit, return value if needed in EAX.

I forget out of my head the C convention but it is pushed in reverse with the capacity of a variable number of parameters, function corrects the stack on exit. Maybe one of the guys here will be more up to date on the details than I am at the moment.

Regards,

hutch@movsd.com
Posted on 2002-10-22 19:56:13 by hutch--
IIRC, C calling convention is the same as STDCALL, except the stack is corrected by the caller:
; C

push 2
push 1
push 0
call function
add esp, 12
...
function:
retn


; STDCALL
push 2
push 1
push 0
call function
...
function:
retn 12
Posted on 2002-10-22 21:49:53 by bitRAKE
Posted on 2002-10-23 02:41:32 by Four-F
AFAIK STDCALL also has an extra qualification - if the called procedure has a variable number of arguments, caller clears the stack. In effect, it devolves into CDECL when you use vararg.
Posted on 2002-10-23 04:12:22 by AmkG

I forget out of my head the C convention but it is pushed in reverse with the capacity of a variable number of parameters, function corrects the stack on exit. Maybe one of the guys here will be more up to date on the details than I am at the moment.


Caller corrects the stack after function's return...
Posted on 2002-10-23 04:14:53 by JCP