Placing auto variables in a specific register
In this section:
If you need to place a local variable in a specific register, you can use this construct:
registertypevarasm("reg") [=init];
Typically, these variables are used in inline assembler statements.
Alternatively, you can use the @ operator and the #pragma location directive like this: #pragma location=r9 or @r9, see Controlling data and function placement in memory. Note that the compiler requires that the register is free to be used throughout the lifetime of the variable.
For example:
int test(void)
{
register int myVar asm("r10");
asm volatile("// do something with %0" : "=r"(myVar));
return myVar;
}