/ 
/ 
/                   FIRST PRINTING, FEBRUARY 1974
/ 
/ THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO 
/ CHANGE WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED
/ AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
/ DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPON-
/ SIBILITY FOR ANY ERRORS THAT MAY APPEAR IN THIS
/ DOCUMENT.
/ 
/ THE SOFTWARE DESCRIBED IN THIS DOCUMENT IS FUR-
/ NISHED TO THE PURCHASER UNDER A LICENSE FOR USE ON
/ A SINGLE COMPUTER SYSTEM AND CAN BE COPIED (WITH
/ INCLUSION OF DIGITAL'S COPYRIGHT NOTICE) ONLY FOR 
/ USE IN SUCH SYSTEM, EXCEPT AS MAY OTHERWISE BE PRO-
/ VIDED IN WRITING BY DIGITAL.
/ 
/ DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY
/ FOR THE USE OR RELIABILITY OF ITS SOFTWARE ON EQUIP-
/ MENT THAT IS NOT SUPPLIED BY DIGITAL.
/ 
/ COPYRIGHT (C) 1974, BY DIGITAL EQUIPMENT CORPORATION
/ 
/ 
        .EJECT
/ EDIT #13
/
/ COPYRIGHT 1971, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/
/ RSX UDC-15 HANDLER TASK     12 JAN 72        H. KREJCI, W.A. DESIMONE
/
/ THIS HANDLER TASK IS TO PROVIDE AN RSX INTERFACE TO THE
/ PDP-15 UNIVERSAL DIGITAL CONTROLLER (UDC-15) FRONT END
/ DEVICE.
/
/ THE FOLLOWING PARAGRAPHS CONTAIN GENERAL EVENT VARIABLE
/ INFORMATION, AND A DESCRIPTION OF THE SERVICE PROVIDED
/ FOR EACH MODULE TYPE SUPPORTED BY THIS HANDLER.
/
/ WITH EACH SERVICE DESCRIPTION IS A "MODULE ADDRESS TABLE"
/ CONSISTING OF A ONE WORD ENTRY FOR EACH MODULE OF THE
/ PARTICULAR TYPE.  THESE WORDS CONTAIN THE MODULE ADDRESSES
/ IN BITS 0-7 (FOR HARDWARE PURPOSES, MODULE ADDRESSES ARE
/ CONSIDERED TO CONSIST OF THREE PARTS: X, BITS 0-2; Y,
/ BITS 3-5; & WD, BITS 6-7).  THESE TABLES ARE CONSTRUCTED  
/ BY EDITING THE HANDLER TASK SOURCE.
/
/ WHEN NECESSARY, A "HISTORY TABLE" OF THE SAME SIZE
/ IMMEDIATELY FOLLOWS THE MODULE ADDRESS TABLE.
/
/ THE TASK IS WRITTEN SUCH THAT THE CODE TO SUPPORT EACH 
/ MODULE TYPE IS INCLUDED ONLY IF ITS MODULE ADDRESS TABLE
/ EXISTS.  THEREFORE, TO ELIMINATE CODE TO SUPPORT NON-
/ EXISTENT MODULES, THE MODULE ADDRESS TABLE MAY BE REMOVED
/ (CHANGED TO A COMMENT).
/
	.EJECT
/ EVENT VARIABLE INFORMATION
/
/ UDC-15 REQUESTS ARE QUEUED FOR A LOGICAL UNIT BY THE
/ 'QUEUE I/O' DIRECTIVE USING THE CAL PARAMETER BLOCK
/ FORMATS DESCRIBED WITH THE REQUEST DESCRIPTIONS.
/
/ IF A REQUEST CANNOT BE QUEUED, THE EVENT VARIABLE, IF
/ SPECIFIED, IS SET TO ONE OF THE FOLLOWING NEGATIVE VALUES
/ TO INDICATE REJECTION AND THE REASON:
/
/	-101 -- LUN DOES NOT EXIST,
/	-102 -- LUN IS NOT ASSIGNED TO A PHYSICAL DEVICE-UNIT,
/	-103 -- HANDLER TASK IS NOT RESIDENT,
/	-777 -- NODE FOR REQUEST IS UNAVAILABLE (EMPTY POOL).
/
/ IF A REQUEST IS QUEUED, THE EVENT VARIABLE, IF SPECIFIED,
/ IS CLEARED (BY THE QUEUE I/O DIRECTIVE) AND LEFT FOR THE
/ HANDLER TASK TO SET NON-ZERO.  IF THE REQUEST IS PERFORMED,
/ THE EVENT VARIABLE (IF SPECIFIED) IS SET POSITIVE UPON
/ SUCCESSFUL COMPLETION.  IF A REQUEST CANNOT BE PERFORMED,
/ THE EVENT VARIABLE (IF SPECIFIED) IS SET TO ONE OF THE
/ FOLLOWING NEGATIVE VALUES TO INDICATE FAILURE AND THE CAUSE:
/
/	  -6 -- ILLEGAL REQUEST FUNCTION,
/	 -30 -- OUT-OF-PARTITION TRANSFER (NORMAL MODE),
/	 -70 -- INVALID PARAMETER,
/	 -71 -- BUFFER CONNECT OR DISCONNECT ERROR.
/
	.EJECT
/ HANDLER INFORMATION REQUEST
/
/ THIS REQUEST IS TO PERMIT A REQUESTOR TO DETERMINE THE NAME
/ AND BASIC CAPABILITIES OF AN I/O HANDLER TASK THAT IS ASSIGNED
/ TO A LOGICAL UNIT.  A THREE-WORD CAL PARAMETER BLOCK OF THE
/ FOLLOWING FORMAT IS USED:
/
/	(0)  3600 (OCTAL FUNCTION CODES),
/	(1)  EVENT VARIABLE ADDRESS,
/	(2)  LOGICAL UNIT NUMBER.
/
	.EJECT
/ ANALOG OUTPUT -- A633 MODULES
/
/ THIS MODULE-TYPE IS SERVICED BY A REQUEST TO SET AN
/ INDICATED ANALOG OUTPUT CHANNEL TO A VOLTAGE PROPOR-
/ TIONAL TO AN INDICATED BINARY INTEGER (0-1023 FOR ZERO
/ TO TEN VOLTS).  THE CHANNELS ARE NUMBERED FROM ZERO,
/ STARTING WITH THE FIRST MODULE LISTED BELOW.  A FIVE-
/ WORD CAL PARAMETER BLOCK OF THE FOLLOWING FORMAT IS USED:
/
/	(0)  6700 (OCTAL FUNCTION CODES),
/	(1)  EVENT VARIABLE ADDRESS,
/	(2)  LOGICAL UNIT NUMBER,
/	(3)  ANALOG CHANNEL NUMBER,
/	(4)  OUTPUT VOLTAGE MAGNITUDE.
/
/ MODULE ADDRESS TABLE FOR TYPE A633
/
A633AT	440000	/MODULE ADDRESS TABLE
A633HT=.	/HISTORY TABLE (NONE UESD)
/
	.EJECT
/ SINGLE-SHOT DIGITAL OUTPUT -- M687 & M807 MODULES
/
/ THESE MODULE-TYPES ARE SERVICED BY A REQUEST TO PULSE AN
/ INDICATED DIGITAL OUTPUT POINT.  THE OUTPUT POINTS ARE
/ NUMBERED FROM ZERO, STARTING WITH THE FIRST CHANNEL ON
/ THE FIRST MODULE LISTED BELOW.  A FOUR-WORD CAL PARAMETER
/ BLOCK OF THE FOLLOWING FORMAT IS USED:
/
/	(0)  6000 (OCTAL FUNCTION CODES),
/	(1)  EVENT VARIABLE ADDRESS,
/	(2)  LOGICAL UNIT NUMBER,
/	(3)  POINT NUMBER.
/
/ MODULE ADDRESS TABLE FOR TYPES M687, & M807
/
M687AT	442000	/MODULE ADDRESS TABLE
	444000
M687HT=.	/HISTORY TABLE (NONE USED)
/
	.EJECT
/ LATCHING DIGITAL OUTPUT -- M685, M803, OR M805 MODULES
/
/ THIS MODULE-TYPE IS SERVICED BY A REQUEST TO SET AN
/ AN INDICATED DIGITAL OUTPUT POINT TO AN INDICATED
/ LOGICAL VALUE (POLARITY).  THE POINTS ARE NUMBERED
/ FROM ZERO, STARTING WITH THE FIRST CHANNEL ON THE
/ FIRST MODULE LISTED BELOW.  A FIVE-WORD CAL PARAMETER
/ BLOCK OF THE FOLLOWING FORMAT IS USED:
/
/	(0)  6100 (OCTAL FUNCTION CODES),
/	(1)  EVENT VARIABLE ADDRESS,
/	(2)  LOGICAL UNIT NUMBER,
/	(3)  POINT NUMBER,
/	(4)  LOGICAL VALUE (-1:TRUE::0:FALSE).
/
/ MODULE ADDRESS TABLE FOR TYPES M685, M803, & M805
/
M685AT	772000	/MODULE ADDRESSES TABLE
	774000
M685HT	.BLOCK .-M685AT	/HISTORY TABLE
/
	.EJECT
/ CONTACT INTERRUPT SERVICE -- W733 MODULES
/
/ INTERRUPT CAUSED INPUT FROM INTERRUPT MODULES IS SERVICED
/ BY TWO REQUESTS.  ONE WHICH "CONNECTS" DIGITAL INPUT TO A
/ CIRCULAR BUFFER, AND ANOTHER WHICH "DISCONNECTS" DIGITAL
/ INPUT FROM A CIRCULAR BUFFER.
/
/ A SIX-WORD CAL PARAMETER BLOCK OF THE FOLLOWING FORMAT
/ IS USED TO CONNECT A CIRCULAR BUFFER:
/
/	(0)  7000 (OCTAL FUNCTION CODES),
/	(1)  EVENT VARIABLE ADDRESS,
/	(2)  LOGICAL UNIT NUMBER,
/	(3)  TRIGGER EVENT VARIABLE ADDRESS,
/	(4)  ADDRESS OF TOP OF CIRCULAR BUFFER,
/	(5)  ADDRESS OF BOTTOM OF CIRCULAR BUFFER.
/
/ A THREE-WORD CAL PARAMETER BLOCK OF THE FOLLOWING FORMAT
/ IS USED TO DISCONNECT A CIRCULAR BUFFER:
/
/	(0)  7100 (OCTAL FUNCTION CODES),
/	(1)  EVENT VARIABLE ADDRESS,
/	(2)  LOGICAL UNIT NUMBER.
/
/ WHEN THE HANDLER TASK LOADS, PART OF ITS INITIALIZATION
/ CONSISTS OF READING ALL CONTACT SENSE MODULES, INITIALIZING 
/ THE "HISTORY TABLE", AND ENABLING UDC IMMIEDIATE INTERRUPTS.
/
/ WHENEVER AN INTERRUPT ACCOMPANIED BY A CHANGE OF STATE
/ (NON-ZERO COS GATES OUTPUT), THE HISTORY TABLE IS UPDATED;
/ AND IF AN NON-FULL CIRCULAR BUFFER IS CONNECTED TO RECEIVE
/ DIGITAL INPUT, A FOUR WORD ENTRY OF THE FOLLOWING FORMAT IS
/ MADE:
/
/	(0)  ENTRY EXISTENCE INDICATOR (+1 OR -N),  ***
/	(1)  MODULE NUMBER (0-255),
/	(2)  COS GATES OUTPUT (BITS 0-15),
/	(3)  DATA WORD (BITS 0-15).
/
/ THE REQUESTOR IS EXPECTED TO CLEAR (ZERO) "ENTRY EXISTENCE
/ INDICATORS" WHEN DATA HAS BEEN REMOVED FROM THE CIRCULAR
/ CIRCULAR BUFFER.  IF A FULL BUFFER IS FOUND, DATA IS DIS-
/ CARDED (HISTORY TABLE IS UPDATED) AND A DATA OVER-RUN COUNT
/ IS INCREMENTED.  
/
/ *** WHEN DATA OVER-RUNS OCCUR, THE 2'S COMP OF THE NUMBER OF
/ TIMES DATA WAS DISCARDED IS SET IN THE EXISTENCE INDICATOR
/ OF THE FIRST DATA TRANSFER TO THE CIRCULAR BUFFER ("-N").
/ OTHERWISE, THE INDICATOR IS SET TO ONE (+1).
/
/ THE INITIAL ENTRY IN A CIRCULAR BUFFER IS MADE AT THE
/ LOWEST ADDRESS, ADN IT IS FILLED IN ORDER OF INCREASING 
/ ADDRESSES.  THE REQUESTOR MUST MAINTAIN RECORD OF  WHERE
/ TO FIND THE NEXT ENTRY IN THE BUFFER.
/
/ MODULE ADDRESS TABLE FOR TYPE W733
/
W733AT	770000	/MODULE ADDRESS TABLE
	776000
W733HT	.BLOCK .-W733AT	/HISTORY TABLE
/
	.EJECT
/ CONTACT SENSE SERVICE -- W731 MODULES (ALSO W733)
/
/ A CONTACT SENSE MODULE (OR A CONTACT INTERRUPT MODULE) IS
/ SERVICED BY A REQUEST TO READ THE MODULE DATA INTO THE
/ LOW ORDER (2-17) BITS OF AN INDICATED WORD.  THE MODULES
/ ARE NUMBERED FROM ZERO, STARTING WITH THE FIRST MODULE
/ LISTED BELOW.  A FIVE-WORD CAL PARAMETER BLOCK OF THE 
/ FOLLOWING FORMAT IS USED:
/
/	(0)  7400 (OCTAL FUNCTION CODES),
/	(1)  EVENT VARIABLE ADDRESS,
/	(2)  LOGICAL UNIT NUMBER,
/	(3)  MODULE NUMBER,
/	(4)  ADDRESS OF WORD IN WHICH TO RETURN DATA.
/
/ MODULE ADDRESS TABLE FOR TYPES W731 & W733
/
W731AT	770000	/MODULE ADDRESS TABLE
	776000
W731HT=.	/HISTORY TABLE (NONE USED)
/
	.EJECT
/ SYMBOL DEFINITIONS
/
X10=10		/AUTO-INCREMENT REG 10
X11=11		/AUTO-INCREMENT REG 11
R1=101		/RE-ENTRANT REGISTER ONE
R2=102		/RE-ENTRANT REGISTER TWO
R3=103		/RE-ENTRANT REGISTER THREE
R4=104		/RE-ENTRANT REGISTER FOUR
NADD=107	/NODE ADDITION ROUTINE ENTRY POINT
SNAM=123	/NAME SCAN ROUTINE ENTRY POINT
POOL=240	/LISTHEAD FOR POOL OF EMPTY NODES
PDVL=252	/LISTHEAD FOR PHYSICAL DEVICE LIST
DQRQ=337	/DE-QUEUE REQUEST ENTRY POINT
VAJX=342	/VERIFY & ADJUST ENTRY POINT
IOCD=345	/DECLARE I/O REQUEST COMPLETE ENTRY POINT
D.TG=10		/POSITION OF TRIGGER EVENT VARIABLE IN PDVL NODE
DMTQ=361	/CLEAN UP QUEUE ROUT. ENTRY PT. (FOR ABORT.)
ECLA=641000	/EAE CLA INSTRUCTION
.INH=705522	/INHIBIT INTERRUPTS
.ENB=705521	/ENABLE INTERRUPTS
UMOD=701001	/SELECT UDC MODE
USINT=702004	/* SELECT INTERRUPT MODE PER AC 16-17
ULA=702024	/* LOAD ADDRESS REGISTER FROM AC 0-7
ULD=701064	/LOAD DATA FROM AC 0-15 TO MODULE PER ADR REG
URRA=701052	/READ IMMEDIATE ADDRESS & GERNERIC CODE
		/INTO AC 0-11 AND LOAD ADR REG FROM AC 0-7
URD=702032	/* READ DATA INTO AC FROM MODULE PER ADR REG
USNB=702041	/* SKIP IF SCANNER NOT BUSY
ULPS=701044	/LOAD PREVIOUS STATUS FROM AC 0-15
URCG=701072	/READ COS GATES
		/"*" INDICATES MODE SELECT IS REQUIRED, AND
		/THE SYMBOL "/*/" FLAGS INSTRUCTIONS THAT
		/MUST BE ADJACENT TO EACH OTHER.
/
	.EJECT
/ HANDLER INITIALIZATION
/
START	LAC	(PDVL)	/SCAN PHYSICAL DEVICE LIST FOR FOR NODE
	DAC*	(R1)	/FOR THIS DEVICE.
	LAC	(DNAM)
	DAC*	(R2)
	JMS*	(SNAM)	/(R1, R2, R6, X17, XR, & AC ARE ALTERED)
			/NODE FOUND?
	CAL	(10)	/NO -- EXIT
	DAC	PDVNA	/SAVE PDVL NODE ADDRESS
	AAC	+D.TG	/AND TRIGGER EVENT VARIABLE ADDRESS
	DAC	PDVTA	/TRIGGER EVENT VARIABLE ADDRESS ADDRESS.
	CAL	CCPB	/CONNECT INTERRUPT LINE
	LAC	TG	/CONNECT OKAY?
	SPA
	CAL	(10)	/NO -- EXIT
	DZM	TG	/YES -- CLEAR TRIGGER EVENT VARIABLE AND
	LAC	(TG)	/SET TRIGGER EVENT VARIABLE ADDRESS IN
	DAC*	PDVTA	/PHYSICAL DEVICE NODE
	AND	(070000)/DETERMINE "XR-ADJ"
	TCA
	DAC	XADJ
/
	.IFDEF	M685AT	/IF M685 MODULE SERVICE, INITIALIZE
			/ALL POINTS FALSE.
/
	LAC (M685HT-M685AT) /SETUP LR & XR TO SCAN ADDRESS 
	PAL		/AND HISTORY TABLES.
	CLX
/
M685I2	LAC	M685AT,X /LOAD ADDRESS REGISTER FROM ADR TBL
	UMOD		/*/
	ULA		/*/
/
	CLA		/LOAD ZERO DATA & WRITE HISTORY TBL WORD
	ULD
	DAC	M685HT,X
/
	AXS	+1	/CONTINUE THRU ENTIRE ADR TBL
	JMP	M685I2
/
	.ENDC
/
	JMP	WFTGR	/INITIALIZATION COMPLETE -- WAIT FOR TRIGGER
/
DNAM	.SIXBT "UD@@@@"	/DEVICE NAME (HANDLER TASK NAME IS "UD....")
/
	.EJECT
/ WAIT FOR TASK TO BE TRIGGERED (BY 'QUEUE I/O' DIRECTIVE)
/ TO SIGNAL THAT A REQUEST HAS BEEN QUEUED.
/
WFTGR	CAL	WFTCPB	/WAIT FOR TRIGGER EVENT VARIABLE TO BE SET
/
/ THE TASK HAS BEEN TRIGGERED -- PICK A REQUEST FROM QUEUE (IF ANY)
/
	DZM	TG	/CLEAR TRIGGER
/
PQ	LAC	PDVNA	/DE-QUEUE A REQUEST
	DAC*	(R1)
	JMS*	(DQRQ)	/(R1, R2, R4, R5, R6, XR, & AC ARE ALTERED)
			/WAS A REQUEST FOUND?
	JMP	WFTGR	/NO -- WAIT FOR TRIGGER
	DAC	RNA	/YES -- SAVE ADDRESS OF REQUEST NODE
	TAD	XADJ	/SETUP XR TO ACCESS NODE
	PAX
	LAC	6,X	/SAVE [REQUESTOR'S] EVENT VARIABLE ADDRESS (17-BITS)
	SNA		/(IF NONE SPECIFIED USE POINTER AS EVENT VARIABLE)
	LAC	(EVA)
	DAC	EVA
	LAC	5,X	/FETCH CAL FUNCTION CODE
	AND	(777)
	.IFDEF	A633AT	/TEST FOR A633 SERVICE
	SAD	(067)
	JMP	A633
	.ENDC
	.IFDEF	M687AT	/TEST FRO M687, & M807 SERVICE
	SAD	(060)
	JMP	M687
	.ENDC
	.IFDEF	M685AT	/TEST FOR M685, M803, & M805 SERVICE
	SAD	(061)
	JMP	M685
	.ENDC
	.IFDEF	W731AT	/TEST FOR W731 SERVICE
	SAD	(074)
	JMP	W731
	.ENDC
	.IFDEF	W733AT	/TEST FOR W733 SERVICE
	SAD	(070)
	JMP	CTDI
	SAD	(071)
	JMP	DFDI
	.ENDC
	SAD	(036)	/TEST FOR HANDLER INFO
	JMP	HINF
	SAD	(777)	/TEST FOR EXIT REQUEST
	JMP	DAEX
	SAD	(017)	/ABORT REQUEST.
	JMP	UDABRT	/YES.
ERR6	LAW	-6	/UNIMPLIMENTED FUNCTION -- SET
	JMP	FINIS	/EVENT VARIABLE TO -6
/
	.EJECT
/ SERVICE FOR ANALOG OUTPUT -- MODULE TYPE A633
/
	.IFDEF	A633AT
/
A633	CLQ!CLL		/FORM UDC DATA OUTPUT WORD IN MQ
	LAC	10,X	/AND MODULE NUMBER IN XR.
	LRS	12	/(VOLTS IN BITS 2-11)
	SZA		/ERR 70 IF VOLTS OUT OF RANGE: 0-1023
	JMP	ERR70
	LAC	7,X	/(CHANNEL OF MODULE IN BITS 0-1)
	LRS	2
	PAX
	TAD (A633AT-A633HT)/ERR 70 IF CHANNEL NUMBER IS BEYOND
	SMA		/DEFINED MODULES
	JMP	ERR70
/
	LAC	A633AT,X /SET 'UDCMOD' FROM MODULE ADDRESS
	DAC	UDCMOD	/TABLE, AND 'UDCDOW' FROM MQ.
	LACQ
	DAC	UDCDOW
/
	JMS	UDCOUT	/OUTPUT 'UDCDOW' TO MODULE 'UDCMOD'
/
	JMP	DONE	/REQUEST COMPLETED
/
	.ENDC
/
	.EJECT
/ SERVICE FOR SINGLE-SHOT DIGITAL OUTPUT -- MODULE TYPES M687 & M807.
/
	.IFDEF	M687AT
/
M687	LAC	7,X	/FETCH DIGITAL POINT NUMBER, AND
	CLL		/SET MQ TO BIT-OF-MODULE, & XR TO
	LRS	4	/MODULE-NUMBER
	PAX
	TAD (M687AT-M687HT)/ERR 70 IS POINT NUMBER IS BEYOND
	SMA		/DEFINED MODUELS.
	JMP	ERR70
	LAC	M687AT,X /SET 'UDCMOD' FROM MODULE ADR TABLE
	DAC	UDCMOD
/
	ECLA!LLS 4	/DETERMINE DATA OUTPUT WORD FROM
	XOR	(LRS 00)/BIT-OF-MODULE.
	DAC	.+3
	CLA!STL
	RAR
	XX
	DAC	UDCDOW
/
	JMS	UDCOUT	/OUTPUT 'UDCDOW' TO MODULE 'UDCMOD'
/
	JMP	DONE	/REQUEST COMPLETED
/
	.ENDC
/
	.EJECT
/ SERVICE FOR LATCHING DIGITAL OUTPUT -- MODULE TYPE M685
/
	.IFDEF	M685AT
/
M685	LAC	10,X	/FETCH LOGICAL VALUE
	SPA		/ZERO (TRUE) OR MINUS ONE (FALSE)?
	SAD	(-1)
	SKP
	JMP	ERR70	/NO -- ERR 70
	DAC	TEMP1	/YES -- SAVE POLARITY IN 'TEMP1'
/
	LAC	7,X	/FETCH DIGITAL POINT NUMBER, AND 
	CLL		/SET MQ TO BIT-OF-MODULE & XR TO
	LRS	4	/MODULE NUMBER.
	PAX
	TAD (M685AT-M685HT)/ERR 70 IF POINT NUMBER IS BEYOND 
	SMA		/DEFINED MODULES.
	JMP	ERR70
	LAC	M685AT,X /SET 'UDCMOD' FROM MODULE ADR TABLE
	DAC	UDCMOD
/
	ECLA!LLS 4	/DETERMINE BIT MASK & SAVE IN 'TEMP2'
	XOR	(LRS 00)
	DAC	.+3
	CLA!STL
	RAR
	XX
	DAC	TEMP2
/
	CMA		/CLEAR BIT IN HISTORY TABLE
	AND	M685HT,X
	DAC	M685HT,X
/
	LAC	TEMP1	/SET BIT IN HISTORY TABLE TO INDICATED
	AND	TEMP2	/POLARITY, AND SET 'UDCDOW' FROM HISTORY
	XOR	M685HT,X /TABLE.
	DAC	M685HT,X
	DAC	UDCDOW
/
	JMS	UDCOUT	/OUTPUT 'UDCODW' TO MODULE 'UDCMOD'
/
	JMP	DONE	/REQUEST COMPLETED
/
	.ENDC
/
	.EJECT
/ CONTACT INTERRUPT SERVICE -- MODULE TYPE W733
/
	.IFDEF	W733AT
/
/ CTDI -- CONNECT TASK'S CIRCULAR BUFFER TO RECEIVE DIGITAL 
/ INPUT FROM CONTACT SENSE MODULES.
/
CTDI	LAC	RNA	/SETUP X10 TO FETCH PARAMETERS FROM
	AAC	+6	/REQUEST NODE.
	DAC*	(X10)
/
	LAC	(+1)	/SETUP R4 & R2 FOR 'VAJX', AND XR TO
	DAC*	(R4)	/ACCESS REQUEST NODE.
	LAC	RNA
	DAC*	(R2)
	TAD	XADJ
	PAX
/
	LAC	DICBID	/IS A BUFFER ALREADY CONNECTED?
	SZA
	JMP	ERR71	/YES -- ERR 71
	LAC	2,X	/NO -- WAS I/O REQUEST TASK ISSUED?
	SNA
	JMP	ERR71	/NO -- ERR 71
	DAC	DIRSTL	/YES -- SAVE REQUESTOR'S STL NODE ADR (ID)
	DAC	DIRPBP	/ALSO SAVE PART. BLK. PTR. FOR IOCD IN DAEX.
/
	LAC*	X10	/VERIFY & ADJUST (TO 17-BITS) REQUESTOR'S
	DAC*	(R3)	/TRIGGER EVENT VARIABLE ADDRESS
	JMS*	(VAJX)	/(R3, R5, XR, & AC ARE ALTERED) ADR OKAY?
	JMP	ERR30	/NO -- ERR 30
	LAC*	(R3)	/YES -- SAVE TRIGGER EVENT VARIABLE ADR
	DAC	UDITAD
/
	LAC*	X10	/VERIFY & ADJUST (TO 17-BITS) TOP (LOW)
	DAC*	(R3)	/ADDRESS OF CIRCULAR BUFFER
	JMS*	(VAJX)	/(R3, R5, XR, & AC ARE ALTERED) ADR OKAY?
	JMP	ERR30	/NO -- ERR 30
	LAC*	(R3)	/YES -- SAVE ADDRESS, AND SET 'UDICBX'.
	DAC	DICBP1
	DAC	UDICBX
/
	LAC*	X10	/VERIFY & ADJUST (TO 17-BITS) BOTTOM (HIGH)
	DAC*	(R3)	/ADDRESS OF CIRCULAR BUFFER
	JMS*	(VAJX)	/(R3, R5, XR, & AC ARE ALTERED) ADR OKAY?
	JMP	ERR30	/NO -- ERR 30
	LAC*	(R3)	/YES -- SAVE ADDRESS & DETERMINE BUFFER SIZE
	IAC
	DAC	DICBP2
	TCA
	TAD	DICBP1
	SNA		/ERR 30 IF SIZE IS LESS THAN FOUR
	JMP	ERR30	/WORDS, OR NOT A MULTIPLE OF FOUR
	AND	(003)	/WORDS
	SZA
	JMP	ERR30
/
	LAC	DIRSTL	/ALL CHECKS OKAY -- CONNECT BUFFER TO
	DAC	DICBID	/RECEIVE DIGITAL INPUT
	LAC	DIRPBP	/STORE PART. BLK. PTR. FOR DAEX ROUT.
	DAC	DICPBP
/
	LAC (W733HT-W733AT) /SETUP LR & XR TO SCAN ADDRESS
	PAL		/AND HISTORY TABLES.
	CLX
/
CTDI2	LAC	W733AT,X /LOAD ADDRESS REGISTER FROM MODULE
	UMOD		/*/ADDRESS TABLE, READ DATA FROM 
	ULA		/*/ADDRESSED MODULE, AND WRITE HISTORY 
	URD		/*/TABLE WORD.
	DAC	W733HT,X
/
	AXS	+1	/CONTINUE THRU ENTIRE ADR TBL
	JMP	CTDI2
/
	LAC	(002)	/ENABLE UDC IMMEDIATE INTERRUPT
	UMOD		/*/
	USINT		/*/
/
	LAW	-1	/SET 'XIOCD' TO NOT CALL 'IOCD'
	DAC	XIOCD
/
	JMP	DONE	/REQUEST COMPLETED
/
/ DFDI -- DISCONNECT TASK'S CIRCULAR BUFFER FROM DIGITAL INPUT
/
DFDI	LAC	RNA	/SETUP XR TO ACCESS REQUEST NODE
	TAD	XADJ
	PAX
/
	LAC	2,X	/WAS REQEST TASK ISSUED?
	SNA
	JMP	ERR71	/NO -- ERR 71
	SAD	DICBID	/YES -- IS REQUESTOR'S CIRCULAR BUFFER
	SKP		/CONNECTED FOR DIGITAL INPUT?
	JMP	ERR71	/NO -- ERR 71
	DZM	DICBID	/YES -- DISCONNECT. 
	DZM	DICPBP	/CLEAR PART. BLK. PTR.
	CLA		/DISABLE UDC INTERRUPTS.
	UMOD		/*/
	USINT		/*/
/
	LAC	(+1)	/SET 'XIOCD' TO CALL 'IOCD' TWICE
	DAC	XIOCD
/
	JMP	DONE	/REQUEST COMPLETED
/
DICBP1	0	/TOP ADDRESS OF CIRCULAR BUFFER
DICBP2	0	/BOTTOM ADDRESS OF CIRCULAR BUFFER PLUS ONE
DIRSTL	0	/REQUESTOR'S STL NODE ADR
DICBID	0	/CIRCULAR BUFFER ID -- THE STL NODE ADR OF
		/A TASK CONTAINING A BUFFER CONNECTED TO
		/RECIEVE DIGITAL INPUT, OR ZERO IF NO BUFFER
		/IS CONNECTED.
DICPBP	0	/PARTITION BLOCK PTR. FOR TASK REQ. CONNECT.  
		/ZERO IF TASK REQ. CONNECT IS AN EXEC. MODE TASK, OR
		/NO BUFFER IS CONNECTED TO ANY TASK.  SAVING THIS
		/PTR. IS NECCESSARY IN ORDER THAT THE TRANSF. PENDING
		/COUNT CAN BE DECREMENTED IN THE EVENT OF AN
		/EXIT REQ. WITH A TASK (NORMAL MODE) CONNECTED.
/
/ UDC INTERRUPT SERVICE ROUTINE
/
UDCINT	0
	DBA		/DISABLE BANK ADDRESSING, AND
	DAC	UDIACB	/SAVE AC, XR, & LR.
	PXA
	DAC	UDIXRB
	PLA
	DAC	UDILRB
/
	LAC (W733HT-W733AT)/SETUP LR & XR TO SCAN MODULE 
	PAL		/ADDRESS TABLE.
	CLX
/
	URRA		/READ IMMEDIATE ADDRESS INTO ADR REG & AC
	AND	(776000)
/
	SAD	W733AT,X /SCAN MODULE ADR TBL TO MATCH 
	JMP	.+4	/ADDRESS READ FROM "IMMEDIATE 
	AXS	+1	/SCAN REGISTER".  IF NONE FOUND,
	JMP	.-3	/IGNORE INTERRUPT.  IF FOUND,
	JMP	UDIEXT	/LEAVE MODULE NUMBER IN XR.
/
	PXA		/SAVE MODULE NUMBER
	DAC	UDIMNB
/
	LAC	W733HT,X /LOAD PREVIOUS DATA (FROM HISTORY 
	ULPS		/TABLE), READ COS GATES, AND SAVE
	URCG		/COS GATES OUTPUT.
	DAC	UDICGB
/
	UMOD		/*/UPDATE HISTORY TABLE AND SAVE
	URD		/*/DATA WORD (POINT POLARITIES).
	DAC	W733HT,X
	DAC	UDIDWB
/
	LAC	UDICGB	/ZERO COS GATE OUT (NO CHANGE-OF-STATE)?
	SNA
	JMP	UDIEXT	/YES -- DO NOT RETURN DATE
	LAC	DICBID	/NO -- IS A BUFFER CONNECTED?
	SPA!SNA
	JMP	UDIEXT	/NO -- DO NOT RETURN DATA
	LAC	UDICBX	/YES -- SETUP XR TO ACCESS NEXT 
	TAD	XADJ	/SLOT (4 WDS) IN CIRCULAR BUFFER.
	PAX
	LAC	0,X	/IS SLOT EMPTY?
	SNA
	JMP	UDI2
	ISZ	UDIORC	/NO -- DATA OVERRUN, INCREMENT 'UDIORC'
	JMP	UDIEXT	/AND DO NOT RETURN DATA
	ISZ	UDIORC	/(EXTRA COUNT TO AVOUD ZERO AFTER
	JMP	UDIEXT	/2**18 OVER-RUNS)
UDI2	LAC	UDIORC	/YES -- FILL SLOT & CLEAR OVER-RUN COUNT
	SNA		/  WD. 0 -- SLOT FILLED IND (+1 OR -'UDIOCRC')
	LAW	-1	/  WD. 1 -- MODULE NUMBER
	TCA		/  WD. 2 -- COS GATES OUTPUT
	DAC	0,X	/  WD. 3 -- DATA WORD (POINT POLARITIES)
	LAC	UDIMNB
	DAC	1,X
	LAC	UDICGB
	DAC	2,X
	LAC	UDIDWB
	DAC	3,X
	DZM	UDIORC
/
	LAC	UDICBX	/ADVANCE CIRCULAR BUFFER INDEX
	AAC	+4
	SAD	DICBP2
	LAC	DICBP1
	DAC	UDICBX
/
	LAC	UDITAD	/SET TRIGGER EVENT VARIABLE, AND
	TAD	XADJ	/DECLARE A SIGNIFICANT EVENT.
	PAX
	LAC	(+1)
	DAC	0,X
	LAC	(401000)
	ISA
/
UDIEXT	LAC	(002)	/SELECT IMMEDIATE INTERRUPT
	UMOD		/*/
	USINT		/*/
/
	LAC	UDILRB	/RESTORE LR, XR, & AC
	PAL
	LAC	UDIXRB
	PAX
	LAC	UDIACB
/
	DBR		/RETURN TO INTERRUPTED PROGRAM
	JMP*	UDCINT
/
UDIACB	0	/AC BUFFER
UDIXRB	0	/XR BUFFER
UDILRB	0	/LR BUFFER
UDIMNB	0	/MODULE NUMBER BUFFER
UDICGB	0	/COS GATES OUTPUT BUFFER
UDIDWB	0	/DATA WORD BUFFER
/
UDICBX	0	/CIRCULAR BUFFER INDEX
UDITAD	0	/REQUESTOR'S TRIGGER EVENT VARIABLE ADDRESS
UDIORC	0	/DATA OVER-RUN COUNT
/
	.ENDC
/
	.EJECT
/ CONTACT SENSE SERVICE -- MODULE TYPE W731
/
W731	LAC	7,X	/FETCH MODULE NUMBER FROM REQUEST
	PAL		/NODE, AND SAVE IN LR.
	SPA		/ERR 70 IF MODULE NUMBER IS 
	JMP	ERR70	/BEYOND EXISTENT MODULES.
	TAD (W731AT-W731HT)
	SMA
	JMP	ERR70
/
	LAC	RNA	/VERIFY AND ADJUST (TO 17-BITS) THE
	DAC*	(R2)	/ADDRESS AT WHITCH DATA WORD IS TO
	LAC	10,X	/BE STORED.
	DAC*	(R3)
	LAC	(+1)
	DAC*	(R4)
	JMS*	(VAJX)	/(R3, R5, XR, & AC ARE ALTERED) ADR OKAY?
	JMP	ERR30	/NO -- ERR 30
	LAW	-1	/YES -- SETUP X10 TO RETURN DATA WORD
	TAD*	(R3)
	DAC*	(X10)
/
	CLA		/DISABLE UDC INTERRUPTS
	UMOD		/*/
	USINT		/*/
/
	UMOD		/*/LOOP IF SCANNER IS BUSY
	USNB		/*/
	JMP	.-2
	PLX		/CONVERT MODULE NUMBER (IN LR) TO
	LAC	W731AT,X /MODULE ADDRESS, READ MODULE, AND
	UMOD		/*/RETURN DATA WORD TO REQUESTOR
	ULA		/*/IN BITS 2-17 OF THE INDICATED
	URD		/*/WORD.
	RCR
	RCR
	DAC*	X10
/
	LAC	DICBID	/IS A BUFFER CONNECTED FOR DIGITAL INPUT?
	SNA
	JMP	DONE	/NO -- REQUEST COMPLETED
	LAC	(002)	/YES -- RE-ENABLE IMMEDIATE INTERRUPT
	UMOD		/*/
	USINT		/*/
	JMP	DONE	/REQUEST COMPLETED
/
	.ENDC
/
	.EJECT
/ HANDLER INFORMATION
/
HINF	LAC	(300017)	/RETURN INFO IN EVENT VARIABLE
	JMP	FINIS
/
/ DONE -- REQUEST SUCCESSFULLY COMPLETED, SET REQUESTOR'S EVENT
/ VARIABLE TO ONE (+1), AND PROCEDE TO NEXT REQUEST.
/
DONE	LAC	(+1)
	JMP	FINIS
/
/ ERR30 -- OUT-OF PARTITION PARAMETER (NORMAL MODE ONLY), SET
/ REQUESTOR'S EVENT VARIABLE TO -30 AND PROCEDE TO NEXT REQUEST.
/
ERR30	LAW	-30
	JMP	FINIS
/
/ ERR70 -- INVALID PARAMETER IN CAL PARAMETER BLOCK OR CONTROL
/ TABLE, SET REQUESTOR'S EVENT VARIABLE TO -70 AND PROCEDE T0
/ NEXT REQUEST.
/
ERR70	LAW	-70
	JMP	FINIS
/
/ ERR71 -- BUFFER ALREADY CONNECTED, OR BUFFER CONNECT OR
/ DISCONNECT REQUEST NOT TASK ISSUED (QUEUE I/O DIRECTIVE
/ ISSUED FROM AN INTERRUPT SERVICE ROUTINE), SET REQUESTOR'S
/ EVENT VARIABLE TO -71 AND PROCEDE TO NEXT REQUEST.
/
ERR71	LAW	-71
	JMP	FINIS
/
/ UDCOUT -- SUBROUTINE TO OUTPUT THE DATA WORD IN 'UDCDOW' TO
/ THE MODULE INDICATED BY 'UDCMOD'.
/
UDCOUT	0
	CLA		/DISABLE UDC IMMEDIATE INTERRUPT
	UMOD		/*/
	USINT		/*/
/
	UMOD		/*/LOOP IF SCANNER BUSY
	USNB		/*/
	JMP	.-2
/
	LAC	UDCMOD	/SET MODLUE ADDRESS IN ADR REG
	UMOD		/*/
	ULA		/*/
	LAC	UDCDOW	/OUTPUT DATA TO MODULE
	ULD
/
	LAC	DICBID	/IS A BUFFER CONNECTED FOR DIGITAL INPUT?
	SNA
	JMP*	UDCOUT	/NO -- EXIT SUBROUTINE
	LAC	(002)	/YES -- RE-ENABLE UDC IMMEDIATE
	UMOD		/*/INTERRUPT & EXIT SUBROUTINE
	USINT		/*/
	JMP*	UDCOUT
/
UDCMOD	0	/MODULE ADDRESS (BITS 0-7)
UDCDOW	0	/UDC DATA OUTPUT WORD (BITS 0-15)
/
/ FINISH REQUEST BY SETTING THE EVENT VARIABLE (IF SPECIFIED) TO
/ THE CONTENTS OF AC, DECLARING A SIGNIFICANT EVENT, RETURNING
/ THE REQUEST NODE TO THE POOL, AND DECLARING 'I/O COMPLETED'.
/
FINIS	PAL		/SET EVENT VARIABLE (IF SPCECIFIED) TO
	LAC	EVA	/CONTENTS OF AC
	TAD	XADJ
	PAX
	PLA
	DAC	0,X
/
	LAC	(401000)/DECLARE A SIGNIFICANT EVENT
	ISA
/
	LAC	RNA	/DECLARE REQUEST COMPLETED (DECREMENT
	DAC*	(R2)	/TRANSFERS PENDING COUNT FOR NORMAL
			/MODE TASKS.
	LAC	XIOCD	/"IOCD" IS CALLED ONCE PLUS THE CONTENTS
	SMA		/OF 'XIOCD', WHICH CONTAINS EITHER: -1, 0,
	JMS*	(IOCD)	/+1 (NORMALLY ZERO).  (R5, XR, & AC ARE
	LAC	XIOCD	/ALTERED.)
	SMA!SZA
	JMS*	(IOCD)
	DZM	XIOCD
/
	LAC	(POOL)	/RETURN REQUEST NODE TO POOL
	DAC*	(R1)	/R2 IS ALREADY SETUP
	JMS*	(NADD)
/
	JMP	PQ	/PICK NEXT REQUEST (IF ANY)
/
XIOCD	0	/COUNT OF EXTRA CALLS TO 'IOCD'.  USED
		/TO CAUSE A TRANSFERS PENDING COUNT BETWEEN
		/THE TIME A "CONNECT" AND "DISCONNECT" (SO
		/THAT I/O RUNDOWN CAN CAUSE A DISCONNECT
		/WHEN NECESSARY).
/
/ DAEX -- DISCONNECT & EXIT
/	-IF A CIRCULAR BUFFER IS CONNECT TO A NORMAL MODE TASK,
/	THE TRANSFERS PENDING COUNT MUST BE DECREMENTED.  THAT IS
/	THE PURPOSE OF DICPBP (SEE COMMENTS ON THIS REG.).  THE EXIT
/	REQ. NODE IS USED TO ALLOW IOCD TO OPERATE SUCCESSFULLY.
/
DAEX	LAC	DICBID	/TASK CONNECTED (TO CIRC. BUFF.)?
	SNA		/NON-ZERO IF CONNECTED.
	JMP	DAEX1	/NO.  BYPASS SETTING UP EXIT REQ. NODE.
	LAC	DICPBP	/YES.  SET WORD 3 OF EXIT REQ. NODE TO
	DAC	3,X	/CONNECTED TASK'S PART. BLK. PTR.
DAEX1	LAC	(POOL)	/RETURN REQUEST NODE TO POOL AND DECR. T.P.C.
	DAC*	(R1)
	LAC	RNA
	DAC*	(R2)
	JMS*	(IOCD)
	JMS*	(NADD)
/
	CAL	DCPB	/DISCONNECT INTERRUPT LINE
/
	ISZ	PDVTA	/CLEAR ASSIGN INHIBIT FLAG & EXIT
	.INH		///
	DZM*	PDVTA	///
	.ENB		///
	CAL	(10)	///
/
	.EJECT
/
/PROCESS ABORT REQ.  IF TASK TO BE ABORTED IS CONNECTED, DISCONNECT IT.
/
UDABRT	LAC	5,X	/ABORT REQ. NODE LUN=0?
	AND	(777000)
	SZA
	JMP	ERR6	/NO.  RETURN -6 EV.
	LAC	DICBID	/YES.  TASK TO BE ABORTED CONNECTED?
	SAD	2,X	/COMPARE STL NODE PTRS.
	JMP	UDABR1	/YES.  GO DISCONNECT.
UDABR2	LAC	PDVNA	/NO.  REMOVE PENDING REQS. FROM TASK TO BE ABORTED'S
	DAC*	(R1)	/QUEUE.
	LAC	RNA	/ABORT REQ. NODE ADDRESS.
	DAC*	(R2)
	JMS*	(DMTQ)
	JMP	DONE	/REQ. FINISHED SUCCESSFULLY
/
UDABR1	DZM	DICBID	/DISCONNECT.
	DZM	DICPBP
	LAC	(1)	/SET SWITCH TO DECRM. T.P.C. TWICE.
	DAC	XIOCD
	JMP	UDABR2	/CLEAN UP QUEUE.
/
XADJ	0	/XR ADJUST FOR CURRENT PAGE
PDVNA	0	/PHYSICAL DEVICE LIST NODE ADDRESS
PDVTA	0	/ADR OF TRIGGER EVENT VARIABLE ADR IN PDVL NODE
RNA	0	/REQUEST NODE ADDRESS
EVA	0	/EVENT VARIABLE ADDRESS
DIRPBP	0	/TEMP. FOR CONNECTED TASK'S PART. BLK. PTR.
/
TEMP1	0
TEMP2	0
/
CCPB	11	/CONNECT CPB
	TG
	31
	UDCINT
/
DCPB	12	/DISCONNECT CPB
	0
	31
	UDCINT
/
WFTCPB	20	/WAIT FOR TRIGGER CPB
	TG
/
TG	0	/TRIGGER EVENT VARIABLE
/
	.END	START
