Most commons are cdecl, stdcall, fastcall
In function calls, parameters are pushed onto the stack/registers from right to left.
int func(int x, int y, int z, int m, int k);
int a, b, c, d, e, ret;
ret = func(a, b, c, d, e);
- C declaration
- uses stack frame
- The caller cleans up the stack
push e
push d
push c
push b
push a
call func
add esp, 20 ; cleaning up the stack. 5 integer parameters --> 4-bytes x 5 = 20
- Standart call
- used by Windows API
- uses stack frame
- callee cleans up the stack
push e
push d
push c
push b
push a
call func
; callee cleans up the stack so no need to add esp, 20
- uses registers(for first few instructions) and stack frame
- callee cleans up the stack
ecx, edx
(32-bit)(Microsoft)rcx, rdx, r8, r9
(64-bit)(Microsoft, Intel)
push e
push d
push c
mov edx, b
mov ecx, a
call func
; for x64
push e
mov r9, d
mov r8, c
mov rdx, b
mov rcx, a
call func