
function gen_call {
	typeset name="$1"
	typeset kcnum="$2"
	typeset nparms="$3"
	typeset rent="$4"
	typeset neglist="$5"

	print		'# DO NOT EDIT THIS FILE, IT IS GENERATED BY "mkkercalls"'
	print		".text"
	print		".set noreorder"
	print		".ifdef __PIC__"
	print		".ifdef __MIPS_ABICALLS__"
	print		"  .abicalls"
	print		" .else"
	print		"  .qnxpiccalls"
	print		".endif"
	print		".endif"
	print		".global ${name}"
	print		"${name}:"
	let	"i = ${nparms}"
	while [ $i -gt 4 ]; do
		let	"reg = $i - 4 + 7"
		let "off = ($i - 4)	* 4 + 12"
		print	"lw	\$${reg},${off}(\$29)"
		let "i = $i - 1"
	done
	print		"addiu	\$2,\$0,${kcnum}"
	for neg in $neglist; do
		let "reg = $neg + 3"
		print	"subu	\$${reg},\$0,\$${reg}"
	done
	print		'syscall'
	print		'jr $31'
	print		' nop'
	case ${rent} in
	NONE)
		print	'.ifdef __PIC__'
		print	".ifdef __MIPS_ABICALLS__"
		print	"  addi \$25,.L_err_${name}-${name}"
		print	'  move	$8,$31'
		print	'  move $9,$28'
		print	".L_err_${name}:"
		print	'  .cpload $25'
		print	'  la	$25,__ker_err'
		print	'  move $31,$8'
		print	'  move $28,$9'
		print	'  jr	$25'
		print	'.else'
		print	'  move	$8,$31'
		print	'  move $9,$23'
		print	'  .cpload $25'
		print	'  la	$25,__ker_err'
		print	'  move $31,$8'
		print	'  move $23,$9'
		print	'  jr	$25'
		print	'.endif'
		print	'.else'
		print	'  j	 __ker_err'
		print	'.endif'
		print	' move	$4,$2'
		;;
	NORMAL)
		print	'jr		$31'
		print	' nop'
		;;
	NEGATIVE)
		print	'subu	$2,$0,$2'
		print	'jr		$31'
		print	' nop'
		;;
	esac
	print		".type ${name},@function"
	print		".size ${name},.-${name}"
}
