On Thu, Sep 13, 2001 at 11:42:24PM +0200, Klaus Borchers wrote:
> On return, a assembler subroutine called from C must somehow set <pc> to the
> value passed in <lr>. Immediately after return, <lr> contains the adrs of the
> current instruction, which is of pretty limited use to the calling program.
>
> Apart from
> mov pc, lr ; return
>
> i could use
> stmdb sp!, {r4-r12, lr} ; entry
> ; destroy all regs except <pc> and <sp>
> ldmia sp!, {r4-r12, pc} ; return with <lr> destroyed
>
> Do I still have to restore <lr>, just in case some day a clever compiler might
> think of a way to use it ?
No, it's not any different from "mov pc,lr".
> After all, a cycle is a cycle, and a word is a word ...
>
> Does anybody know if there is an "official" definition of the Arm-Linux
> assembly language calling conventions ?
The official definition is called the "ARM Procedure Calling Standard"
(APCS). I don't know if it's available from the ARM web site, but IIRC
it's partly documented in the book "ARM System Architecture" by Steve
Furber.
The APCS basically boils down to:
- The first four function arguments are passed in registers r0-r3,
extra parameters are passed on the stack. Floating point arguments go
in the first four floating point registers.
- Parameters on the stack are pushed in reversed order (just like any C
implemention does).
- The return value of a function goes into r0.
I'm not sure if a function should save r1-r3 before calling a function,
or if the called function should do that.
Erik
--
J.A.K. (Erik) Mouw, Information and Communication Theory Group, Department
of Electrical Engineering, Faculty of Information Technology and Systems,
Delft University of Technology, PO BOX 5031, 2600 GA Delft, The Netherlands
Phone: +31-15-2783635 Fax: +31-15-2781843 Email: [EMAIL PROTECTED]
WWW: http://www-ict.its.tudelft.nl/~erik/
_______________________________________________
http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm
Please visit the above address for information on this list.