| |||
| Home > Compiler-specific Features > Instruction intrinsics > Named register variables | |||
The compiler enables you to access registers of an ARM architecture-based processor using named register variables. Named register variables are supported:
at file scope
at local scope, but not on a function parameter.
registertypevar-name__asm(reg);
Where:
typeis the type of the named register variable.
Any type of the same size as the register being named can be used in the declaration of a named register variable. The type can be a structure, but note that bitfield layout is sensitive to endianness.
var-nameis the name of the named register variable.
regis a character string denoting the name of a register on an ARM architecture-based processor.
Registers available for use with named register variables on ARM architecture-based processors are shown in Table 4.16.
Table 4.16. Named registers available on ARM architecture-based processors
| Register | Character string for __asm |
|---|---|
CPSR |
|
SPSR |
|
r0 to r12 | "r0" to "r12" |
r13 or sp | "r13" or "sp" |
r14 or lr | "r14" or "lr" |
r15 or pc | "r15" or "pc". |
On targets with a VFP, the registers of Table 4.17 are also available for use with named register variables.
Table 4.17. Named registers available on targets with a VFP
| Register | Character string for __asm |
|---|---|
FPSID | "fpsid" |
FPSCR | "fpscr" |
FPEXC | "fpexc" |
void foo(void)
{
register int foo __asm("r0");
}
In this example, foo is declared as a named
register variable for the register r0.
Named register variables in the Compiler User Guide.