Hallo Erik,
thank you very much for your answer.
> > 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).
It is available from ARM-Limited's web-site at :
http://www.arm.com/armwww.ns4/img/12-Technical+Specs-ARM+Thumb+Procedure+Call+Standard+PDF/$File/ATPCSA05.pdf?OpenElement
I just looked it up.
> 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.
- r0-r3 may be destroyed by called function (unless r0 is return result)
- r4..r11 and sp (r13) need to be preserved
- r12 (ip) may also be destroyed. "ip" stands for
intra-procedure-call-scratch-register, and I understand it such that you may
use it as a scratchpad *between* procedure calls, but when you call a
procedure, it may be destroyed by that procedure - r14(lr) specifically
needs not be preserved
For a lengthy routine compiled without -fomit-frame-pointer, gcc
(2.95.2) generates the following code:
entry:
mov r12, sp ; R12 is used to save SP and therefore destroyed
stmdb sp!, {r4, r5, r6, r7, r8, r9, r10, r11, r12, lr, pc}
sub r11, r12, #4 ; r11 is used as frame-pointer throughout the
routine (and thus lost)
exit:
ldmdb r11, {r4, r5, r6, r7, r8, r9, r10, r11, sp, pc} ; r0..r3,
r12 and r14(lr) are not restored
With -fomit-frame-pointer, gcc generates the following code:
entry:
stmdb sp!, {r4, r5, r6, r7, r8, r9, r10, lr} ; r11 and r12 are not
saved
....... ; r11 is *never* used !?!, all other regs except sp are
destroyed
exit:
ldmia sp!, {r4, r5, r6, r7, r8, r9, r10, pc} ; r11, r12, and r14 are
not restored
So, if gcc promises to always and forever adhere to the APCS, it seems safe not
to save both R14 and R12. It seems a pity, though, that R11 doesn't seem to get
used, since a register less available in a routine is much more of a performance
impact than an extra push or pop on entry.
Unless you plan to be interrupted by a debugger, I think it should be safe to
used r11 in your assembler routine if you save it.
Does anybody know what R11 is used for if -fomit-frame-pointer is specified ?
Regards,
Klaus
--
Mobotix AG
Klaus Borchers
Luxemburgerstr. 6
D-67657 Kaiserslautern
Germany
Tel: +49 (631) 3033141
Fax: +49 (631) 3033190
E-Mail: [EMAIL PROTECTED]
_______________________________________________
http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm
Please visit the above address for information on this list.