	/DYA	339 DISPLAY DEVICE HANDLER
	/	FOR BACKGROUND/FOREGROUND
	/	H.W.SPENCER, 8-12-69.
/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
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
SPDI=700662		/SKIP ON DISPLAY INTERRUPT
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.	JMS	SWAP
LPA.=DYA.
	0			/FOREGROUND BUSY
	0			/BACKGROUND BUSY
	0			/FOREGROUND .CLOSE
	0			/BACKGROUND .CLOSE
DYWD5	XX			/ION OR IOF
DYWD6	XX			/ION OR IOF OR DBR
DYWD7	XX			/RETURN POINTER
DYWD10	XX			/JUMP FUNCTION
LPWD10=DYWD10
DYWD11	XX			/USER ID (0=FG,1=BG)
DYWD12	XX			/.DAT SLOT NO.
DYWD13	XX			/UNIT NO.,CAL ADDRESS
DYWD14	XX			/FILE TYPE OR DATA MODE
DYWD15	XX			/RESTART OR BUFFER ADDRESS
DYWD16	XX			/BUFFER SIZE OR WORD COUNT
DYWD17	XX			/R/T ADDRESS AND PRIORITY(0-2)
LPWD17=DYWD17
/FUNCTION DISPATCH TABLE (WORDS 20-32)
	JMP	DYINIT		/1-.INIT
	JMP	DYIGNR		/2-.DLETE-.RENAM-.FSTAT (IGNORED)
	JMP	DYIGNR		/3-.SEEK (IGNORED)
	JMP	DYIGNR		/4-.ENTER (IGNORED)
	JMP	DYIGNR		/5-.CLEAR (IGNORED)
	JMP	DYCLOS		/6-.CLOSE
	JMP	DYIGNR		/7-.MTAPE (IGNORED)
DYRD	JMP	DYREAD		/10-.READ
	JMP	DYWRIT		/11-.WRITE
	XX			/12-.WAIT-.WAITR
	JMP	DYIGNR		/13-.TRAN (IGNORED)
SCOM35	XX			/.SCOM+35
	DYSTP			/FOREGROUND STOP I/O
	DYSTP			/BACKGROUND STOP I/O
	2			/THIS IS THE 339 HANDLER
	.EJECT
/DISPLAY INITIALIZATION SECTION
/
/CHECK IF MONITOR DISPLAY-IN-USE FLAG IS ON
DYINIT	LAC*	(.SCOM+12		/.SCOM+12 SHOULD BE NON-0
	SZA
DYIN05	JMP	DYIN40		/OK,FLAG IS ON (THIS GETS CHANGED TO
				/  JMP DYIN07 AFTER FIRST TIME THRU
	LAW	5024		/DISPLAY NOT IN
DYIN06	DAC	LPTMP1
	LAC	DYWD13
	DAC	LPTAUX
	LAC	DYWD11		/USER ID
	SZA
	LAC	(3000		/IF BACKGROUND
	XOR	LPTMP1
	JMS	LPTERR		/GO CAUSE PRINTING OF ERROR MESSAGE
	JMP	DYIGNR		/EXIT FROM CAL
/SET INITIALIZING PARAMETERS
/
DYIN07	LAC	DYWD14		/GET FILE TYPE
	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	DYWD15		/GET R
	SZA			/NON-0 MEANS YES
	JMP	DYIGNR		/GO CLEAR FLAG AND EXIT
/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	LAC	DYPDP		/GET LOC OF PUSH-DOWN LIST
	SPDP			/SEND TO 339
	DAC*	DYWD16		/SEND TO USER
DYIN30	LAC*	(.SCOM+55		/.SETUP FOR PIC AND API CHANNEL 54
DYAC	DAC	DYIN30
DYPC	JMS*	DYIN30
LPTMP1	SPDI			/SKIP ON DISPLAY INTERRUPT
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
/FIND THE LOCATION OF 339 SLOT IN LEVEL 4 Q
DYLVL4	LAC*	(.SCOM+53
LPTMP2	TAD	(2
	DAC	DYLVL4
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
DYR=DYWD15			/POINTER TO USER INIT PARAMETERS
DYIN70	LAC	DYR		/GET POINTER
	AND*	(.SCOM		/CHECK FOR NEXM
	SAD	DYR
	JMP	DYIN72		/OK,PROCESS USERS INIT
	LAW	5036		/SET UP ERROR MESSAGE 36
	JMP	DYIN06
DYIN72	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
	.EJECT
/CAL RETURN SEQUENCE
DYIGNR	JMS	CLFLAG		/CLEAR BUSY FLAGS
DYTIO	LAC	(400200		/RAISE TO PRIORITY LEVEL 0
	ISA
	IOF
LPFCLR	SKP			/NOP IF FLAG TO BE CLEARED
	DZM	DYA.+1		/FOREGROUND BUSY FLAG.
LPBCLR	SKP			/NOP IF FLAG TO BE CLEARED
	DZM	DYA.+2		/BACKGROUND BUSY FLAG.
	LAC	DYSKP		/RESET
	DAC	LPFCLR		/SWITCHES.
	DAC	LPBCLR
	DBK			/FROM LEVEL 0.
	XCT DYA.+5		/ION OR IOF
	XCT .+1
	XCT (JMP* DYA.+7		/RETURN POINTER.
	.EJECT
/339 .READ
DYREAD	LAC	DYWD15		/GET BUFFER ADDRESS
	DAC	DYLPTR		/SAVE IT
	LAC	DYWD16		/GET -W (INTERRUPT COUNT)
	DAC	DYINTP		/SAVE IN TEMPORARY
	LAC	DYWD14		/GET M
	SAD	(7		/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	TAD	(LAC DYSTD	/GET APPROP F-R WORD
	DAC	.+1
	XX
	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 INTERNAL BUSY SWITCH
	LAC	DYINTP		/GET - W 
	DAC	DYIOW		/INTO I0 BUSY SWITCH
	JMP	DYTIO		/RETURN
/SEQUENCE TO PROCESS USERS NSTD
DYRD30	LAC*	(.MED		/POINTS TO LOC AFTER I/O MACRO
	DAC	DYTEMP
	TAD	(1		/INCERMENT RETURN POINTER
	DAC*	(.MED
	LAC*	DYTEMP		/GET USER'S NSTD WORD
	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 AC
/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	DYWRT		/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	DYWD14		/GET M
	SNA
	JMP	DYWR10		/0 = RESUME DISPLAY AFTER EXT STOP
	SAD	(4
	JMP	DYWR20		/4 = START THE DISPLAY AT L
	SAD	(2
	STPD+10			/2 = STOP THIS DISPLAY (IGNORE ANYTHING ELSE)
	SAD	(1
	RES2+10			/1 = RESUME DISPLAY AFTER INTERNAL STOP
/I/O COMPLETED BY THIS CAL, RETURN
DYWRT	LAC	DYWD17		/SEE IF THIS WAS R-T REQUEST
	SZA
	JMS	LPNXTQ		/IT WAS, CALL REALTP
	JMP	DYIGNR		/RETURN, CLEAR BUSY FLAGS
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	DYWD15		/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. 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	DYIGNR		/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
	DZM*	(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	DYDBK		/DBK INTO INTERRUPT RETURN SEQUENCE
	DAC	DYSW
 
/SAVE AND CLEAR INTERRUPT FLAGS
DYNT10	LAC*	(.SCOM+35	/SAVE IN-PROCESS FLAG
	DAC	SCOM35
	LAW	-1		/SET FLAG TO SHOW THIS INTERRUPT
	DAC*	(.SCOM+35
	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 (DBK=API)
/INTERRUPT HANDLER RETURN SEQUENCE (WITHOUT HAVING PROCESSED THE INTERRUPT)
DYIRTA	LAC	(DYINTP+400000	/GET INTERRUPT PROCESSOR ADDRESS
	DAC*	DYLVL4		/INTO LEVEL 4 Q
DYIRTB	LAC*	(.SCOM+54		/ADDRESS
	DAC	LPTMP1		/OF CALL4
	LAC	(400200		/RAISE TO LEVEL 0
DYISA	ISA
	JMS*	LPTMP1
	DYPC
	SCOM35
	LAC	SCOM35		/RESTORE IN-PROCESS FLAG
	DAC*	(.SCOM+35
	LAC	DYAC		/RESTORE INTERRUPT AC
DYSW	XX			/ION OR DBK IF ENTERED VIA PIC OR API
	DBR			/DEBREAK FROM LEVEL 2 (IF API)
	XCT	.+1
	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
/ENTERED AT LEVEL 4 OF API (IF API IS PRESENT) WITH PIC ON.
/ENTERED AT MAINSTREAM (IF NO API).
DYINTP	XX			/RETURN ADDRESS HERE
/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	DYDBK		/GET DBK
	DAC	DYNT48		/INTO RETURN FROM CHECKING INTERRUPT
	LAC	DYISA		/GET ISA(SETTING UP FOR API) INTO PROJECT FOR CHECKING INTERRUPT.
	JMP	DYNT30-1		/GO CHECK ON FLAGS
DYNT44	DAC	DYNT48		/ION INTO RETURN FROM INT CHECKING 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
	SZA
	JMP	DYNT47		/NOT DONE,LOOK FOR MORE
	ION
	JMP	LPEMPT		/GO TO IO DONE SEQUENCE
DYNT47	LAC*	DYWPTR		/GET FLAG WORD FROM NEW WORKING BUFFER
	SNA			/IF 0, NO INTERRUPT TOOK PLACE
	JMP	DYNOR		/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
DYNOR	LAC	(400200		/RAISE TO LEVEL 0
	ISA
	IOF
	XCT	LPFCLR		/SKP OR NOP
	DZM	DYA.+1		/CLEAR FG BUSY
	XCT	LPBCLR		/SKP OR NOP
	DZM	DYA.+2		/CLEAR BG BUSY
	LAC	DYSKP		/RESET TO SKP
	DAC	LPFCLR
	DAC	LPBCLR
	ISZ	DYBUSY		/CLEAR INT. PROCESSOR BUSY FLAG
DYNT73	ION
DYDBK	DBK			/TO LEVEL 2
	DBR			/DEBREAK TO ENTERING LEVEL & RESTORE
	XCT	.+1
	XCT	(JMP* DYINTP	/RETURN THRU ENTRY OF INT. PROCESSOR
LPNOR=DYNOR
	.EJECT
/STOP I/O SUBROUTINE
DYSTP	0
	LAC	(400200		/RAISE TO LEVEL 0
	ISA
	IOF
	DZM	DYIOW		/CLEAR INTERNAL BUSY FLAG
	RS1			/CLEAR PUSHBUTTON FLAG
	SPMI			/CLEAR MANUAL INTERRUPT FLAG
	NOP
	CFD			/CLEAR ALL OTHERS
	DZM	DYA.+1		/CLEAR BUSY AND CLOSE FLAGS
	DZM	DYA.+2
	DZM	DYA.+3
	DZM	DYA.+4
	DBK			/RELEASE INTERRUPT SYSTEM
	ION
	JMP*	DYSTP
/SET UP SWITCH IN EXIT ROUTINE TO
/CLEAR FOREGROUND OR BACKGROUND BUSY REGISTER AS
/A FUNCTION OF WORD11, AND PLACE IOF IN LPT
/IOT REGISTER SO THAT NO NEW I/O WILL BE STARTED.
LPEMPT	JMS	CLFLAG
/IS THIS DEVICE INVOLVED IN I/O BUSY SITUATION.
LPT31	LAC*	(.SCOM+52		/ADDRESS OF
	DAC	LPTMP1		/I/O BUSY
	LAC	(400200		/TESTER.
	ISA			/PROTECT.
	IOF
	LAC	(LPA.
	JMS*	LPTMP1
	DBK			/UNPROTECT.
	ION
	JMS	LPREAL		/CHECK FOR REAL TIME REQUEST.
	JMP	LPNOR		/NOT REAL TIME REQUEST.
	LAC	LPWD17
	JMS	LPNXTQ
	JMP	LPNOR
/SUBROUTINE TO PLACE CONTENTS OF
/AC IN REAL TIME QUEUEING SCHEME.
LPNXTQ	0
	DAC	LPTMP1
	LAC*	(.SCOM+51
	DAC	LPTMP2		/SAVE AC.
	LAC	(400200		/RAISE TO API
	ISA			/LEVEL 0
	IOF			/TURN OFF PIC
	LAC	LPTMP1		/RESTORE AC
	JMS*	LPTMP2		/ENTER REALTP SUBROUTINE
	DBK			/FROM LEVEL 0
DYION	ION			/TURN ON PIC.
	JMP*	LPNXTQ
/
/SUBROUTINE TO DETERMINE IF THIS I/O
/WAS A REAL TIME REQUEST OR NOT.
/CALLING SEQUENCE:	JMS	LPREAL
/		(NOT REAL)
/		(REAL)
LPREAL	0
	LAC	LPWD17		/NON 0 IF REAL TIME.
	SNA
	JMP*	LPREAL		/NOT .REALW
	LAC	(JMP DYRD
	SAD	LPWD10		/JMP FUNCTION
	ISZ	LPREAL		/.REALW
	JMP*	LPREAL
/SUBROUTINE TO SET UP CLEARING OF THE
/APPROPRIATE BUSY FLAG (AT PROTECTED EXIT TIME)
/AND NULL (IOF) LINE PRINTER IOT
/REGISTER.
CLFLAG	0
	DZM	DYIOW		/CLEAR INTERNAL BUSY FLAG
	LAC	LPA.+11		/WORD 11 OF LIVE REGS.
	SZA			/0=FGRD, 1=BGRD
	JMP	.+4
	LAC	(NOP		/FOREGROUND
	DAC	LPFCLR
	JMP*	CLFLAG
	LAC	(NOP		/BACKGROUND
	DAC	LPBCLR
	JMP*	CLFLAG
/
/THIS SUBROUTINE IS EXECUTED (XCT) BY THE
/CAL HANDLER VIA WORD 0 OF THIS I/O
/HANDLER JUST PRIOR TO GIVING CONTROL
/TO THE HANDLER AT THE APPROPRIATE
/ENTRY IN THE FUNCTION DISPATCH TABLE.
SWAP	0
/MULTI-UNIT DEVICES ONLY:
/	STOP ANY I/O
/	IN PROGRESS.
	XCT	LPA.+5		/ION OR IOF
	DBK			/FROM LEVEL 0
/MULTI-UNIT DEVICES ONLY:
/	SWAP BACKUP AND
/	LIVE DATA REGISTERS.
	JMP*	SWAP
/
/SUBROUTINE TO CAUSE OUTPUTTING OF ERROR MESSAGE.
LPTERR	0
	DAC	LPTLAW		/LAW CODE
	LAC*	(.SCOM+66
	DAC	LPTMP1
	LAC	(400200		/RAISE TO API LEVEL 0
	ISA
	IOF			/TURN OF PIC.
LPTLAW	XX			/LAW CODE
	JMS*	LPTMP1
LPTAUX	XX
	DBK
	ION
	JMP*	LPTERR
/
	.EJECT
/CONSTANTS AND STUFF LIKE THAT
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
