Hello! In one of my applications i need to copy value of a register in a C variable. Because I work with a LM3S811 I cannot use inline assembler (because it is not permitted when generating Thumb code), and the only solution (I guess) is to use " Named register variables". The problem is that in any situation returned value is the value of register r0.
int reg6(void) { register int reg __asm("r6"); return reg; }
For example this function return the value of register r0. Somebody can tell my why? There is another solution?
use the Embedded in-line assembler in Thumb2 mode instead. See:
http://www.keil.com/support/man/docs/armcc/armcc_caciddae.htm
Thank you for your help! I solved the problem with a function like this:
__asm int reg6(void)
{
MOV R0, R6 ;
BX LR ;
}
that returns the value from R0.