Re: Register Usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



John Farmer <news02@xxxxxxxxxxx> 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
was configured.

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.

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux