Calling Convention
Calling conventions in programming define how functions receive parameters from the caller and how they return values. Programming languages and architectures may use different calling conventions.
They define:
- Which registers are used to pass arguments.
- How the stack is used for additional arguments.
- How the return value is passed back to the caller.
- Who is responsible for cleaning up the stack (caller or callee).
Common calling conventions include:
cdecl
: Used in C where the caller cleans the stackstdcall
: Used in Windows API calls, where the callee cleans the stackfastcall
: Passes some arguments in registers for efficiencyx86-64 System V ABI
: Defines calling conventions for x86-64 architecture, including how parameters are passed in registers and on the stack.