AAPCS
More info
- Owner
- Arm
- Type
- Calling convention
- Spec
- ARM-software/abi-aa
The Procedure Call Standard for the Arm Architecture: which registers a function may trash and which it must hand back untouched.
Part of Arm's ABI family since the early 2000s, it is the reason objects built by GCC, Clang and Keil link together at all. The first four arguments travel in r0–r3, the result comes back in r0. A callee that touches r4–r11 must save them first, r12 is fair game, and the stack must be 8-byte aligned at every public call. The hard-float variant passes floating-point arguments in FPU registers; mix it with soft-float and the linker refuses, mercifully.
Embedded developers get a neat dividend. When a Cortex-M takes an exception, the hardware itself stacks r0–r3, r12, LR, PC and xPSR — precisely the registers AAPCS lets a function clobber. An interrupt handler can therefore be an ordinary C function, with no assembly prologue.