This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Documentation
- To: Erik Mouw <J dot A dot K dot Mouw at ITS dot TUDelft dot NL>
- Subject: Re: Documentation
- From: Richard Earnshaw <rearnsha at arm dot com>
- Date: Wed, 29 Nov 2000 17:20:23 +0000
- Cc: Rafael Rodríguez Velilla <rrv at tid dot es>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Cc: rearnsha at arm dot com
- Organization: ARM Ltd.
- Reply-To: rearnsha at arm dot com
> 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.