Article ID: 100832
Article Last Modified on 12/9/2005
_cdecl _stdcall _fastcall
-------------------------------------------------------------------
Arguments Pushed R to L Pushed R to L Note 3
Stack cleaned up by Caller Called Called
Naming convention Prepend "_" Note 1 Note 2
Note 1 The _stdcall calling convention decorates each function name by prepending an underscore character (as the _cdecl convention does) and appending an at sign "@" and the decimal representation of the number of bytes of stack space required. Each argument is widened to a multiple of four bytes.
Note 2 The _fastcall calling convention decorates each function name by prepending an at sign "@" and appending an at sign and the decimal representation of the number of bytes of stack space required. Each argument is widened to a multiple of four bytes.
Note 3 The first two function arguments that require four or fewer bytes are placed into registers. The caller pushes the remainder of the parameters onto the stack from right to left. This behavior may change in future versions.
int _cdecl CFunc(int a, int b);
calling function called function
-------------------------------------------
push b _CFunc PROC NEAR
push a .
call _CFunc .
add esp,8 .
. RET
. _CFunc ENDP
.
int _cdecl CVarFunc(int a, ...);
calling function called function
-------------------------------------------
push ... _CVarFunc PROC NEAR
push a .
call _CVarFunc .
add esp,4+... .
. RET
. _CVarFunc ENDP
.
The following code example illustrates the code generated in the
calling function and in the called function to support the standard calling
convention.
int _stdcall StdFunc(int a, int b);
calling function called function
-------------------------------------------
push b _StdFunc@8 PROC NEAR
push a .
call _StdFunc@8 .
. .
. RET 8
. _StdFunc@8 ENDP
The following code example illustrates the code generated in the
calling function and in the called function to support the fastcall calling
convention.
int _fastcall FastFunc(int a, int b);
calling function called function
-------------------------------------------
mov edx, b @FastFunc@8 PROC NEAR
mov ecx, a .
call @FastFunc@8 .
. .
. RET 8
. @FastFunc@8 ENDP
Keywords: kbhowto kbinfo kbcompiler KB100832