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:

    What is an artist? A provincial who finds himself somewhere between a physical reality and a metaphysical one.... It’s this in-between that I’m calling a province, this frontier country between the tangible world and the intangible one—which is really the realm of the artist.
    Frederico Fellini (b. 1920)

    Art, it seems to me, should simplify. That, indeed, is very nearly the whole of the higher artistic process; finding what conventions of form and what detail one can do without and yet preserve the spirit of the whole—so that all that one has suppressed and cut away is there to the reader’s consciousness as much as if it were in type on the page.
    Willa Cather (1873–1947)