perm filename SAITGI.FAI[S,AIL]1 blob sn#102556 filedate 1974-05-22 generic text, type T, neo UTF8
COMPIL(TGI,<TRIGINI>,<JOBTPC,JOBAPR,OVPCWD>
	,<TRIG ROUTINE INTERRUPT HANDLER>,<.RSEED>,INHIBIT)
BEGIN UNDER
OV←←400000
FOV←←40000
ZDV←←40
FXU←←100
IFE ALWAYS,<		;MORE EXTERNALS, CONDITIONALLY ASSEMBLED.
EXPO <
	EXTERNAL INTMAP,ENABLE
>;EXPO
	EXTERNAL APRACS,GOGTAB
NOEXPO <
	EXTERNAL INTTBL
>;NOEXPO
>
TRGIN:	0
	XWD 000000,TRGIQ	;SPECIAL INIT IN FIRST SYS PHASE
	0			;ONLY 1 ROUTINE TO CALL.
	LINK %INLNK,TRGIN
TRGIQ:	PUSH	P,[0]		;NO ROUTINE.
	PUSHJ	P,TRIGINI	;INITIALIZATION
	POPJ	P,		;RETURN.
HERE(TRIGINIT)
	JFCL	17,.+1		;CLEAR NUMERIC FLAGS.
EXPO <
	PUSH	P,[=32]		;ARM FOR FLOATING OVERFLOWS
	PUSH	P,[FLTOV]	;ROUTINE.
	PUSH	P,[0]		;NOT DEFERRED
	PUSHJ	P,INTMAP	;SET IT ALL UP.
	PUSH	P,[=32]
	PUSHJ	P,ENABLE	;AND ENABLE IT.
	PUSH	P,[=29]		;ARM FOR regular, too.
	PUSH	P,[FLTOV]	;ROUTINE.
	PUSH	P,[0]		;NOT DEFERRED
	PUSHJ	P,INTMAP	;SET IT ALL UP.
	PUSH	P,[=29]
	PUSHJ	P,ENABLE	;AND ENABLE IT.
>;EXPO
NOEXPO <
	MOVE	USER,GOGTAB	;LOOK TO SEE IF SET UP FOR
	SKIPE	DISPAT(USER)	;INTERRUPTS YET; IF NOT,
	 JRST	 .+3
	PUSH	P,[=128]	;ENABLE THEM NOW.
	PUSHJ	P,INTTBL	;...
	MOVEI	A,10		;TURN ON ALL OVERFLOWS.
	CALL6	(A,APRENB)
	MOVEI	A,FLTOV
	MOVEM	A,JOBAPR	;...
>;NOEXPO
	POP	P,1		;RETURN ADDRESS
	POP	P,OVROUT	;USER'S ROUTINE.
	JRST	(1)		;RETURN.
FLTOV:				;HERE WHEN AN INTERRUPT HAPPENS
NOEXPO <
	MOVEM	1,SAVP		;GET AN ACCUMULATOR.
>;NOEXPO
	MOVE	1,JOBTPC	;COME HERE WITH AC'S SET UP.
	MOVEM	1,OVPCWD	;SAVE FOR LOOKING.
	TLNN	1,FXU		;WHAT KIND OF INTERRUPT
	 JRST	 NOFX		;NOT FLOATING UNDERFLOW.
	MOVE	1,-1(1)		;GET OPCODE.
	TLNN	1,40000		;CHECK FOR FSC
	TLZ	1,2000
	DPB	1,[POINT 29,SEW,35] ;CHANGE INSTRUCTION
EXPO <				;GET BACK INTRRUPT AC'S
	PUSH	P,16
	MOVEM	P,SAVP
	MOVE	17,[XWD APRACS,0]
	BLT	17,17		;RESTORE AC'S
>;EXPO
NOEXPO <
	MOVE	1,SAVP		;GET BACK SAVED AC.
>;NOEXPO
SEW:	SETZ	0,0		;MODIFIED!!!!
NOEXPO <
	MOVEM	1,SAVP		;SAVE AGAIN.
>;NOEXPO
EXPO <
	MOVEM	17,APRACS+17
	MOVEI	17,APRACS
	BLT	17,APRACS+16
	MOVE	P,SAVP
	POP	P,16
>;EXPO
NOFX:	HLRZ	1,@JOBTPC	;CHECK IF NEXT INSTR IS JFCL
	ANDCMI	1,777
	CAIE	1,(<JFCL>)	;CHECK.
	 JRST	 USRRT		;GO TO USER ROUTINE.
	HRRZ	1,@JOBTPC	;GET EFFECTIVE ADDRESS
	HRRM	1,JOBTPC
RET:	MOVSI	1,OV+FOV+FXU+ZDV
	ANDCAM	1,JOBTPC
NOEXPO <
	MOVE	1,SAVP		;RESTORE THE ACCUMULATOR
	JRST	2,@JOBTPC
>;NOEXPO
EXPO <
	POPJ	P,		;RETURN TO INTERRUPT HANDLER.
>;EXPO
USRRT:	SKIPN	OVROUT
	 JRST	 RET		;NO USER ROUTINE.
NOEXPO <
	MOVEI	1,APRACS	;SAVE AC'S HERE FOR USER TO SEE
	BLT	1,APRACS+17
	MOVE	1,SAVP
	MOVEM	1,APRACS+1
	MOVE	USER,GOGTAB
	MOVE	P,IPDP(USER)
	MOVE	SP,ISPDP(USER)
>;NOEXPO
	PUSHJ	P,@OVROUT	;CALL USER'S ROUTINE.
NOEXPO <
	MOVE	1,APRACS+1	;RESTORE AC'S
	MOVEM	1,SAVP
	MOVSI	1,APRACS
	BLT	1,17		;AND RESTORE ALL OTHERS
>;NOEXPO
	JRST	RET
SAVP:	0
OVROUT:	0
BEND UNDER
.RSEED:	=524287
ENDCOM (TGI)