This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: MIPS asm prologue macros
- From: Thiemo Seufer <ths at networkno dot de>
- To: Masao Uebayashi <uebayasi at gmail dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Mon, 2 Jun 2008 10:01:43 +0100
- Subject: Re: MIPS asm prologue macros
- References: <20080602.170218.136354108.uebayasi@gmail.com>
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