<<< __cdecl, the C-style calling convention | Index | C-style Procedure Call Example >>> |
PASCAL-style parameters are pushed on the stack in left-to-right order.
The STDCALL calling convention is a variation of the PASCAL calling convention in which are pushed on the stack right-to-left.
Note: parameters to Windows API functions are passed using the STDCALL calling method.
Pascal-style procedure call is made with the
caller pushing parameters into the stack in left-to-right order (opposite of __cdecl)
calling the function
stack is cleaned up by the callee
; example of pascal-style call. ; NOTE: __stdcall would push the arguments in reverse order. push arg1 push arg2 push arg3 call function ; no stack cleanup upon return: callee did it
PASCAL and STDCALL call
pros:
the code is slightly smaller, though the size impact is only visible in large programs.
cons:
C functions like printf() have variable arguments (aka variadic functions)
Variadic functions are almost impossible to get right with PASCAL and STDCALL methods, because only the caller really knows how many arguments were passed in order to clean them up.
See also: Using
<<< __cdecl, the C-style calling convention | Index | C-style Procedure Call Example >>> |