	.TITLE RDDI - READ UDC DIGITAL INPUT.
/ 
/ 
/                   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
/COPYRIGHT 1971,DIGITAL EQUIPMENT CORP.,MAYNARD, MASS.
/	EDIT #6
/			10-5-71
/			1 MAR 73	T. MURRAY
//CALLING SEQUENCE       CALL CTDI(ILUN,IBUF,ITEV,IEV)
/	JMS* CTDI
/	JMP .+5		/SUBR. RETURN.
/	ADDR OF LUN	/INTEGER.
/	ADDR OF ARRAY NAME	/INTEGER
/	ADDR OR ARRAY SIZE	/INTEGER
/	ADDR. OF TRIGG. EV. VAR.	/INTEGER
/	ADDR. OF EVENT VAR.	/INTEGER (OPTIONAL)
/	NEXT INSTRUCTION.
/
/CALLING SEQUENCE		CALL RDDI(N,L,IOVCT)
/	JMS* RDDI
/	JMP .+4		/SUBR. RETURN.
/	ADDR OF PT. NUMBER	/INTEGER
/	ADDR. OF LOGICAL SWITCH	/LOGICAL
/	ADDR OF OVERCOUNT	/INTEGER(OPTIONAL)
/	NEXT INSTRUCTION.
/
/CALLING SEQUENCE	CALL DFDI (ILUN)
/	JMS* DFDI
/	JMP .+2		/SUBR. RETURN.
/	ADDR. OF LUN	/INTEGER
/	NEXT INSTRUCTION.
/
/REGISTER AND INSTRUCTION DEFINITIONS:
/
X10=10		/AUTO-INCR. 10
/
/CTDI(ILUN,IBUF,ITEV,IEV)-CONNECT UDC ON LUN=ILUN TO DIGITAL INPUT.
/INITIALIZES UDC HANDLER TASK TO SEND DIGITAL INPUTS TO ARRAY
/IBUF(MUST BE INTEGER AND MULTIPLE OF 4 WORDS LONG).  MUST BE ISSUED
/BEFORE ANY CALL TO RDDI.
/
/DFDI(ILUN)-DISCONNECT UDC ON LUN=ILUN FROM DIGITAL INPUT.
/
/RDDI(N,L,IOVCT)-READ DIGITAL INPUT FROM IBUF ARRAY INITIALIZED IN
/PRIOR CALL TO CTDI.  IBUF IS TREATED AS A CIRCULAR BUFFER AND IS SCANNED
/SEQUENTIALLY FOR A TRUE CHANGE OF STATE. THE PT. NUMBER
/CORRESPONDING TO THIS CHANG IS RETURNED IN N.  LOGICAL TRUE IS
/RETURNED IN L IF CHANGE OF STATE RESULTS IN A SWITCH (POINT) BEING
/CLOSED;FALSE IF BEING OPENED.    IF NO CHANGE OF STATE FOR A GIVEN
/POINT HAS OCCURED DURING SCAN OF CIRCULAR BUFFER, 0 IS RETURNED IN N
/AND LOGICAL FALSE IN L.  THE NUMBER OF DIGITAL INPUTS LOST DUE TO
/BUFFER OVERFLOW (MOD. (2**17)-1) IS RETURNED IN IOVCT.
	.EJECT
/
/
	.GLOBL RDDI,DFDI,CTDI,.DA
/
CTDI	0
	JMS*	.DA	/GET ARGS.
	JMP	ARGE1
LUN	0		/LOG. UNIT NUM. (ADDR.)
IBUF	0		/ADDR. OF FIRST WORD OF ARRAY
ARRSIZ	0		/ADDR. OF ARRAY SIZE
TEV	0		/ADDR. OF TRIGG. EV. VAR.
EV	0		/ADDR. OF EVENT VAR. (OPTIONAL)
ARGE1	LAC	IBUF	/GET TOP OF ARRAY.
	DAC	CPB4
	DAC	BUFT
	DAC	BUFP
	TAD*	ARRSIZ
	DAC	BUFB
	AAC	-1
	DAC	CPB5	/BOTTOM OF ARRAY
	LAC	TEV	/TRIGGER.
	DAC	CPB3
	LAC*	LUN	/LOG. UNIT NO.
	DAC	CPB2
	LAC	EV	/EVENT VAR. ADDR.
	DAC	CPB1
	DZM	EV	/REINIT. EV ARG.
	CAL	UDCCON	/UDC CONNECT.
/
	LAC	(SKP)
	DAC	SW
	LAC	(T1)
	DAC	O
	DZM	OVRC
	JMP*	CTDI
	.EJECT
/
/
DFDI	0	/SUBR. ENTRY.
	JMS*	.DA	/GET ARGS.
	JMP	ARGE2
LUN1	0	/ADDR. OF LOG. UNIT NO.
ARGE2	LAC*	LUN1
	DAC	CPB2A
	CAL	UDCDIS	/UDC DISCONNECT.
	JMP*	DFDI
/
/
/CAL PARAMETER BLOCKS*
/
/UDC CONNECT
UDCCON	7000		/FUNCT. CODE.
CPB1	0		/EV VAR. ADDR.
CPB2	0		/LUN.
CPB3	0		/TRIG. EV VAR. ADDR.
CPB4	0		/ADDR. OF TOP OF ARRAY.
CPB5	0		/ADDR. OF BOTTOM OF ARRAY.
/
/UDC DISCONNECT*
/
UDCDIS	7100		/FUNCT. CODE.
CPB1A	0		/EVENT VAR. ADDR.
CPB2A	0		/LUN.
/
/
	.EJECT
RDDI	0
	JMS*	.DA
	JMP	SW
N	0
L	0
O	0
/
SW	XX		/IS A CIRUCLAR BUFFER ENTRY BEING PROCESSED?
	JMP	PROC	/YES (NOP) -- CONTINUE TO REPORT POINT NUMBERS
BINT	LAC*	BUFP	/NO (SKP) -- IS THERE AN UNPROCESSED BUFFER ENTRY
	SNA
	JMP	NODATA	/NO -- RETURN ZEROS
	LAC	(NOP)	/YES -- SET ENTRY SWITCH TO PROCESS IT
	DAC	SW
/
	SMA		/DETERMINE OVERRUN COUNT
	CLA
	TCA
	DAC	OVRC
/
	LAC	BUFP	/DETERMINE HIGH ORDER BITS FOR POINT NUMBER(S)
	DAC*	(X10)	/AND SEVE COS GATE OUTPUT (LOW ORDER BITS DATA)
	LAC*	X10	/AND DATA WARD (POINT POLARITIES).
	LLS	4
	AND	(7760)
	DAC	HOB
	LAC*	X10
	DAC	COS
	LAC*	X10
	DAC	PPL
/
	DZM	LOB	/CLEAR LOW-ORDER-BITS COUNTER
/
PROC	LAC	LOB	/HAVE ALL POINTS ON THE CURRENT MODULE
	SAD	(20)	/BEEN REPORTED?
	JMP	NEXT	/YES -- PROCEDE TO NEXT BUFFER ENTRY
	ISZ	LOB	/NO -- UPDATE LOW ORDER BITS COUNT
	LAC	PPL	/DETERMINE PLOARITY OF NEXT POINT
	RCL
	DAC	PPL
	SZL!CLA
	LAW	-1
	DAC	LV
/
	LAC	COS	/DETERMINE CHANGE-OF-STATE OF NEXT POINT
	RCL
	DAC	COS
	SNL		/CHANGED?
	JMP	PROC
	LAC	LOB	/YES --- RETURN ARGUMENTS:
	XOR	HOB	/  POINT NUMBER, POLARITY, & OVER-RUN COUNT
	DAC*	N
	LAC	LV
	DAC*	L
	LAC	OVRC
	DAC*	O
/
	JMP	DONE
/
NEXT	DZM*	BUFP	/CLEAR ENTRY EXISTENCE INDICATOR
/
	LAC	BUFP	/ADVANCE BUFFER POINTER
	AAC	+4
	SAD	BUFB
	LAC	BUFT
	DAC	BUFP
/
	JMP	BINT	/CHECK FOR A ENTRY
/
NODATA	LAC	(SKP)	/SET SWITCH FOR NO BUFFER ENTRY BEING PROCESSED
	DAC	SW
/
	DZM*	N	/RETURN NO DATA INDICATION
	DZM*	L
	LAC	OVRC
	DZM*	O
/
DONE	DZM*	TEV	/CLEAR TRIGGER EVENT VARIABLE
	LAC	(T1)
	DAC	O
	JMP*	RDDI
/
BUFT	0	/CIRCULAR BUFFER TOP
BUFB	0	/BUFFER BOTTOM
BUFP	0	/BUFFER POINTER
/
COS	0	/COS GATES OUTPUT BUFFER
PPL	0	/POINT POLARITIES (MODULE DATA WORD)
HOB	0	/POINT NUMBER HIGH ORDER BITS (MODULE NUMBER)
LOB	0	/POINT NUMBER LOW ORDER BITS (COUNTER)
LV	0	/LOGICAL VALUE (TEMP BUF)
OVRC	0	/DATA OVER-RUN COUNT
/
T1	0	/TEMP 1
/
	.END
