MIPS asm prologue macros
Thiemo Seufer
ths@networkno.de
Mon Jun 2 09:02:00 GMT 2008
Masao Uebayashi wrote:
> Hi!
>
> The "MIPSpro(TM) N32 ABI Handbook" shows an attached code (slightly
> cleaned up by me) to explain how to write assembly for ABIs
> ({O,N}{32,64}). The start of a sample assembly function looks like:
The O64 ABI was never standardized and is limited to some embedded
systems, it is not covered by the N32 ABI Handbook.
> NESTED(asmfunc, FRAMESZ, ra)
> move t0, gp # save entering gp
> # SIM_ABI64 has gp callee save
> # no harm for SIM_ABI32
This part looks not quite correct. t0 may get clobbered on a subroutine
call, so it isn't generally usable for saved values ...
> SETUP_GPX(t8)
> PTR_SUBU sp, FRAMESZ
> SETUP_GP64(GPOFF, asmfunc)
> SAVE_GP(GPOFF)
... which is the reason why gp is saved on the stack by SAVE_GP or
SETUP_GP64.
> :
>
> Questions:
>
> - I'm not sure where / when the t0 value is restored into GP.
>
> - Has anyone invented any macros which can handle all the four ABI
> cases cleanly?
Glibc has the necessary macros for Linux/MIPS (in <sys/asm.h>).
Thiemo
More information about the Binutils
mailing list