Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: Assembly call in C

2006-05-17 by derbaier

--- In lpc2000@yahoogroups.com, "Woolsey Matt" <matt.woolsey@...> wrote:
>
> >
> >vaneenbergen schrieb:
> >
> >> in gcc (i use rowley) the first 4 arguments are in R0 - R3, the rest 
> >> will be put on stack (so best keep everything withing 4 arguments). 
> >> the return will be in R0.
> >
> >This is the (T)APCS standard by ARM. AFAIK all compilers for ARM are
> >doing like this.
> >
> >-- 
> >42Bastian
> >
> 
> 
> Keil compiler for ARM does not use APCS.
>

If you keep things simple CARM seems to follow APCS close enough.

From CARM Compiler User's Guide 
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
Function Parameters
C and C++ functions pass up to four parameters in registers R0-R3. The
first parameter is passed in register R0. Parameters that cannot fit
into registers are passed on the stack and are accessed using
[SP+#displacement] instructions.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
A single function return value is returned in R0, so for pointers or
32 bit integers or smaller, CARM follows APCS close enough. Perhaps it
deviates for more complex variables???

--Dave

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.