X86 Calling Conventions

X86 Calling Conventions

This article describes the calling conventions used on the x86 architecture.

Calling conventions describe the interface of called code:

  • The order in which atomic (scalar) parameters, or individual parts of a complex parameter, are allocated
  • How parameters are passed (pushed on the stack, placed in registers, or a mix of both)
  • Which registers may be used by the callee without first being saved (i.e. pushed)
  • How the task of setting up for and restoring the stack after a function call is divided between the caller and the callee

This is intimately related with the assignment of sizes and formats to programming-language types. Another closely related topic is name mangling, which determines how symbol names in the code map to symbol names used by the linker. Calling conventions, type representations, and name mangling are all part of what is known as an Application Binary Interface (ABI).

There are often subtle differences in how various compilers implement these conventions, so it is often difficult to interface code which is compiled by different compilers. On the other hand, conventions which are used as an API standard (such as stdcall) are very uniformly implemented.

Read more about X86 Calling Conventions:  Historical Background, Caller Clean-up, Callee Clean-up, Intel ABI, List of X86 Calling Conventions

Famous quotes containing the words calling and/or conventions:

    When I was in high school I thought a vocation was a particular calling. Here’s a voice: “Come, follow me.” My idea of a calling now is not: “Come.” It’s like what I’m doing right now, not what I’m going to be. Life is a calling.
    Rebecca Sweeney (b. 1938)

    It is not human nature we should accuse but the despicable conventions that pervert it.
    Denis Diderot (1713–1784)