NAME INTERRUPTHANDLER

$include (reg.inc)

	EXTRN	RQGETLEVEL:NEAR
	EXTRN	RQSIGNALINTERRUPT:NEAR


%IF (%RMX EQ 1) THEN (DGROUP GROUP DATA) FI

%IF (%RMX EQ 1) THEN (DATA SEGMENT    PUBLIC)
				ELSE (DATA SEGMENT RW PUBLIC) FI
DATA ENDS

%IF (%RMX EQ 1) THEN (CGROUP GROUP CODE) FI

%IF (%RMX EQ 1) THEN (CODE SEGMENT    PUBLIC)
				ELSE (CODE SEGMENT ER PUBLIC) FI

%IF (%RMX EQ 1) THEN (ASSUME DS:DGROUP
                      ASSUME CS:CGROUP)
                ELSE (ASSUME DS:DATA)   FI

	PUBLIC INTHANDLER

	INTHANDLER PROC NEAR

%IF	(%RMX EQ 1)	THEN	(
		push	ax
		push	cx
		push	dx
		push	bx
							; skip sp
		push	bp
		push	si
		push	di
)	ELSE	(
		%pusha				; save the processor state
)	FI
		push	ds
		push	es
%IF (%RMX EQ 3) THEN (
		push	fs
		push	gs
) FI

		push	%cx			; allocate room for status
		mov		%bp, %sp	; ss:(e)bp	is status$pointer

		push	ss			; ax = rq$get$level (status$ptr)
		push	%bp
		call	rqgetlevel

		push	%ax			; CALL rq$signal$interrupt (ax,status$ptr)
		push	ss
		push	%bp
		call	rqsignalinterrupt

		pop		%cx			; pop status

							; restore processor state
%IF (%RMX EQ 3) THEN (
		pop		fs
		pop		gs
) FI
		pop		es
		pop		ds

%IF	(%RMX EQ 1)	THEN	(
		pop	di
		pop	si
		pop	bp
							; skip sp
		pop	bx
		pop	dx
		pop	cx
		pop	ax
)	ELSE	(
		%popa
)	FI

		%iret				; return from interrupt

	INTHANDLER ENDP

CODE ENDS

END
