SLAU132Y September 2004 – June 2021
Strict conventions associate specific registers with specific operations in the C/C++ environment. If you plan to interface an assembly language routine to a C/C++ program, you must understand and follow these register conventions.
The register conventions dictate how the compiler uses registers and how values are preserved across function calls. Table 7-3 shows the types of registers affected by these conventions. Table 7-4 summarizes how the compiler uses registers and whether their values are preserved across calls. For information about how values are preserved across calls, see Section 7.5.
Register Type | Description |
---|---|
Argument register | Passes arguments during a function call |
Return register | Holds the return value from a function call |
Expression register | Holds a value |
Argument pointer | Used as a base value from which a function's parameters (incoming arguments) are accessed |
Stack pointer | Holds the address of the top of the software stack |
Program counter | Contains the current address of code being executed |
Register | Alias | Usage | Preserved by Function(1) |
---|---|---|---|
R0 | PC | Program counter | N/A |
R1 | SP | Stack pointer | N/A(2) |
R2 | SR | Status register | N/A |
R3 | Constant generator | N/A | |
R4-R10 | Expression register | Child | |
R11 | Expression register | Parent | |
R12 | Expression register, argument pointer, return register | Parent | |
R13 | Expression register, argument pointer, return register | Parent | |
R14 | Expression register, argument pointer, return register | Parent | |
R15 | Expression register, argument pointer, return register | Parent |