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 07:56:16
Andrew Cagney wrote:

> Hello,
> 
> 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.

> 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 :-):

	.verstamp	3 0
	.extern	c1 1
	.extern	foo 1
	.text	
	.align	2
	.file	2 "foo.c"
	.globl	main
	.loc	2 5
 #   1	struct c1 { char c; };
 #   2	struct foo { struct c1 c1 };
 #   3	
 #   4	main()
 #   5	{
	.ent	main 2
main:
	.option	O1
	subu	$sp, 32
	sw	$31, 28($sp)
	.mask	0x80000000, -4
	.frame	$sp, 32, $31
	.loc	2 5
	.loc	2 9
 #   6		extern struct c1 c1;
 #   7		extern struct foo foo;
 #   8	
 #   9		bar1(c1);
	lbu	$14, c1
	sb	$14, 0($sp)
	lw	$4, 0($sp)
	.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
	.livereg	0x2000FF0E,0x00000FFF
	lw	$31, 28($sp)
	addu	$sp, 32
	j	$31
	.end	main

Making the variables automatic just changes the "lbu" to references the
stack instead of external storage.

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