Subject: Re: DEC/MIPS ABI and small structs?
To: Andrew Cagney <ac131313@cygnus.com>
From: Simon Burge <simonb@wasabisystems.com>
List: port-pmax
Date: 07/16/2001 08:41:34
Andrew Cagney wrote:

> > Andrew Cagney wrote:
> > 
> >> I'm trying to find a little history on the original ABI used by DEC on 
> >> the PMAX (little endian MIPS) machines.
> >> 
> >> I'm firstly wondering what the abi is correctly called.
> > 
> > COFF.
> 
> I was thinking of something like o32, n32, o64, ....

Those names are SGI names - Ultrix predates the 64-bit-isms.  It would
be closest to o32 though.

> >> Second, according to the ABI, how should small structs be passed vis:
> >> 
> >> struct c1 { char c; };
> >> void foo (struct c1 c1);
> > 
> > 
> > I don't have an ABI document, but both appear to be passed on the stack.
> > Here's the assembly output of the a simple C program (source included in
> > the asm- more assemblers should do this :-):
> 
> 
> I think it was was passed in A0, might need to look at the function to 
> see which value it uses.

Yes, $4 = a0, which is defined as the first argument.

> >  #   8	
> >  #   9		bar1(c1);
> > 	lbu	$14, c1
> > 	sb	$14, 0($sp)
> 
> 
> pick up c1, store it on the stack at 0($sp).

Storing a0 on the stack is redundant, and would probably be left out if
I used any of the -O flags.

> > 	lw	$4, 0($sp)
> 
> move it in to A0 as a word.  This means that c1 is sitting in the least 
> significant byte of A0 (and the other bytes contain garbage?).

Yes.

> > 	.livereg	0x0800000E,0x00000000
> > 	jal	bar1
> > 	.loc	2 10
> >  #  10		bar2(foo);
> > 	lbu	$15, foo
> > 	sb	$15, 0($sp)
> > 	lw	$4, 0($sp)
> > 	.livereg	0x0800000E,0x00000000
> > 	jal	bar2
> > 	.loc	2 11
> >  #  11	}
> > 	move	$2, $0
> 
> The reason for asking is that I'm looking at a LE o32 bug involving 
> small structs and register alignment.  To the best of my knowledge 
> nothing ever specified this formally.

From the Ultrix end not surprising, unfortunately, given the age of the
software we are talking about...  o32 should define the behaviour though
(doco somewhere on www.sgi.com - I should have a copy locally if you
can't find it).

Simon.
--
Simon Burge                            <simonb@wasabisystems.com>
NetBSD CDs, Support and Service:    http://www.wasabisystems.com/