	include	'exec/types.i'
	include	'exec/tasks.i'
	xref	_localf
	xref	_oldtraphandler
	xdef	_trapintercept
_trapintercept:
	movem.l	d0/a0,-(sp)	; need a data register
	move.l	8(sp),d0	; get trap number
	asl.l	#2,d0		; convert in array index
	lea	_localf,a0
	move.l	0(a0,d0.l),d0	; get alternate usermode vector
	beq.s _if00000
		cmp.l #-1,d0                                                                                                                    
		beq.s _if00001
			move.l	d0,14(sp)	; modify rte address
_if00001:
		movem.l	(sp)+,d0/a0	; restore d0/a0, why?
		addq.l	#4,sp		; remove trap #
		rte			; close eyes, plug ears
_if00000:
	movem.l	(sp)+,d0/a0	;restore d0 contents
	move.l	_oldtraphandler,-(sp)
	rts			; jump to it
	end
