Subject: Re: Can anyone help with NetBSD/Alpha asm code?
To: John Birrell <firstname.lastname@example.org>
From: Chris G Demetriou <Chris_G_Demetriou@BALVENIE.PDL.CS.CMU.EDU>
Date: 12/09/1995 00:20:01
>I found a reference in /usr/include/machine/asm.h to the LEAF() macro stating
>that it is not expecting functions to be called (so it doesn't set up a frame).
>I changed the code to ....
yup, that's the right observation to have made...
> NESTED(cerror, 0, 8, ra, 0, 0)
> br t0, 1f
> 1: SETGP(t0)
> lda sp, -8(sp)
> stq ra, 0(sp)
> mov v0, a0
> stl a0, 0(v0)
> ldiq v0, -1
> ldq ra, 0(sp)
> lda sp, 8(sp)
> so that the return address wasn't trashed by the call to __error and it
That's not quite correct, for two reasons:
(1) the Digital "Calling Standard for AXP Systems" (AA-PY8AB-TE,
really an OSF/1 book) indicates that the stack pointer should
always be 16-byte-aligned (page 3-12), and
(2) Since a0 can be overwritten by the called function, what you
really want to do is store s0 on the stack, move v0 to s0 (instead
of a0), use it, then at the end of the function restore s0.