Some registers are protected, some are free game. For details, see the ABI (Application Binary Interface) page 3-14 and EABI (Embedded Application Binary Interface) specifications: http://www.esofta.com/softspecs.html
gvb At 04:33 PM 9/25/00 -0400, Zhaobin Zhu wrote: >Hi, > >This is a newbie question regarding (PowerPC) calling a C routine >within a .S >file: > >Let me take an example: > >in arch/ppc/kernel/head.S, >... > mr r3,r31 > mr r4,r30 > mr r5,r29 > mr r6,r28 > mr r7,r27 > bl identify_machine >... >The code calls rountine identify_machine(..) in setup.c. > >Questions: > > The identify_machine(..) in setup.c will certainly use some of the > registers >(r0-r31). > Will the compiler protect the registers used in the routine (for > example > push them into stack before entering the routine and pop them out > after exiting the routine ) ? > > If yes, how the compiler does the protection ? Will it simply save > all the >regs > into stack before entering routine and restore them after > returning from the > > routine (except R3 wiich may be used as a pointer to some returned > value). > > If compiler does no reg protection, then there is no gurantee that the >register set > will be the same before and after calling a C routine. It's the > calling >code's > responsibility to make sure some important regs will not be > altered after >return > from a C routine. > >Thanks, > >-- > Zhaobin Zhu > zzhu at emc.com > > ** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/