SYS_PRINT_INT=1
SYS_PRINT_FLOAT=2
SYS_PRINT_DOUBLE=3
SYS_PRINT_STR=4
SYS_READ_INT=5
SYS_READ_FLOAT=6
SYS_READ_DOUBLE=7
SYS_READ_STR=8
SYS_SBRK=9
SYS_EXIT=10

MAIN_FSZ=8
MAIN_RA=0

			.data
message:		.ascii	"This program demonstrates how to pass\n"
			.ascii	"more than 4 arguments to a function.\n"
			.ascii	"The first 4 are passed in the $a registers\n"
			.asciiz	"and the rest are on the stack.\n"

arg:			.asciiz	"This is arg #"
sp:			.asciiz " "
nl:			.asciiz	"\n"

done_msg:		.ascii	"There, we're all done!\n"
			.asciiz	"Bye now.\n"

			.text
main:			subu	$sp,$sp,MAIN_FSZ
			sw	$fp,4($sp)
			addu	$fp,$sp,MAIN_FSZ
			sw	$ra,MAIN_RA($fp)

			li	$v0,SYS_PRINT_STR
			la	$a0,message
			syscall

			subu	$sp,$sp,12	# args 5 to 7
			li	$t0,6
			sw	$t0,12($sp)
			li	$t0,5
			sw	$t0,8($sp)
			li	$t0,4
			sw	$t0,4($sp)
			li	$a3,3
			li	$a2,2
			li	$a1,1
			li	$a0,0

			jal	print_args

			addu	$sp,$sp,12

			la	$a0,done_msg
			li	$v0,SYS_PRINT_STR
			syscall

			lw	$ra,MAIN_RA($fp)
			lw	$fp,4($sp)
			addu	$sp,$sp,MAIN_FSZ
			jr	$ra

print_args:		# LEAF
			move	$t0,$a0
			la	$a0,arg
			li	$v0,SYS_PRINT_STR
			syscall
			li	$a0,7
			li	$v0,SYS_PRINT_INT
			syscall
			la	$a0,sp
			li	$v0,SYS_PRINT_STR
			syscall
			lw	$a0,12($sp)
			li	$v0,SYS_PRINT_INT
			syscall
			la	$a0,nl
			li	$v0,SYS_PRINT_STR
			syscall

			la	$a0,arg
			li	$v0,SYS_PRINT_STR
			syscall
			li	$a0,6
			li	$v0,SYS_PRINT_INT
			syscall
			la	$a0,sp
			li	$v0,SYS_PRINT_STR
			syscall
			lw	$a0,8($sp)
			li	$v0,SYS_PRINT_INT
			syscall
			la	$a0,nl
			li	$v0,SYS_PRINT_STR
			syscall

			la	$a0,arg
			li	$v0,SYS_PRINT_STR
			syscall
			li	$a0,5
			li	$v0,SYS_PRINT_INT
			syscall
			la	$a0,sp
			li	$v0,SYS_PRINT_STR
			syscall
			lw	$a0,4($sp)
			li	$v0,SYS_PRINT_INT
			syscall
			la	$a0,nl
			li	$v0,SYS_PRINT_STR
			syscall

			la	$a0,arg
			li	$v0,SYS_PRINT_STR
			syscall
			li	$a0,4
			li	$v0,SYS_PRINT_INT
			syscall
			la	$a0,sp
			li	$v0,SYS_PRINT_STR
			syscall
			move	$a0,$a3
			li	$v0,SYS_PRINT_INT
			syscall
			la	$a0,nl
			li	$v0,SYS_PRINT_STR
			syscall

			la	$a0,arg
			li	$v0,SYS_PRINT_STR
			syscall
			li	$a0,3
			li	$v0,SYS_PRINT_INT
			syscall
			la	$a0,sp
			li	$v0,SYS_PRINT_STR
			syscall
			move	$a0,$a2
			li	$v0,SYS_PRINT_INT
			syscall
			la	$a0,nl
			li	$v0,SYS_PRINT_STR
			syscall

			la	$a0,arg
			li	$v0,SYS_PRINT_STR
			syscall
			li	$a0,2
			li	$v0,SYS_PRINT_INT
			syscall
			la	$a0,sp
			li	$v0,SYS_PRINT_STR
			syscall
			move	$a0,$a1
			li	$v0,SYS_PRINT_INT
			syscall
			la	$a0,nl
			li	$v0,SYS_PRINT_STR
			syscall

			la	$a0,arg
			li	$v0,SYS_PRINT_STR
			syscall
			li	$a0,1
			li	$v0,SYS_PRINT_INT
			syscall
			la	$a0,sp
			li	$v0,SYS_PRINT_STR
			syscall
			move	$a0,$t0
			li	$v0,SYS_PRINT_INT
			syscall
			la	$a0,nl
			li	$v0,SYS_PRINT_STR
			syscall

			jr	$ra
