← Learn

Introduction to Windows API

Author
Moise Medici
Updated
23 Jan 2026 · Completed

stdcall

stdcall is very similar to cdecl with the only exception that the function clears up the stack internally and the caller doesn’t have to care about it. At the end of the function it executes ret 8 which does two operations at once:

  • by default it pops the return address into EIP
  • if it is called with an operand, like 8 it cleans up the stack with ADD ESP, 8
FUN PROC
push ebp
mov ebp, esp
mov eax, [ebp+8] ; a
add eax, [ebp+12] ; + b
pop ebp
ret 8 ; callee cleans 2 args (8 bytes)
FUN ENDP

The caller calls the function the same way as cdecl but after the call, the stack is already cleaned:

push b
push a
call FUN
; EAX = result