perm filename SAITGI.FAI[S,AIL]4 blob sn#181925 filedate 1975-10-22 generic text, type T, neo UTF8
SEARCH HDRFIL
COMPIL(TGI,<TRIGINI>,<JOBTPC,JOBAPR,OVPCWD>
	,<TRIG ROUTINE INTERRUPT HANDLER>,<.RSEED>,INHIBIT)
BEGIN UNDER
NOTENX <;DEC VERSION OF UNDER/OVER FLOW CODE
OV←←400000
CRY0←←200000
CRY1←←100000
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,100		;TURN ON FLOATING 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.
	LDB	1,[POINT 4,@JOBTPC,12]
	MOVE	1,INTCOD(1)	; PICK UP MAPPING BETWN JFCL AC AND FLAGS
	TDNN	1,JOBTPC	; ARE ANY OF THEM ON?
	 JRST	 USRRT		; NO, JFCL IS NOT RELEVANT HERE
	TLO	1,OV!FXU	; ALWAYS CLEAR OVERFLOW FLAG
	ANDCAM	1,JOBTPC	; CLEAR ONLY THE APPROPRIATE BITS
	HRRZ	1,@JOBTPC	;GET EFFECTIVE ADDRESS
	HRRM	1,JOBTPC
	JRST	XIT
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
RET:	MOVSI	1,OV+FOV+FXU+ZDV
	ANDCAM	1,JOBTPC
XIT:
NOEXPO <
	MOVE	1,SAVP		;RESTORE THE ACCUMULATOR
	JRST	2,@JOBTPC
>;NOEXPO
EXPO <
	POPJ	P,		;RETURN TO INTERRUPT HANDLER.
>;EXPO
SAVP:	0
OVROUT:	0
>;NOTENX
INTCOD:	0		; THIS TABLE IS INDEXED BY THE AC FIELD OF A JFCL
	OV,,0		; IT GIVES THE CORRESPONDENCE BETWEEN SUCH AND
	CRY0,,0		;    THE ACTUAL FLAG BITS IN THE LH OF THE PC
	CRY0!OV,,0	;    SO THAT WE CAN EASILY COMPARE THE FLAGS
	CRY1,,0		;    WITH THE BITS THAT ARE TESTED IN THE JFCL
	CRY1!OV,,0	;    (THUS SIMULATING THE HARDWARE!)
	CRY1!CRY0,,0
	CRY1!CRY0!OV,,0
	FOV,,0
	FOV!OV,,0
	FOV!CRY0,,0
	FOV!CRY0!OV,,0
	FOV!CRY1,,0
	FOV!CRY1!OV,,0
	FOV!CRY1!CRY0,,0
	FOV!CRY1!CRY0!OV,,0
TENX<;TENEX VERSION OF UNDER/OVER FLOW
OV←←400000
FOV←←40000
ZDV←←40
FXU←←100
IFE ALWAYS,<		;MORE EXTERNALS, CONDITIONALLY ASSEMBLED.
	EXTERNAL INTMAP,ENABLE
	EXTERNAL GOGTAB,PS3ACS
>
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.
	PUSH	P,[=7]		;ARM FOR FLOATING OVERFLOWS
	PUSH	P,[FLTOV]	;ROUTINE.
	PUSH	P,[0]		;NOT DEFERRED
	PUSHJ	P,INTMAP	;SET IT ALL UP.
	PUSH	P,[=7]
	PUSHJ	P,ENABLE	;AND ENABLE IT.
	PUSH	P,[=6]		;ARM FOR regular, too.
	PUSH	P,[NOFLT]	;ROUTINE.
	PUSH	P,[0]		;NOT DEFERRED
	PUSHJ	P,INTMAP	;SET IT ALL UP.
	PUSH	P,[=6]
	PUSHJ	P,ENABLE	;AND ENABLE IT.
	POP	P,1		;RETURN ADDRESS
	POP	P,OVROUT	;USER'S ROUTINE.
	JRST	(1)		;RETURN.
GETADR:				
	MOVEI	1,400000	;THIS FORK
	JSYS	RIR		;READ TABLES
	HLRZ	2,2		;LEVTAB ADDRESS
	MOVE	1,@2(2)		;LEVEL 3 PC WORD
	MOVEM	1,OVPCWD	;SAVE FOR LOOKING.
	POPJ	P,
NOFLT:
	PUSHJ	P,GETADR	;GET PC WORD
	JRST	NOFX		;NOT FLOATING
FLTOV:
	PUSHJ	P,GETADR	;GET ADDRESS OF INTERRUPTED CODE IN 1
	MOVE	1,-1(1)		;GET OPCODE.
	TLNN	1,40000		;CHECK FOR FSC
	TLZ	1,2000
	DPB	1,[POINT 29,SEW,35] ;CHANGE INSTRUCTION
	PUSH	P,16		;GET BACK INTERRUPT ACS
	MOVEM	P,SAVP
	MOVE	17,[XWD PS3ACS,0]
	BLT	17,17		;RESTORE AC'S
SEW:	SETZ	0,0		;MODIFIED!!!!
	MOVEM	17,PS3ACS+17
	MOVEI	17,PS3ACS
	BLT	17,PS3ACS+16
	MOVE	P,SAVP
	POP	P,16
NOFX:	HLRZ	1,@OVPCWD	;CHECK IF NEXT INSTR IS JFCL
	ANDCMI	1,777
	CAIE	1,(<JFCL>)	;CHECK.
	 JRST	 USRRT		;GO TO USER ROUTINE.
	LDB	1,[POINT 4,@OVPCWD,12]
	MOVE	1,INTCOD(1)	; PICK UP CORRESPONDING FLAG BITS
	TDNN	1,OVPCWD
	 JRST	 USRRT		; IF NO FLAGS ON, JFCL IS NOP
	TLO	1,OV!FXU	; ALWAYS CLEAR OVERFLOW
	ANDCAM	1,OVPCWD	; CLEAR THOSE FLAG BITS
	HRRZ	1,@OVPCWD	;GET EFFECTIVE ADDRESS
	HRRM	1,OVPCWD
	JRST	XIT
RET:	MOVSI	1,OV+FOV+FXU+ZDV	;PROBABLY A NO-OP ON TENEX
	ANDCAM	1,OVPCWD	;BUT PROBABLY DOESNT HURT 
XIT: 	MOVEI	1,400000	;THIS FORK
	JSYS	RIR		;READ LEVTAB,CHNTAB
	HLRZ	2,2
	MOVE	1,OVPCWD
	MOVEM	1,@2(2)		;SAVE THE NEW PC WORD FOR LEVEL 3
	POPJ	P,		;RETURN TO INTERRUPT HANDLER.
USRRT:	SKIPN	OVROUT
	  JRST	 RET		;NO USER ROUTINE.
	PUSHJ	P,@OVROUT	;CALL USER'S ROUTINE.
	POPJ	P,		;JUST RETURN
SAVP:	0
OVROUT:	0
>;TENX  -- END OF TENEX VERSION OF UNDER/OVER FLOW HANDLER
BEND UNDER
.RSEED:	=524287
ENDCOM (TGI)