This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Documentation


> GCC on ARM follows the ARM Procedure Call Standard (APCS), which
> basically boils down to:
> 
> - First four arguments to a function go into r0 - r3. Extra arguments
>   are pushed onto the stack in reverse order (somebody please correct
>   me if I'm wrong).

Pretty much, unless you are using a floating point variant that passes 
arguments in f0-f3; but gcc doesn't support these.

Stack is full-descending -- that is the stack pointer register points to 
the last allocated element on the stack and the next free one is 4 bytes 
below that.  Arguments from C functions are passed with the last argument 
on the list at the highest address on the stack, except as noted above: 
the first four words are passed in r0 through r3.

> - The return value of the function goes into r0.
> 
> Calling a C function from assembly is just:
> 
> 	bl	c_function
> 
> Returning from an assembly function to a C function is:

Pretty much, unless you want conforming stack frames; but this is too 
complex to describe here -- you need to read one of the documents cited.

> 
> 	mov	pc,lr
> 
> >   Is there such a documentation?
> 
> The APCS is described in "ARM Architecture Reference Manual" by Dave
> Jagger, or in "ARM System Architecture" by Steve Furber.
> 
> For code examples, check out the Linux kernel source, or have a look at
> blob, a bootloader I wrote for StrongARM systems:
> 
>   http://www.lart.tudelft.nl/lartware/blob/
> 
> 

Richard.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]