4.4.6 Variables in Registers

You can define a variable and associate it with a specified register; however, it is generally recommended that register allocation be left to the compiler to achieve optimal results and to avoid code failure.

Register variables are defined by using the register keyword and indicating the desired register, as in the following example:

register int input asm(“r12”);

A valid AVR device register name must be quoted as an argument to the asm(). Such a definition can be placed inside or outside a function, but you cannot made the variable static. Support for local register variables is to limited to specifying registers for input and output operands when calling extended in-line assembly.

The compiler reserves the allocated register for the duration of the current compilation unit, but library routines may clobber the register allocated, thus it is recommended that you allocate a register that is normally saved and restored by function calls (a call-saved register, described in 4.6 Register Usage).

You cannot take the address of a register variable.