4.7.49. 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:


register type var-name __asm(reg);



is 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.


is the name of the named register variable.


is 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

RegisterCharacter string for __asm

"cpsr" or "apsr"



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

RegisterCharacter 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.

See also

Copyright © 2007, 2010 ARM Limited. All rights reserved.ARM DUI 0348A