This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: MIPS asm prologue macros


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]