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:

    I introduced her to Elena, and in that life-quickening atmosphere of a big railway station where everything is something trembling on the brink of something else, thus to be clutched and cherished, the exchange of a few words was enough to enable two totally dissimilar women to start calling each other by their pet names the very next time they met.
    Vladimir Nabokov (1899–1977)

    Languages exist by arbitrary institutions and conventions among peoples; words, as the dialecticians tell us, do not signify naturally, but at our pleasure.
    François Rabelais (1494–1553)