What is an ABI?
An Application Binary Interface (ABI) is a hardware-level interface used between software executables.ABIs are similar to APIs, in that an API is a source code level interface between source code,
but while APIs are high-level and hardware indepedent. ABIs are low-level and hardware dependent.
ABI's determine:
- How to pass arguments to a function
- How to pass a function's return
- What register's must be preserved and what registers can be be clobbered (over-written)
- How data is organized in memory
- How system calls are performed
We will reference the The Proceedure Call Standard for ARM32 from the ARM32 ABI to write our next program.
This document defines the following calling convention:
- The registers r4-r8, r10, and r11 are used to hold the values of local variables
- Registers r12-r15 have special roles: IP, SP, LR, and PC
- A subroutine must preserve the contents of the registers r4-r8, r10, r11 and SP
- The first four registers r0-r3 (a1-a4) are used to pass argument values into a subroutine and to return values
- r0-r3 may also be used to hold intermediate values within a routine (but, in general, only between subroutine calls)
| Register | Synonym | Special | Role in the procedure call standard |
|---|---|---|---|
| r15 | PC | program counter | |
| r14 | LR | link register/scratch register | |
| r13 | SP | stack pointer | |
| r12 | IP | new-sb in inter-link-unit calls/scratch register | |
| r11 | v8 | FP | frame pointer or variable register |
| r10 | v7 | register variable | |
| r9 | v6 | SB TR |
static base/register variable/platform register This register is defined by the platform standard |
| r8 | v5 | register variable | |
| r7 | v4 | register variable | |
| r6 | v3 | register variable | |
| r5 | v2 | register variable | |
| r4 | v1 | register variable | |
| r3 | a4 | argument 4/scratch register/result | |
| r2 | a3 | argument 3/scratch register/result | |
| r1 | a2 | argument 2/scratch register/result | |
| r0 | a1 | argument 1/scratch register/result |