	/DYA	339 DISPLAY DEVICE HANDLER
	/	H.W. SPENCER, X768, APRIL 1968
/COPYRIGHT 1968, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
	/DISPLAY IOT'S
RPDP=700501		/READ PUSH DOWN POINTER
RXP=700502		/READ X REGISTER 1-12
RYP=701602		/READ Y REGISTER 1-12
RDAC=700601		/READ DISPLAY ADDRESS COUNTER
RS1=700602		/READ STATUS 1 (P.29 "338" MANUAL)
RS2=701622		/READ STATUS 2 (P.30)
RPB=700621		/READ PUSH BUTTONS
RSG1=700622		/READ SLAVE GROUP 1
RSG2=701642		/READ SLAVE GROUP 2
RCG=701662		/READ CHARACTER GENERATOR (VC38)
SPDP=700645		/SET PUSH DOWN POINTER
SIC=700665		/SET INITIAL CONDITIONS
LBF=700705		/SET BREAK FIELD
SCG=700743		/SET CHARACTER GENERATOR
INIT=701605		/INITIALIZE THE DISPLAY
RES1=700724		/RESUME AFTER LTPEN, EDGE OR EXTERNAL STOP
RES2=701604		/RESUME AFTER STOP CODE
CFD=701601		/CLEAR DISPLAY FLAGS AND DAC
STPD=700704		/STOP DISPLAY (EXTERNAL)
SPLP=700642		/SKIP ON LIGHT PEN HIT FLAG
SPSP=700662		/SKIP ON SLAVE LIGHT PEN HIT FLAG
SPES=700701		/SKIP ON EXTERNAL STOP FLAG
SPEF=700702		/SKIP ON EDGE FLAG
SPSF=700721		/SKIP ON INTERNAL STOP FLAG
SPMI=700722		/SKIP ON MANUAL INTERRUPT
SPDF=SPSP			/SKIP ON ANY DISPLAY FLAG
RPL=705512		/READ PRIORITY LEVELS IN API
DYIC=003367		/INITIAL CONDITIONS 
DYPBI1=000200		/PUSH BUTTON INITIAL SETTING & ENABLE BIT
.SCOM=100			/MONITOR COMMUNICATIONS
.MED=3		/MONITOR ERROR DETECTION
	.GLOBL	DYA.
DYA.	DAC	DYCALP		/CAL POINTER
	DAC	DYARGP		/ARGUMENT POINTER
	ISZ	DYARGP		/TO FUNCTION CODE (LOC+1)
	LAC*	DYARGP		/GET FUNCTION CODE
	ISZ	DYARGP		/POINT TO NEXT ARG (LOC+2)
	ADD	(JMP DYDISP	/SET UP FUNCTION DISPATCH
	DAC	.+1
DYDISP	XX			/FUNCTION DISPATCH
	JMP	DYINIT		/1-.INIT
	JMP	DYIGNR		/2-.DLETE-.RENAM-.FSTAT (IGNORED)
	JMP	DYIGNR		/3-.SEEK (IGNORED)
	JMP	DYIGNR		/4-.ENTER (IGNORED)
	JMP	DYRET		/5-.CLEAR (IGNORED)
	JMP	DYCLOS		/6-.CLOSE
	JMP	DYRET		/7-.MTAPE (IGNORED)
	JMP	DYREAD		/10-.READ
	JMP	DYWRIT		/11-.WRITE
	JMP	DYWAIT		/12-.WAIT-.WAITR
	ISZ	DYARGP		/13-.TRAN (IGNORED)
	JMP	DYWRT		/RETURN TO LOC+5
	.EJECT
/DISPLAY INITIALIZATION SECTION
/
/CHECK IF MONITOR DISPLAY-IN-USE FLAG IS ON
DYINIT	LAC*	(.SCOM+4		/.SCOM+4 CONTAINS THE FLAG
	AND	(10000		/  IN BIT 5.
	SZA
DYIN05	JMP	DYIN40		/OK,FLAG IS ON (THIS GETS CHANGED TO
				/  JMP DYIN07 AFTER FIRST TIME THRU
	LAW	24		/IOPS 24 SAYS DISPLAY BIT IS NOT ON
	JMP*	(.MED+1		/GO TO ERROR ROUTINE
/SET INITIALIZING PARAMETERS
/
DYIN07	LAC*	DYCALP		/GET CAL
	AND	(3000		/LOOK AT F (BITS 7-8)
	SZA			/USE STANDARD INIT PARAMETERS (F=0)
	JMP	DYIN70		/GO GET SPECIAL INIT PARAMETERS
/CHECK TO SEE WHETHER THIS CALL IS TO CLEAR THE BUSY FLAG ONLY.
	LAC*	DYARGP		/GET R
	SNA			/NON-0 MEANS YES
	JMP	DYIN08		/NO, ACTUAL INIT WANTED
	DZM	DYIOW		/CLEAR BUSY FLAG
	ISZ	DYARGP		/INCREMENT ARGUMENT POINTER
	JMP	DYIGNR		/RETURN TO CALLER
/PROCEED WITH NORMAL .INIT
DYIN08	LAW	DYIC		/GET INITIAL CONDITIONS
	SIC			/SEND TO DISPLAY
	LAW	DYPBI1		/GET PB SETTING
	LBF			/SET 0-5
	XOR	(100		/ENABLE 6-11
	LBF			/SET 6-11
DYIN10	LAC	DYCHAR		/GET LOC OF CHARACTER TABLE
	SNA			/IF 0 THERE ISNT ONE
	JMP	DYIN20		/SO GO ON TO NEXT STEP
	.REPT	4
	RTR			/MOVE HI-ORDER 6 BITS INTO 11-17
	RAR
	AND	(77		/CLEAR EXTRANEOUS BITS
DYIN15	SCG			/SET CHAR GEN IOT
DYIN20	ISZ	DYARGP		/NEXT ARG (LOC+3)
	LAC	DYPDP		/GET LOC OF PUSH-DOWN LIST
	SPDP			/SEND TO 339
	DAC*	DYARGP		/STORE IN LOC+3
	DZM	DYIOW		/RESET I0 BUSY FLAG
DYIN30	CAL+54			/.SETUP FOR PIC AND API CHANNEL 54
DYAC	16
DYPC	SPDF			/SKIP ON DISPLAY FLAGS
DYPIC	DYINT			/INTERRUPT HANDLER ADDRESS
DYIN60	LAC	.+2		/CLOSE OFF .SETUP ENTRY
DYAC2=DYIN60
DYNSFL	DAC	DYIN30		/LEFT-ADJUSTED REGISTERS INDICATOR WORD 
DYCNT	JMP	DYIGNR		/GO TO RETURN
/ONE-TIME SECTION TO GET LOC OF PDP AND VC38 CHAR TABLE FROM MONITOR.
/  COMMENTS DESCRIBE LATER USE AS STORAGE LOCATIONS.
/  .SCOM+12 POINTS TO THE PDP LOCATION,WHICH IN TURN POINTS TO THE
/  LOCATION OF THE CHARACTER TABLE.
DYIN40	LAC*	(.SCOM+12
DYINTT=DYIN40		/TEMP STORE FOR INTERRUPT SERVICE
DYPDP	DAC	DYPDP		/LOCATION OF PUSH DOWN LIST
DYCHAR	LAC*	DYPDP		/LOCATION OF CHARACTER TABLE
DYCNT2	DAC	DYCHAR		/COUNTER REGISTER
DYL	LAC	.+2		/POINTER TO CURRENT DISPLAY FILE
DYTEMP	DAC	DYIN05		/TEMP STORE FOR HANDLER
DYNSTD	JMP	DYIN07		/CONTAINS CURRENT FLAGS/REGISTERS BITS
/
/SEQUENCE TO COLLECT USER'S SPECIAL INIT PARAMETERS
DYIN70	LAC*	DYARGP		/GET R FROM LOC+2
	DAC	DYR
	LAC*	DYR		/GET R(1), INITIAL CONDITIONS
	SIC			/SEND TO DISPLAY
	ISZ	DYR
	LAC*	DYR		/GET R(2). PB 0-5 WITH REQUIRED ENABLE BITS
	LBF			/SEND TO DISPLAY
	ISZ	DYR
	LAC*	DYR		/GET R(3), PB 6-11 WITH REQUIRED ENABLE BITS
	LBF			/SEND TO DISPLAY
	ISZ	DYR
	LAC*	DYR		/GET CHARACTER GENERATOR SETTINGS
	SZA
	JMP	DYIN15		/USE SETTINGS PROVIDED
	JMP	DYIN10		/NONE PROVIDED,USE MONITOR'S
DYIGNR	ISZ	DYARGP		/POINT TO RETURN
DYRET	DBR			/DEBREAK & RESTORE
	XCT	(JMP* DYARGP	/RETURN PAST CAL (IN 3 CYCLES TO LET DBR WORK
DYBSY	DBR			/DEBREAK
	XCT	(JMP* DYCALP	/AND RETURN TO CAL
	.EJECT
/339 .READ
DYREAD	LAC	DYIOW		/GET .READ BUSY SWITCH
	SZA			/SKIP IF NOT BUSY
	JMP	DYBSY		/BUSY, GO BACK
	LAC*	DYARGP		/GET BUFFER ADDRESS FROM LOC+2
	DAC	DYLPTR		/SAVE IT
	ISZ	DYARGP		/POINT TO LOC+3
	LAC*	DYARGP		/GET -W (INTERRUPT COUNT) FROM LOC+3
	DAC	DYINTP		/SAVE IN TEMPORARY
	LAC*	DYCALP		/GET CAL
	AND	(7000		/SAVE M (BITS 6-8)
	SAD	(7000		/IF M=7
	JMP	DYRD30		/GO GET USERS NSTD
	SZA			/IF M
	JMP	DYRD10		/NOT 0, GO PROCESS M=1-6
	LAC	DYSTD3		/=0, GET STANDARD N0-INTERRUPT WORD
	DAC	DYNSTD
	JMP	DYRD35		/GO READ REGISTERS
/SEQUENCE TO CONVERT M=1 THRU 6 TO A STANDARD FLAGS-REGISTERS WORD
DYRD10	SAD	(1000		/IS IT 1
	LAC	DYNS-6		/YES, GET LP WORD, ALL OTHER SAD TESTS WILL FAIL
	SAD	(2000
	LAC	DYNS-5		/MANUAL INTERRUPT
	SAD	(3000
	LAC	DYNS-4		/PUSHBUTTON
	SAD	(4000
	LAC	DYNS-3		/EDGE FLAG
	SAD	(5000
	LAC	DYNS-2		/INTERNAL STOP
	SAD	(6000
	LAC	DYNS-1		/EXTERNAL STOP
	AND	DYSTD		/AND OUT ALL BUT THE STANDARD REGISTERS
	DAC	DYNSTD		/AND THATS IT
/SEQUENCE TO SET UP DZM OR NOP IN THE INTERRUPT HANDLER TO SAVE 
				/OR IGNOR INTERRUPT FLAGS
DYRD21	LAW	-6		/SET UP COUNTER FOR 6 FLAGS
	DAC	DYCNT	
	LAC	DYNSTD		/GET NSTD
DYRD22	RCL			/SLIP A BIT INTO L
	DAC	DYAC2		/SAVE THE AC
	LAC	DYDZM		/ASSUME FLAG IS TO BE SAVED, GET DZM
	ISZ	DYDZM		/SET TO NEXT FLAG
	SNL			/SKIP IF FLAG IS TO BE SAVED
	LAC	DYNOP		/GET A NOP IF IT IS TO BE IGNORED
DYRD24	DAC*	DYNT1X		/DAC THRU DYNT1X POINTER TABLE
	ISZ	DYRD24		/NEXT ENTRY IN TABLE
	LAC	DYAC2		/RESTORE AC
	ISZ	DYCNT		/INCREMENT COUNTER AND CHECK IF DONE
	JMP	DYRD22		/REPEAT FOR NEXT BIT
	LAC	(DAC* DYNT1X	/RESTORE DAC TO POINTER TABLE
	DAC	DYRD24
	LAC	(DZM DYLP		/RESTORE DZM LIST
	DAC	DYDZM
	JMS	DYRD50		/SET UP READ-REGISTERS IOTS
/CLEAR SOFTWARE INTERRUPT FLAGS
	LAW	-1		/-1 = CLEAR
	DAC	DYLP		/LIGHT PEN
	DAC	DYMI		/MANUAL INTERRUPT
	DAC	DYPB		/PUSH BUTTONS
	DAC	DYEDG		/EDGE VIOLATION
	DAC	DYISTP		/INTERNAL STOP
	DAC	DYESTP		/EXTERNAL STOP
/TURN ON HANDLER BUSY SWITCH
	LAC	DYINTP		/GET - W 
	DAC	DYIOW		/INTO I0 BUSY SWITCH
	JMP	DYIGNR		/RETURN
/SEQUENCE TO PROCESS USERS NSTD
DYRD30	ISZ	DYARGP		/INCREMENT ARG POINTER TO LOC+4
	LAC*	DYARGP		/GET NSTD
	DAC	DYNSTD		/AND SAVE IT
	AND	DYNS		/MASK OFF BITS 0-5
	SZA
	JMP	DYRD33		/REGISTER BITS ON, USE THEM, GO CHECK FLAG BITS
	LAC	DYSTD2		/REGISTER BITS OFF, USE STANDARD DEFAULT  OPTION
	XOR	DYNSTD		/INSERT USERS FLAG BITS
	DAC	DYNSTD
	AND	DYNS		/MASK OFF 0-5
DYRD33	XOR	DYNSTD		/INVERT, NOW 6-17 ARE OFF, 0-5 = FLAG BITS
	SZA
	JMP	DYRD21		/GO SET UP INTERRUPT HANDLER, FLAG BITS ON IN ACAC
/NOT WAITING FOR ANY INTERRUPTS, GO SERVICE READ AND EXIT
DYRD35	LAC	DYNSTD		/GET USER REQUEST BIT MAP
	RTL			/MOVE REGISTER BITS TO LEFT EDGE
	RTL
	RTL
	DAC	DYAC2		/FOR IOT SETUP ROUTINE
	JMS	DYRD50		/SET UP READ-REGISTERS IOTS
	JMS	DYRR20		/READ THOSE REGISTERS
	JMS	DYNT60		/INSERT IN USER'S BUFFER
	LAC	DYWPTR		/RESET INTERNAL BUFFER POINTERS
	DAC	DYAPTR
	LAC	DYBPTR
	DAC	DYWPTR
	JMP	DYIGNR		/RETURN TO USER
/SEQUENCE TO SET UP READ IOT OR SKP IN INTERRUPT HANDLER DEPENDING ON
/   REGISTERS REQUESTED BY USER
DYRD50	0			/ENTRY POINT
	LAW	-12		/10 POSSIBLE REGISTERS
	DAC	DYCNT		/INTO COUNTER
	DAC	DYNSFL		/TO BE USED AS COUNT OF IOTS ISSUED
	LAC	DYAC2		/GET REGISTER BITS
DYRD52	RCL			/PUT ONE IN THE LINK
	DAC	DYAC2		/SAVE REMAINDER
DYRD54	LAC	DYREG		/GET AN IOT
	ISZ	DYRD54		/POINT TO NEXT IOT
	SZL			/USE THE IOT IF L=1
	JMP	DYRD56
	ISZ	DYNSFL		/REDUCE COUNT OF IOTS BY ONE
	LAC	DYSKP		/USE SKIP IF L=0 (UNWANTED REGISTER)
DYRD56	DAC*	DYRR2X		/DAC THRU DYRR2X POINTER TABLE
	ISZ	DYRD56		/NEXT ENTRY IN POINTER TABLE
	LAC	DYAC2		/RESTORE BIT MAP TO AC
	ISZ	DYCNT		/BUMP COUNT AND CHECK IF FINISHED
	JMP	DYRD52		/BACK FOR NEXT ROUND
	LAC	(LAC DYREG	/ALL DONE, RESET POINTERS
	DAC	DYRD54
	LAC	(DAC* DYRR2X
	DAC	DYRD56
	JMP*	DYRD50		/LEAVE
 
	.EJECT
/339 .WRITE
DYWRIT	LAC*	DYCALP		/GET CAL
	AND	(7000		/SAVE M (BITS 6-8)
	SNA
	JMP	DYWR10		/0 = RESUME DISPLAY AFTER EXT STOP
	SAD	(4000
	JMP	DYWR20		/4 = START THE DISPLAY AT L
	SAD	(2000
	STPD+10			/2 = STOP THIS DISPLAY (IGNORE ANYTHING ELSE)
	SAD	(1000
	RES2+10			/1 = RESUME DISPLAY AFTER INTERNAL STOP
DYWRT	ISZ	DYARGP		/POINT TO LOC +3
	JMP	DYIGNR		/RETURN PAST CAL
DYWR10	LAC	DYL		/GET ADDRESS OF CURRENT DISPLAY FILE
	JMP	DYWR22		/GO RESTART THIS DISPLAY
/START DISPLAY AT L
DYWR20	CFD			/CLEAR DISPLAY AND SET TO CONTROL STATE
	LAC*	DYARGP		/GET DISPLAY FILE POINTER
	DAC	DYL		/SAVE CURRENT DISPLAY FILE ADDRESS
DYWR22	AND	(70000		/GET HIGH ORDER 3 BITS OF ADDRESS
	CLL			/CLEAR LINK
	RTR			/MOVE TO BREAK FIELD POSITION IN AC
	RTR
	XOR	(4000		/SET ENABLE BREAK FIELD BIT
	LBF			/LOAD BREAK FIELD
	LAC	DYPDP		/GET PUSH-DOWN STACK LOCATION
	SPDP			/RESET PDP
	LAC	DYL		/GET DISPLAY FILE POINTER AGAIN
	INIT			/START DISPLAY
	JMP	DYWRT		/RETURN
	.EJECT
/339 .WAIT
DYWAIT	LAC*	DYCALP		/GET CAL
	AND	(1000		/CHECK BIT 8
	SZA			/IS IT .WAIT OR .WAITR
	JMP	DYWT10		/.WAITR
	LAC	DYIOW		/GET BUSY SWITCH
	SZA
	JMP	DYBSY		/BUSY RETURN TO CAL
	JMP	DYRET		/NOT BUSY, RETURN PAST CAL
/.WAITR
DYWT10	LAC	DYIOW		/GET BUSY SWITCH
	SNA
	JMP	DYIGNR		/NOT BUSY, RETURN PAST CAL
	LAC	DYCALP		/BUSY, GET RESTORE BITS
	AND	(700000		/ (0-2)
	DAC	DYCALP		/SAVE THEM
	LAC*	DYARGP		/GET USERS ADDR. FROM LOC+2
	AND	(077777		/CLEAN OUT BITS 0-2
	XOR	DYCALP		/INSERT RESTORE BITS
	DAC	DYARGP		/SAVE IN RETURN POINTER
	JMP	DYRET		/AND GO THERE
	.EJECT
/ 339. CLOSE
DYCLOS	RS1			/READ STATUS 1 TO CLEAR PUSHBUTTON FLAG
	SPMI			/SKIP ON MANUAL INTERRUPT TO CLEAR ITS FLAG
DYNOP	NOP
	CFD			/CLEAR DISPLAY FLAGS (THE REST,THAT IS) & DAC
	JMP	DYRET		/RETURN
	.EJECT
/ INTERRUPT HANDLER
DYINT	SKP			/PIC ENTRY
	JMP	DYAPI		/API ENTRY (PRIORITY 2)
	DAC	DYAC		/SAVE AC
	LAC	DYION		/ION INTO INTERRUPT RETURN SEQUENCE
	DAC	DYSW
	LAC*	(0		/PIC RETURN ADDR. IN LOC 0
	DAC	DYPC		/INTO RETURN PC
	JMP	DYNT10
DYAPI	DAC	DYAC		/API ENTRY-SAVE AC
	LAC	DYINT		/GET RETURN ADDRESS
	DAC	DYPC		/SAVE IT
	LAC	DYNOP		/NOP INTO INTERRUPT RETURN SEQUENCE
	DAC	DYSW
 
/SAVE AND CLEAR INTERRUPT FLAGS
DYNT10	LAC	(10000		/BITS 6,10 OFF FOR SPES;5 ON=ESTOP
	SPES			/SKIP ON ESTOP,NO FLAG
	CLA			/NO ESTOP,CLEAR BIT 15
	RS1+10			/TO GET INTERRUPT FLAGS AND CLEAR PB FLAG
	AND	(7470		/KEEP INTERRUPT FLAGS ONLY
	SAD*	DYWPTR		/IF SAME AS INTERRUPT BEING PROCESSED
	JMP	DYNT11		/  GO CLEAR FLAGS AND EXIT
	DAC	DYINTT
	LAC	DYIOW
	SNA
	JMP	DYNT11
	LAC	DYINTT
	DAC*	DYBPTR
	JMS	DYRR20		/READ REQUESTED REGISTERS
DYNT11	SPMI			/SKIP ON MANUAL INTERRUPT-TO TURN FLAG OFF
	SKP!CLA
	JMP	DYNT20
	SPES			/SEE IF THIS WAS ESTOP
	JMP	DYNT20		/SKIP AROUND EXTERNAL STOP
	CFD			/CLEAR DISPLAY FLAGS TO ALLOW ION,ETC.
DYSKP	SKP!CLA			/SKIP OVER RES1 AFTER CLF
DYNT20	RES1			/ALL NEEDED FLAGS AND REGISTERS OBTAINED,
		/RESUME DISPLAY ON LP OR EDGE INTERRUPT. IF INTERRUPT WAS ISTP,RES1
		/CLEARS THE FLAG BUT DOESN'T RESUME THE DISPLAY.
/CHECK INTERRUPT BUSY STATUS
	SAD	DYIOW		/IF READ-BUSY FLAG IS OFF (=0
	JMP	DYIRTB		/  GO TO EXIT.
	SAD	DYBUSY		/IF INTERRUPT-BUSY FLAG IS ON (=0
	JMP	DYIRTB		/  GO TO EXIT.
	DZM	DYBUSY		/TURN ON INTERRUPT-BUSY FLAG
	LAC	DYSW		/GET ION OR NOP FROM INTERRUPT RETURN SEQUENCE
	DAC	DYPIC		/PIC-API INDICATOR (NOP=API)
	SAD	DYNOP		/WHICH IS IT
	JMP	DYIRTA		/GO SET UP LEVEL 4 INTERRUPT AND RETURN (API)
	LAC*	(0		/SET UP PIC RETURN FROM 0
	DAC	DYINTP		/IN INTERRUPT PROCESSOR
	LAC	DYAC		/GET INTERRUPT AC
DYION	ION			/TURN PIC ON
	JMP	DYINTP+1		/AND GO TO INTERRUPT PROCESSOR
/INTERRUPT HANDLER RETURN SEQUENCE (WITHOUT HAVING PROCESSED THE INTERRUPT)
DYIRTA	LAC	(DYINTP		/GET INTERRUPT PROCESSOR ADDRESS
	DAC*	(.SCOM+12		/INTO LEVEL 4 MONITOR WORD
	LAC	(404000		/SET UP INTERRUPT AT LEVEL 4
DYISA	ISA			/REQUEST IT (NOW AT LEVEL 2)
DYIRTB	LAC	DYAC		/RESTORE INTERRUPT AC
DYSW	XX			/ION OR NOP IF ENTERED VIA PIC OR API
	DBR			/DEBREAK FROM LEVEL 2 (IF API)
	XCT	(JMP* DYPC	/RETURN
 
/SEQUENCE TO READ AND SAVE HARDWARE REGISTERS REQUESTED BY USER
DYRR20	0			/ENTRY POINT
DYAUTO=11			/AUTO-INDEX REGISTER USED
	LAC*	(DYAUTO		/SAVE CONTENTS
	DAC	DYINTT
	LAC	DYBPTR		/LOAD WITH BUFFER POINTER
	DAC*	(DYAUTO
DYRR21	RPDP+10			/READ PUSH DOWN POINTER
	DAC*	DYAUTO
DYRR22	RXP+10		/X REGISTER
	DAC*	DYAUTO
DYRR23	RYP+10
	DAC*	DYAUTO
DYRR24	RDAC+10			/DISPLAY ADDRESS COUNTER
	DAC*	DYAUTO
DYRR25	RS1+10			/STATUS REGISTER 1
	DAC*	DYAUTO
DYRR26	RS2+10			/STATUS REGISTER 2
	DAC*	DYAUTO
DYRR27	RPB+10			/PUSH-BUTTON REGISTER
	DAC*	DYAUTO
DYRR30	RSG1+10			/SLAVE GROUP 1
	DAC*	DYAUTO
DYRR31	RSG2+10			/SLAVE GROUP 2
	DAC*	DYAUTO
DYRR32	RCG+10			/CHARACTER GENERATOR
	DAC*	DYAUTO
	LAC	DYINTT		/RESTORE AUTO-INDEX REGISTER
	DAC*	(DYAUTO
	LAC	DYAPTR		/RESET BUFFER POINTER FOR NEXT INTERRUPT
	DAC	DYBPTR
	JMP*	DYRR20
 
	.EJECT
/INTERRUPT PROCESSOR
DYINTP	XX			/RETURN ADDRESS HERE
	DAC	DYAC2		/SAVE AC
/SET UP PROTECTS AND UNPROTECTS TO FOLLOW DEPENDING ON PIC OR API, AND
				/PROTECT FLAG-CHECKING
DYNT40	LAC	DYPIC		/GET API-PIC INDICATOR
	SAD	DYION
	JMP	DYNT44		/GO SET UP FOR PIC
	LAC	DYISA		/GET ISA(SETTING UP FOR API)
	DAC	DYNT46		/INTO PROTECT FOR CHECKING INTERRUPT
	LAC	(DBK		/GET DBK
	DAC	DYNT48		/INTO RETURN FROM CHECKING INTERRUPT
	DAC	DYNT73		/AND INTO EXIT TO OUTSIDE WORLD
	JMP	DYNT30		/GO CHECK ON FLAGS
DYNT44	DAC	DYNT48		/ION INTO RETURN FROM INT CHECKING
	DAC	DYNT73		/  AND INTO EXIT TO OUTSIDE WORLD
	LAC	(IOF		/GET IOF
	DAC	DYNT46		/INTO PROTECT FOR INT CHECKING
/SET UP REMAINING SOFTWARE INTERRUPT FLAGS NOT SET AT INTERRUPT TIME
DYNT30	LAC*	DYWPTR		/GET WORD CONTAINING FLAG BITS
	RTL			/LOSE HIGH-ORDER 6 BITS
	RTL
	RTL
	SZL			/CHECK HOME-MADE ESTOP BIT
DYNT17	DZM	DYESTP		/SET ESTP WORD
	SPA!RTL			/CHECK LP FLAG IN SIGN POSITION AND
			/MOVE V & H EDGE FLAGS INTO S & L
DYNT12	DZM	DYLP		/SET LIGHT PEN WORD
	SPA!SZL!RTL		/SKIP IF NEITHER EDGE FLAG WAS ON AND
			/MOVE ISTOP FLAG INTO L
DYNT13	DZM	DYEDG		/SET EDGE FLAG WORD
	SZL!RTL			/SKIP IF ISTOP FLAG OFF AND MOVE SECTOR
			/0 AND CONTROL STATE FLAGS OUT OF THE WAY
DYNT14	DZM	DYISTP		/SET ISTOP WORD
	SPA!RAL			/SKIP IF MI FLAG OFF AND MOVE
			/PB FLAG INTO S
DYNT16	DZM	DYMI		/MANUAL INTERRUPT WORD ON
	SPA			/SKIP IF PB FLAG OFF 
DYNT15	DZM	DYPB		/SET PUSH-BUTTON WORD
/CYCLE THRU SOFTWARE FLAGS TO SEE WHICH ARE ON
	LAW	-6		/SIX SOFTWARE FLAGS
	DAC	DYCNT		/INTO LOOP COUNTER
	LAC	(DYLP		/LP FLAG IS FIRST ONE
	DAC	DYFLGS		/INTO FLAGS POINTER
DYNT33	LAC*	DYFLGS		/GET A FLAG
	SZA			/IS IT ON (0=YES)
	JMP	DYNT37		/NO, LOOK AT NEXT
DYNT35	LAW	-1		/TURN OFF FLAG ABOUT TO BE SERVICED
	DAC*	DYFLGS
	JMS	DYNT60		/CALL READ-REGISTERS ROUTINE
	ISZ	DYIOW		/INCREMENT USERS INTERRUPT CPUNT
	JMP	DYNT37		/REPEAT IF NOT FINISHED
DYNT36	LAC	(400040		/SET AC TO RAISE TO API LEVEL 2
DYNT46	XX			/IOF IF PIC,ISA IF API
	DZM*	DYWPTR		/CLEAR WORD WITH FLAG BITS
	LAC	DYWPTR		/DONE WITH WORKING BUFFER,
	DAC	DYAPTR		/  MAKE IT THE AUXILLIARY BUFFER
	LAC	(DYBUF2		/RESET WORKING BUFFER POINTER
	SAD	DYWPTR
	LAC	(DYBUF1		/TO THE OTHER BUFFER
	DAC	DYWPTR
	LAC	DYIOW		/CHECK IF DONE
	SNA
	JMP	DYIRTC		/DONE, GO TO EXIT
	LAC*	DYWPTR		/GET FLAG WORD FROM NEW WORKING BUFFER
	SNA			/IF 0, NO INTERRUPT TOOK PLACE
	JMP	DYIRTC		/GO EXIT
	LAC	DYAPTR		/RESET BUFFER POINTERS
	DAC	DYBPTR
DYNT48	XX			/DBK IF API, ION IF PIC
	JMP	DYNT30+1		/GO PROCESS NEW INTERRUPT
DYNT37	ISZ	DYFLGS		/INCREMENT FLAG POINTER
	ISZ	DYCNT		/INCREMENT LOOP COUNTER
	JMP	DYNT33		/REPEAT IF NOT FINISHED
	JMP	DYNT36		/OTHERWISE GO CLOSE UP
/GET REGISTERS SPECIFIED BY .READ AND WRITE TO USERS BUFFER
DYNT60	0			/RETURN ADDRESS FROM THIS SUBROUTINE
	LAC	(DYNS		/POINTER TO END+1 OF FLAG INDICATOR LIST
	TAD	DYCNT		/SUBTRACT LOOP COUNTER TO POINT TO RIGHT INDICATOR
	DAC	DYTEMP
	LAC*	DYTEMP		/GET WORD SHOWING WHICH FLAG THIS IS
	AND	DYNSTD		/MASK OUT ALL OTHERS IN USER REQUEST
	DAC*	DYLPTR		/WRITE BUFFER HEADER WORD
	ISZ	DYLPTR		/INCREMENT BUFFER POINTER
	LAC	DYNSFL		/GET INTERRUPT BUFFER WORD COUNT
	SNA			/IF NO REGISTERS WERE READ
	JMP*	DYNT60		/  RETURN TO CALLER.
	DAC	DYCNT2		/INTO COUNTER
	LAC	DYWPTR		/GET BUFFER POINTER INTO
	DAC	DYTEMP		/  MOVABLE REGISTER
DYNT62	ISZ	DYTEMP		/NEXT WORD IN INTERRUPT BUFFER
	LAC*	DYTEMP		/GET THE WORD
	DAC*	DYLPTR		/GIVE IT TO USER'S BUFFER
	ISZ	DYLPTR		/NEXT WORD IN USER'S BUFFER
	ISZ	DYCNT2		/DECREMENT INT BUFFER WORD COUNT
	JMP	DYNT62		/GO GET NEXT WORD
	JMP*	DYNT60		/RETURN TO CALLER
DYIRTC	ISZ	DYBUSY		/TURN OFF INTERRUPT PROCESSOR BUSY FLAG
	LAC	DYAC2		/RESTORE AC
DYNT73	XX			/DBK TO LEVEL 4 IF API, ION IF PIC
	DBR			/DEBREAK TO ENTERING LEVEL & RESTORE
	XCT	(JMP* DYINTP	/RETURN THRU ENTRY OF INT. PROCESSOR
	.EJECT
/CONSTANTS AND STUFF LIKE THAT
DYCALP				/POINTER TO CAL
DYARGP				/POINTER TO CURRENT ARGUMENT OF CAL
DYR			/POINTER TO USERS .READ BUFFER
DYBUSY	1		/INTERRUPT HANDLER BUSY FLAG
DYIOW	0		/READ HANDLER BUSY FLAG
DYFLGS	.DSA	DYLP		/FLAGS POINTER
DYLP	-1			/LIGHT PEN FLAG
DYMI	-1			/MANUAL INTERRUPT FLAG
DYPB	-1			/PUSHBUTTON FLAG
DYEDG	-1			/EDGE FLAG
DYISTP	-1			/INTERNAL STOP FLAG
DYESTP	-1			/EXTERNAL STOP FLAG
DYDZM	DZM	DYLP		/DZM TO BE INSERTED IN INTERRUPT HANDLER
DYSTD3	004340
DYSTD2	007440
DYSTD	777440			/STANDARD SET OF REGISTERS TO READ FROM 339
	407777			/BUFFER HEADER CONSTANTS-INDICATES LIGHT PEN
	207777			/INDICATES MANUAL INTERRUPT FLAG
	107777			/INDICATES PUSHBUTTON FLAG
	047777			/INDICATES EDGE FLAG
	027777			/INDICATES INTERNAL STOP FLAG
	017777			/INDICATES EXTERNAL STOP FLAG
DYNS	007777			/INDICATES NO INTERRUPT, JUST READ
DYLPTR=DYR			/POINTER TO USERS .WRITE BUFFER
DYREG	RPDP+10			/READ DISPLAY REGISTERS IOTS
	RXP+10
	RYP+10
	RDAC+10
	RS1+10
	RS2+10
	RPB+10
	RSG1+10
	RSG2+10
	RCG+10
DYNT1X	DYNT12			/LIST OF PLACES IN THE INTERRUPT
	DYNT16			/  HANDLER SET BY .READ TO EITHER
	DYNT15			/  DZM IF THIS IS A REQUESTED FLAG
	DYNT13			/  OR NOP IF THIS FLAG IS TO BE
	DYNT14			/  IGNORED.
	DYNT17
DYBUF1	.BLOCK	12		/INTERNAL BUFFERS TO SAVE 339 REGISTER
DYBUF2	.BLOCK	12
DYAPTR	DYBUF2			/AUXILLIARY BUFFER POINTER
DYBPTR	DYBUF1			/INTERRUPT READ BUFFER POINTER
DYWPTR	DYBUF1			/INTERRUPT PROC. WORKING BUFFER PTR
DYRR2X	DYRR21			/LIST OF PLACES
	DYRR22		/IN THE READ-REGISTERS
	DYRR23		/ROUTINE, SET BY .READ
	DYRR24		/TO EITHER THE APPROPRIATE
	DYRR25		/READ IOT OR A SKP
	DYRR26		/DEPENDING ON WHETHER
	DYRR27		/THE USER REQUESTED THIS
	DYRR30		/REGISTER OR NOT
	DYRR31
	DYRR32
	.END
