X86 Calling Conventions - Callee Clean-up

Callee Clean-up

When the callee cleans the arguments from the stack it needs to be known at compile time how many bytes the stack needs to be adjusted. Therefore, these calling conventions are not compatible with variable argument lists, e.g. printf. They may be, however, more space efficient, as the code needed to unwind the stack does not need to be generated for each call.

Functions which utilize these conventions are easy to recognize in ASM code because they will unwind the stack prior to returning. The x86 ret instruction allows an optional 16-bit parameter that specifies the number of stack bytes to unwind before returning to the caller. Such code looks like this:

ret 12

Read more about this topic:  X86 Calling Conventions