20.1.4 The Standard Calling Convention

The STDCALL calling convention is the same as the C calling convention, with the exception that the responsibility for removing arguments from the stack belongs to the called routine. The C calling convention is followed exactly if the STDCALL procedure also specifies VARARG, allowing a variable number of parameters. STDCALL is provided for compatibility with 32-bit versions of Microsoft compilers which have STDCALL as their default.

Argument Passing

Argument passing order is the same as the C calling convention. The caller pushes the arguments from right to left. Unlike the C calling convention, however, the called routine must remove arguments from the stack unless the routine uses VARARG to specify a variable number of arguments, in which case the caller removes the parameters from the stack.

Register Preservation

Routines using the STDCALL convention must preserve the same registers required by the C calling convention: BP, SI, DI, DS, and SS. The direction flag is also cleared on entry and must be preserved.

Varying Number of Arguments

If the routine uses VARARG to specify that a variable number of arguments can be passed, the calling routine must remove arguments from the stack.