 # MIPSASM.s zilla 17apr  working version!
 # mod 
 # 23apr return float as well as double
 #
 # If float (not double) stops working, be sure code is compiled
 # with ansi or -prototypes.
 #
 #  double FA_d1,FA_d2;
 #  int FA_reg[4];
 #  int FA_stk[12];
	.verstamp	2 40

	.comm	FA_d1 8
	.comm	FA_d2 8
	.comm	FA_reg 16
	.comm	FA_stk 48	# 4*FA_MAX
	.comm	FA_drtn 8
	.comm	FA_frtn 4
	.comm	FA_irtn 4

	.text	
	.align	2
	.file	2 "FORMIPS.s"
	.globl	ZLforcall2

	.ent	ZLforcall2 2
ZLforcall2:
	.option	O2
	subu	$sp, 56
	sw	$31, 52($sp)
	.mask	0x80000000, -4
	.frame	$sp, 56, $31
	.loc 2 1

	move $10, $4		# save arg1=func in $10

 #	  FA_drtn = (*func)(FA_d1,FA_reg[2],FA_reg[3],
 #	      FA_stk[4],FA_stk[5],FA_stk[6],FA_stk[7],FA_stk[8],FA_stk[9],
 #	                    FA_stk[10],FA_stk[11]);
	.loc 2 2

	l.d	$f12, FA_d1	# leading 2 double args
	l.d	$f14, FA_d2
 #	.loc 2 3

	lw	$4, FA_reg	# first 4 args in registers
	lw	$5, FA_reg+4
	lw	$6, FA_reg+8
	lw	$7, FA_reg+12
 #	.loc 2 4

	lw	$14, FA_stk+16	# remaining args on stack
	sw	$14, 16($sp)
	lw	$14, FA_stk+20
	sw	$14, 20($sp)
	lw	$14, FA_stk+24
	sw	$14, 24($sp)
	lw	$14, FA_stk+28
	sw	$14, 28($sp)
 #	.loc 2 5
	lw	$14 FA_stk+32
	sw	$14, 32($sp)
	lw	$14, FA_stk+36
	sw	$14, 36($sp)
	lw	$14, FA_stk+40
	sw	$14, 40($sp)
	lw	$14, FA_stk+44
	sw	$14, 44($sp)
 #	.loc 2 6

	.livereg	0x0300000E,0x000C0000
	jal	$10
	sw 	$2, FA_irtn		# returned int in $2
	s.d 	$f0, FA_drtn		# returned dbl in $f0
	s.s 	$f0, FA_frtn		# returned flt in $f0

	.livereg	0x2000FF0E,0x00000FFF
	lw	$31, 52($sp)
	addu	$sp, 56
	j	$31
	.end	ZLforcall2
