#include <syscall.h>
#include <vax/psl.h>
#include <vax/mtpr.h>

	.data
	.comm	exitfp,4
	.text
	.globl	_usercall
_usercall:
	.word	0x800
	mfpr		$IPL,r0
	mtpr		$31,$IPL
	movl		fp,exitfp
	mtpr		r0,$IPL
	movl		4(ap),r11
	movl		8(ap),r10
	pushl		$PSL_PRVMOD+PSL_CURMOD
	pushab		callr11r10
	rei
callr11r10:
	pushl		r10
	calls		$1,1f
	pushl		$0
	pushl		$1
	movl		sp,ap
	chmk		$SYS_exit
1:	.word		0
	jmp		(r11)
	.globl	_doexit
	.align	2
_doexit:
	.word	0
	mtpr		$31,$IPL
	movl		exitfp,fp
	clrl		exitfp
	ret
	.globl	forced_exit
	.align	2
forced_exit:
	mtpr		$31,$IPL
	tstl		exitfp
	jeql		1f
	movab		_doexit+2,(sp)
	clrl		4(sp)
1:	rei
