Ian Lance Taylor
Tue Apr 28 16:50:00 GMT 2009
John Farmer <email@example.com> writes:
> Register R12 is initialised in my startup code to the same value as the SP
> (R13) but it never appears to be used for anything. Whats the purpose of
> this register?
> I have looked at the ARM and THUMB procedure call standard (briefly) and it
> looks as though R7 is the Thumb-state Work register or variable register.
> However, looking at the assembly code produced for functions it is clearly
> being used as the frame pointer. Why is there a difference?
> Is there a defining text somewhere that details GCC register usage when
> compiling for a Cortex-M3 chip?
gcc follows the various ARM ABIs, which are documented on arm.com. I
don't know which particular ABI you are using--it depends upon how gcc
r12 is known as ip. gcc will use it as a temporary general purpose
register. It is also used in the prologue to set up the stack frame; I
think this use may be mandated by the ABI, but I'm not sure.
r7 is used as the frame pointer in Thumb code because r12 is not
accessible for general use.
By the way, make sure you are looking at optimized code.
More information about the Gcc-help