	.TITLE	CD....	CR03B CARD READER HANDLER TASK.
/
/CR03B CARD READER CONTROL HANDLER TASK.  THIS CONTROL WILL
/SUPPORT GDI 100 CARD READER
/THIS IS AN IOPS ASCII ONLY HANDLER TASK.
/IT CAN BE ASSEMBLED TO READ 029 OR 026 IBM KEYPUNCHED CARDS.
/DEFINE DEC026 TO READ 026 PUNCHED CARDS.
/DEC026 UNDEFINED TO READ 029 PUNCHED CARDS.
/
/GLEANED BY A.REID FROM CD.... 013 & CD.DOS 012 - 15 SEPT 1972
/
/ THE FOLLOWING QUEUE I/O DIRECTIVES ARE IMPLEMENTED
/
/	CPB	3600	HANDLER INFORMATION (HINF)
/		EVA
/		LUN
/
/ FOR HINF THE FOLLOWING INFORMATION IS RETURNED IN THE EV
/
/	BIT  0		UNUSED
/	BIT  1 = 1	INPUT DEVICE
/	BIT  2 = 0	NOT OUTPUT DEVICE
/	BIT  3 = 0	NOT FILE-ORIENTED
/	BITS 4-11	UNIT NUMBER 'ZERO'
/	BITS 12-17	DEVICE CODE = 7  CARD READER
/
/
/	CPB	2400	ATTACH CARD READER
/		EVA
/		LUN
/
/	CPB	2500	DETACH CARD READER
/		EVA
/		LUN
/
/	CPB	2600	READ CARD
/  (1)		EVA
/  (2)	LUN
/  (3)		MODE
/  (4)		BUFF
/  (5)		SIZE
/
/IF A REQUEST CANNOT BE QUEUED, THE FOLLOWING EVENT VARIABLE
/VALUES ARE RETURNED:
/
/	-101 -- INDICATED LUN DOES NOT EXITS.
/	-102 -- INDICATED LUN IS NOT ASSIGNED TO PHYSICAL DEVICE.
/	-103 -- HANDLER TASK IS NOT CORE RESIDENT.
/	-777 -- NODE FOR REQUEST QUEUE NOT AVAILABLE.
/
/
/IF THE QUEUED I/O REQUEST CANNOT BE SUCCESSFULLY DEQUEUED,
/THE FOLLOWING EVENT VARIABLE VALUES ARE RETURNED:
/
/	-7  -- ILLEGAL DATA MODE.
/	-6  -- UNIMPLEMENTED FUNCTION.
/	-24 -- LUN REASSIGNED WHILE ATTACH/DETACH REQUEST IN QUEUE.
/	-30 -- OUT OF PARTITION TRANSFER (NORMAL MODE).
/	-203 -- CAL NOT TASK ISSUED.
/
/
	.EJECT
/
/   ***** CONSTANTS *****
/
X12=12		/AUTO-INDEXREG. 12
X13=13		/AUTO-INDEXREG. 13
R1=101		/RE-ENTRANT REG. 1
R2=102		/RE-ENTRANT REG. 2
R3=103		/RE-ENTRANT REG. 3
R4=104		/RE-ENTRANT REG. 4
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
ALAD=325	/ATTACH LUN & DEVICE ENTRY POINT
DLAD=332	/DETACH LUN & DEVICE ENTRY POINT
DQRQ=337	/DE-QUEUE REQUEST ENTRY POINT
VAJX=342	/VERIFY AND ADJUST I/O PARAMS.
IOCD=345	/DECREMENT TRANSFERS PENDING COUNT.
DMTQ=361	/DE-QUEUE I/O REQUEST (FOR ABORTING).
D.TG=10		/POSITION OF TRIGGER EVENT VARIABLE IN PDVL NODE
/
/PSUEDO-INSTR. FOR WF.SW SUBR.
/
WFOFF=SPA	/WAITFOR CR03B NOT READY.
WFON=SMA	/WAITFOR CR03B READY.
/
/ *****  IOT INSTRUCTIONS *****
/
CRSC=706722			/CLEAR STATUS & DATA BUFFERS - SELECT A CARD
CROR=706712			/LOAD DATA & STATUS INTO AC
CRCS=706704			/CLEAR STATUS & DATA BUFFERS
CRSI=706721			/SKIP IF FLAG SET
/
.INH=705522		/INHIBIT INTERRUPTS.
.ENB=705521		/ENABLE INTERRUPTS.
/
	.EJECT
/----CR03B STATUS AND AC BIT ASSIGNMENTS.
/
/STATUS REGISTER BIT ASSIGNMENTS:
/
/	BIT 	TRANSLATION
/	
/	17	COLUMN READY
/	16	END OF CARD
/	15-04	DATA
/	03	BAD DATA
/	02	NO PASS
/	01	HOPPER EMPTY
/	00	NOT READY
/
/	STATUS REGISTER BITS CONNECTED TO FLAG AND INTERRUPT REQUEST:
/
/	17	COLUMN DATA READY
/	16	CARD DONE
/	02	NO PASS
/
/MACRO DEFINITIONS:
/
/CP MACRO FOR CARD COLUMN TO ASCII TRANSLATION TABLE 026/029 CONDITIONALIZATION
/
	.IFDEF	DEC026
	.DEFIN	CP,C26,C29
	C26\7777+1
	.ENDM
	.ENDC
	.IFUND	DEC026
	.DEFIN	CP,C26,C29
	C29\7777+1
	.ENDM
	.ENDC
/
/
	.EJECT
/
/
/ ***** HANDLER INITIALIZATION ***** (ONCE ONLY CODE)
/
/START				/STORAGE FOR AC IN INTERR. SERVICE.
/IBUF				/TOP OF INTERNAL BUFFER.
/
/
START	LAC	(PDVL)		/SCAN PDVL FOR THIS DEVICE'S NODE
IBUF	DAC*	(R1)
	LAC	(HNAM)
	DAC*	(R2)
	JMS*	(SNAM)		/R, R2, R6, XR, & AC ARE ALTERED
				/NODE FOUND?
	CAL	(10)		/NO -- EXIT
	DAC	PDVNA		/YES -- PDVL NODE ADDRESS IN AC.
	AAC	D.TG		/SAVE NODE ADDRESS AND
	DAC	PDVTA		/TRIGGER EVENT VARIABLE ADDRESS
	CAL	CCPB		/CONNECT INTERRUPT LINE
	LAC	EV		/CONNECT OK?
	SPA
	CAL	(10)		/NO -- EXIT
	LAC	(TG)		/YES -- SET TEV ADDRESS
	DAC*	PDVTA
	AND	(70000)		/DETERMINE 'XR-ADJ'
	TCA
	DAC	XADJ
/
	CRCS			/CLEAR STATUS
	JMP	WFTGR		/WAIT FOR TRIGGER
/
HNAM	.SIXBT	'CD@@@@'	/HANDLER TASK NAME
	.BLOCK	121+START-.
/ ***** END OF INITIALIZATION CODE *****
/
/******** THE ABOVE CODE IS OVERLAYED BY THE INTERNAL BUFFER ******
/******************************************************************
/
WFTGR	CAL	WFTCPB		/WAIT FOR TEV TO BE SET
/
/ ***** THE TASK HAS BEEN TRIGGERED -- PICK A REQUEST FROM QUEUE
/
	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	RN		/YES -- SAVE ADDRESS OF REQUEST NODE
	TAD	XADJ		/SETUP XR TO ACCESS NODE
	PAX
	LAC	6,X		/SAVE ADDR. OF REQUESTORS EV
	SNA
	LAC	(RE)
	DAC	RE
/
/ ***** I/O REQUEST NODE FORMAT *****
/
/    (0) FORWARD LINK
/    (1) BACKWARD LINK
/    (2) STL PTR.
/    (3) PART. BLK PTR. (0 IF EXM TSK).
/    (4) TASK PRIORITY
/    (5) I/O FCN CODE IN BITS 9-17 AND LUN IN BITS 0-8
/    (6)  -- EVENT VARIABLE ADDRESS
/    (7) CTB PTR.
/    (10) EXTRA
/    (11) EXTRA
/
	LAC	5,X		/FETCH I/O FCN CODE
	AND	(777)
	SAD	(024)		/ATTACH REQUEST?
	JMP	ATTACH		/YES -- ATTACH TO TASK
	SAD	(025)		/NO -- DETACH REQUEST?
	JMP	DETACH		/YES -- DETACH FROM TASK
	SAD	(026)		/NO -- READ REQUST?
	JMP	READ		/YES -- READ CARD
	SAD	(036)		/NO -- HANDLER INFO.?
	JMP	HINF		/YES -- RETURN INFO IN EV
	SAD	(777)		/NO -- EXIT (DEASSIGNED) REQUEST?
	JMP	DAEX		/YES -- DEATTACH & EXIT
	SAD	(017)		/ABORT REQUEST?
	JMP	CDABRT		/YES.
EVM6	LAW	-6		/NO -- UNIMPLEMENTED FUNCTION -- SET
	JMP	SEV		/EVENT VARIABLE TO -6
/
/ ATTACH TO A TASK
/
ATTACH	LAC	PDVNA		/ATTACH LUN & DEVICE
	DAC*	(R1)
	LAC	RN
	DAC*	(R2)
	JMS*	(ALAD)		/R3, R4, R5, R6, X10, X11, XR & AC ARE ALTERED
				/WAS LUN ATTACHED?
	JMP	SEV		/NO -- SET REQUESTOR'S EV TO -24
	JMP	REQCMP		/YES REQUEST COMPLETED
/
/ DETACH FROM TASK
/
DETACH	LAC	PDVNA		/DETACH LUN & DEVICE
	DAC*	(R1)
	LAC	RN
	DAC*	(R2)
	JMS*	(DLAD)		/R3, R4, R5, R6, X10, X11, XR & AC ARE ALTERED
				/WAS LUN ATTACHED
	JMP	SEV		/NO -- SET REQUESTOR'S EV TO -24
	JMP	REQCMP		/YES -- REQUEST COMPLETED
/
	.EJECT
/
/ RETURN HANDLER INFORMATION
/
HINF	LAC	(200007)
	JMP	SEV
/
/READ CARD
/
READ	LAW	-2		/CHK. FOR IOPS ASCII DATA MODE.
	TAD	7,X
	SZA			/IOPS ASCII?
	JMP	EVM7		/NO, RETURN -5 EV.
	LAC	2,X		/SAVE STL NODE PTR. FOR TASK IDENTIF.
	DAC	STLA		/SAVE VALID STL PTR.
	LAC	10,X		/YES.  VAL/ADJ. HEADER ADDRESS
	DAC*	(R3)		/HEADER ADDRESS.
	LAC	11,X		/WORD COUNT
	DAC*	(R4)
	TCA			/SETUP COUNTER  SINCE
	AAC	+2		/OFFSET FOR CR APPENDAGE.
	DAC	CDWDCT		/VAJX ALTERS THE XR.
	DAC	TCWC		/SAVE IN CASE RETRY.
	LAC	RN		/REQ. NODE ADDRESS.
	DAC	RRN		/SAVE READ REQ. NODE ADDR. FOR ABORT.
	DAC*	(R2)
	JMS*	(VAJX)		/VAL/ADJ. (ALTERS XR,AC,R3,R5)
	JMP	EVM30		/RETS. HERE IF ERROR (I/O PARAM. OUT
				/OF PARTITION.
	LAC*	(R3)		/ADJUSTED HEADER ADDRESS -1 TO X12 TEMP.
	AAC	-1
	DAC	TX12
	AAC	+2		/TEXT ADDRESS-1 TO X13 TEMP.
	DAC	TX13		/
	DZM	CDRVAL		/INIT. VALID. BITS.
	LAC	CDON		/HAS CARD DONE FLAG COME UP SINCE
	SNA			/LAST CARD READ?
	CAL	WFCRCD		/NO. WAITFOR CARD DONE.
	DZM	CDON		/YES. CLEAR CARD DONE FLAG.
RETRY	LAC	(IBUF)		/SET INTERN. BUFF ADDR. POINTER
	DAC	ICA
	LAC	TCWC		/RESTORE REQ. WC.
	DAC	CDWDCT
	DZM	COLCNT		/CLEAR COLUMN COUNTER
	DZM	EV1		/REINIT EV.  RETRY FROM ERROR.
	CROR			/LOAD STATUS INTO AC
	CRCS			/CLEAR STATUS
	SPA			/READER READY?
	JMP	ERR1		/NO
	CRSC			/YES, SELECT A CARD
	CAL	WFCRCB		/WAIT FOR INTERRUPT.
/
/
/
/UPON RESUMPTION FOLLOWING WAITFOR, EXAMINE EV AND TAKE THE FOLLOWING
/ACTION:
/
/IF EV BIT 0 = 0 (TROUBLE BIT), NO ERRORS.  TRANSLATE CARD PUNCHES
/TO ASCII AND PASS TO USER AS 5/7 PACKED ASCII.
/IF BIT 0 = 1 (TROUBLE BIT), ERROR BITS 01 TO 03 ARE CHECKED
/THE FOLLOWING ERROR MESSAGES ARE GIVEN AS REQUIRED
/ '*** CD COLUMNS MISSED'
/ '*** CD BAD DATA'
/ '*** CD NO PASS'
/HOPPER EMPTY OR STACKER FULL - IGNORED.  CAUGHT ON SUBSEQ.
/READ AS A READER NOT READY CONDITION.
/IN ALL CASES WHERE A MESSAGE IS TYPED,  THIS HANDLER TASK MARKS TIME
/UNTIL THE ERROR IS REMEDIED.  AT THIS POINT, THE CARD IS REREAD.
/
	LAC	EV1		/EV SET AT INT. LEVEL TO C(STATUS)
	SMA			/ERROR BIT SET?
	JMP	CHKCOL		/NO, CARD DONE
	CLL!RTL			/YES
	SZL			/HOPPER EMPTY?
	JMP	TRANS		/YES BUT LEAVE FOR NEXT READ
	SPA			/NO.  NO PASS?
	JMP	ERR3		/YES
	CLL!RAL			/NO
	SPA			/BAD DATA?
	JMP	ERR4		/YES
	JMP	TRANS		/NO, ASSUME CD NOT READY
CHKCOL	LAW	-120		/CHECK FOR MISSED COLUMNS
	TAD	COLCNT
	SZA!CLA			/80 DEC. COLUMNS READ?
	JMP	COLERR		/NO
	JMP	TRANS		/YES
/
/
ERR4	ISZ	ERRPT
ERR3	ISZ	ERRPT
ERR2	ISZ	ERRPT
ERR1	LAC*	ERRPT		/ERRMSG. BUFFER ADDR. TO AC.
	JMS	TTYOUT		/TYPE MESSAGE.
	JMS	WF.SW		/WAITFOR READER READY.
		WFON
	LAC	(ERRPT+1)	/REINIT. ERRPT.
	DAC	ERRPT
	JMP	RETRY		/READ ANOTHER CARD.
/
	.EJECT
TRANS	LAC	TX12		/SET AUTO INDEX REG.
	DAC*	(X12)
	LAC	TX13
	DAC*	(X13)
	LAC	(IBUF)		/TOP OF INTERNAL BUFFER
	DAC	ICA		/PTR TO BUFFER
	LAW	-20
	DAC	CDCOLC		/CARD COL COUNT
CDRM5	LAW	-5
	DAC	CDR5CT
CDML2	LAC*	ICA		/GET
	SAD	CDRALT		/ALT MODE (12,1,8 PUNCH)?
	JMP	CDGALT		/YES -- TERMINATE BUFFER
	SAD	(7777		/NO -- IS IT AN EOF?
	JMP	EOF		/YES.
	LAC	CDTABL		/NO -- TRANSLATE TO ASCII
	DAC	CDTPTR		/GET TOP OF TABLE AND SET PTR
	LAC	CDTLN1		/SET TABLE LENGTH
CDML4	DAC	CDTLEN		/CURRENT LENGTH/2
	ADD	CDTPTR		/CURRENT TABLE TOP + LENGTH/2
	DAC	CDCPTR
	LAC*	CDCPTR		/GET CURRENT ITEM
	AND	(7777
	SZA!CLL
	ADD	CD7700		/ADD IN REST OF 2'S COMPLEMENT WORD
	TAD*	ICA		/CURRENT COLUMN
	SNA!CLA			/MATCH FOUND?
	JMP	CDCFND		/YES
	SAD	CDTLEN		/CURRENT TABLE LENGTH =0?
				/THIS MEANS AN UNKNOWN CARD PUNCH
	JMP	ILLCP		/GO OUTPUT 'ILLEGAL CARD PUNCH'.
	SNL			/L=0 JUMP UP, L=1 JUMP DOWN TABLE
	JMP	CDDPTR
	LAC	CDCPTR		/SET TABLE TOP TO LOWER HALF
	DAC	CDTPTR
CDDPTR	LAC	CDTLEN		/UPDATE TABLE LENGTH
	CLL!RAR
	JMP	CDML4
CDGALT	LAW	4000		/ALT MODE
	JMP	CDCPUT
/
EOF	LAC	(1005
	JMP	REQCMA		/SET HDR WDI TO EOF
				/REQUEST COMPLETE
/
/COME HERE ON MATCH FOUND
/
CDCFND	LAC*	CDCPTR		/GET CURRENT ENTRY
	CMA!CLL			/GEN. LEFTMOST BIT
	TAD	CDTABL+1	/ADD 4000000
	CMA
	XOR	CDTABL+1	/RESTORE SIXTH BIT
	RAR
CDCPUT	DAC	CDRWD3		/PUT IN TOP OF 3 WORD SHIFT BLOCK
CDCLAW	LAW	-7
	DAC	CDR7CT
CDCPL1	LAC	CDRWD3		/CDEWD3,CDRWD2 & CDRWD1 SHIFT AS A UNIT USING
				/THE LINK TO PASS BITS FROM WORD TO WORD
	RAL
	DAC	CDRWD3
	LAC	CDRWD2
	RAL
	DAC	CDRWD2
	LAC	CDRWD1
	RAL
	DAC	CDRWD1
	ISZ	CDR7CT
	JMP	CDCPL1
	ISZ	ICA		/POINT TO NEXT CARD COL
	ISZ	CDR5CT		/HAVE WE PROCESSED 5 WORDS?
	JMP	CDML2		/NO GET ANOTHER ONE
	LAC	CDWDCT		/YES -- UPDATE WORD COUNT AND
	AAC	2		/CHECK TO SEE IF WE HAVE OVERFLOWED THE
	DAC	CDWDCT		/USER'S BUFFER
	SMA
	JMP	CDVER2		/YES -- WE HAVE OVERFLOWED
	LAC	CDRWD2		/NO -- INSERT 5/7 WORDS IN USER'S BUFFER
	CLL!RAL
	DAC	CDRWD2
	LAC	CDRWD1
	RAL
	DAC*	X13		/STORE FIRST WORD
	LAC	CDRWD2
	DAC*	X13		/STORE SECOND WORD
	ISZ	CDCOLC
	JMP	CDRM5
/
/ THE BUFFER HAS BEEN REMAPPED -- STORE A 'CR' IN THE TRAILER
/ WORD AND SET UP THE HEADER WORD
/
CDCLOS	LAC	(64000
	DAC*	X13		/SET 'CR' IN USER BUFFER
	LAC	(22
	TAD	CDCOLC		/CDCOLC IS NEGATIVE
	CLL			/ROTATE INTO PLACE
	ALS	11		/SHIFT INTO POSITION
	TAD	CDRVAL		/ADD IN BUFFER OVERFLOW IF ANY (BITS 12 & 13 =1)
	AAC	2
REQCMA	DAC*	X12		/SET HEADER WORD ONE
REQCMP	CLA!IAC
SEV	PAL			/SET 17 BIT REQ. EV TO AC VALUE.
	LAC	RE
	TAD	XADJ		/SET 17 BIT ADDRESS TO XR.
	PAX
	PLA
	DAC	0,X
	LAC	(401000)	/DECLARE A SIGNIFICANT EVENT
	ISA
	CLC			/REINIT. RRN FLAG IN CASE READ REQ.
	DAC	RRN
RNTP	LAC	(POOL)		/RETURN REQUEST NODE TO THE POOL
	DAC*	(R1)
	LAC	RN
	DAC*	(R2)
	JMS*	(IOCD)		/DECRM TRANSF. PENDING COUNT.
	JMS*	(NADD)
	JMP	PQ		/LOOK FOR ANOTHER REQUEST
/
/ ***** BUFFER OVERFLOW
/
CDVER2	LAW	-2		/BACKUP USER BUFFER PTR
	TAD*	(X13)
	DAC*	(X13)
	LAC	(60)		/SET OVERFLOW BITS FOR USE BY CDCLOS
	DAC	CDRVAL
	JMP	CDCLOS
/
EVM7	LAW	-7		/ILLEGAL DATA MODE.
	JMP	SEV
EVM30	LAW	-30		/I/O PARAM. OUT OF PARTITION.
	JMP	SEV
AEVM6	LAW	-6		/ILLEGAL FUNCTION.
	JMP	SAEV		/SET ABORT EV.
/
COLERR	LAC	(ERRMG5		/TYPE 'COLUMNS MISSED'
	JMP	ILLCP+1
/
/ON ILLEGAL CARD PUNCH, WAIT FOR READER NOT READY FOLLOWED BY
/READER READY SEQUENCE BEFORE READING ANOTHER CARD.
/
ILLCP	LAC	(ERRMG2)	/TYPE 'ILLEGAL CARD CODE'.
	JMS	TTYOUT
	JMS	WF.SW		/WAIT FOR READER NOT READY.
		WFOFF		/PSUEDO INSTR. FOR WF.SW.
	JMS	WF.SW		/WAIT FOR READER READY.
		WFON		/PSUEDO INSTR. FOR WF.SW.
	JMP	RETRY		/READ ANOTHER CARD.
/
/	SUBR. TO WAIT FOR READER NOT READY OR READY FOR READ
/	PER PSUEDO INSTR. IN CALLING SEQUENCE. AFTER MARK TIME REQS.,
/	THE TRIG. EV. IS CHECKED FOR AN ABORT REQ. IN THE QUEUE.
/	IF TASK REQ. READ IS TO BE ABORTED, THE SUBR. DOESN'T
/	RETURN NORMALLY,BUT EVENTUALLY JUMPS TO CDABRT.
/	CALLING SEQUENCE:
/
/	JMS	WF.SW
/		PSUED. INSTR.  (WFOFF OR WFON)
/	SUBR. RETURN ,IF NO INTERVENING ABORT FOR THIS TASK.
/
WF.SW	0
	LAC*	WF.SW		/GET PSUEDO INSTR.
	DAC	PV1
	ISZ	WF.SW		/BUMP EXIT.
WF.SWA	CROR			/READ CARD READER STATUS.
	CRCS			/CHECK FOR READER READY FOR READ.
PV1	XX			/SPA OR SMA.(READER READY IF POSITIVE AC).
	JMP*	WF.SW		/EXIT.
	CAL	MTCPB		/MARK TIME FOR WAIT.
	CAL	WFECB		/WAIT FOR MARK TIME INTERVAL.
	DZM	EV
	LAC	TG		/CHECK FOR ABORT REQ. IN QUEUE.
	RTL
	SMA			/ABORT REQ.?
	JMP	WF.SWA		/CHECK AGAIN.
	DZM	TG		/YES.  DEQUEUE ABORT REQ.
	LAC	PDVNA		/PDVL NODE ADDR.
	DAC*	(R1)
	JMS*	(DQRQ)		/DEQUEUE ABRT. REQ. R1,R2,R4,R5,R6,XR,AC
	NOP			/ALTERED.  ASSUME ABRT. REQ. IN QUEUE.
	DAC	RN		/SAVE ABORT REQ. NODE ADDR.
	TAD	XADJ		/SET XR.
	PAX
	LAC	6,X		/GET ABRT. REQ. EV.
	DAC	ARE
	LAC	5,X		/CHECK FOR ZERO LUN.
	AND	(777000)	/BITS 0-8
	SZA
	JMP	AEVM6		/ERROR.  NON-ZERO LUN.
	LAC	2,X		/GET STL. NODE PTR. AND CHECK AGAINST
	SAD	STLA		/READ REQ. STL NODE PTR. SAME?
	JMP	CDARD		/YES.  ABORT READ REQ. AND CLEAN UP.
	LAC	PDVNA		/NO.  CLEAN UP QUEUE OF TASK TO BE ABRTED.
	DAC*	(R1)		/ALSO RETR. ABRT. REQ. NODE TO POOL AND
	LAC	RN		/DECR. TRANSF. PEND. CNT.  ABRT. REQ. NODE 
	DAC*	(R2)		/ADDR. TO R2.
	JMS*	(DMTQ)		/EMPTY REQ. QUEUE OF ALL I/O
				/REQ.'S MADE BY TASK BEING ABORTED.
				/R1,R2,R3,R5,R6,X10,X11,X12,XR,AC ALTERED.
	CLA!IAC			/SET ABRT. REQ. EV TO +1.
SAEV	PAL
	LAC	ARE		/ABORT REQ. EV.
	TAD	XADJ
	PAX
	PLA
	DAC	0,X
	LAC	(401000)
	ISA			/DECLARE SIGNIF. EVENT.
	LAC	RN		/RETRN. ABRT. REQ. NODE TO POOL.
	DAC*	(R2)
	LAC	(POOL)
	DAC*	(R1)
	JMS*	(IOCD)		/DECR. TRANSF. PEND. CNT.
	JMS*	(NADD)		/RETRN. NODE TO POOL.
	JMP	WF.SWA		/CHECK AGAIN.
CDARD	LAC	ARE		/OVERRIDE READ REQ. EV WITH ABRT. REQ. EV.
	DAC	RE		/READ IS TO BE ABORTED.
	CLC			/SET CARD DONE FLAG.
	DAC	CDON
	JMP	CDABRT		/PROCEED WITH ABORT.
	.EJECT
/
/ EXIT REQUEST (FROM TASK "....REA")
/
DAEX	LAC	(POOL)		/RETURN REQUEST NODE TO POOL
	DAC*	(R1)
	LAC	RN
	DAC*	(R2)
	JMS*	(IOCD)		/DECREMENT TRANSF. PENDING COUNT
	JMS*	(NADD)
	CRCS			/CLEAR STATUS & DATA BUFFER
	CAL	DCPB		/DISCONNECT
	ISZ	PDVTA		/POINT TO ASSIGN INHIBIT FLAG
	.INH			/INHIBIT INTERRUPTS.
	DZM*	PDVTA		///ZERO IT
	.ENB			///ENABLE INTERRUPTS.
	CAL	(10)		///EXIT
/
/
/ABORT REQUEST.
/
CDABRT	LAC	5,X		/CHECK ABRT. REQ. NODE FOR 0 LUN.
	AND	(777000)	/BITS 0-8.
	SZA
	JMP	EVM6		/ERROR.
	LAC	PDVNA		/PDVL NODE ADDRESS.
	DAC*	(R1)
	LAC	RN		/ABORT REQ. NODE ADDRESS.
	DAC*	(R2)
	JMS*	(DMTQ)		/EMPTY REQ. QUEUE OF ALL I/O REQUESTS
				/MADE BY TASK BEING ABORTED.
				/R1,R2,R3,R5,R6,X10,X11,X12 XR,AC ALTERED.
	LAC	RRN		/ABORT DURING READ REQ. PROC.?
	SPA
	JMP	REQCMP		/NO.
	DAC*	(R2)		/YES.  RETURN NODE TO POOL AND
	LAC	(POOL)		/DECR. TRANSF. PEND. COUNT.
	DAC*	(R1)
	JMS*	(IOCD)
	JMS*	(NADD)
	JMP	REQCMP
/
/
	.EJECT
/
/ INTERRUPT SERVICE ROUTINE
/
INT	0
	DBA
	DAC	START		/SAVE AC
	CROR			/GET DATA & STATUS THEN SAVE
	DAC	TST		/FOR TASK LEVEL PROCESSING
	CRCS			/CLEAR STATUS
	SPA			/ERROR FLAG SET?
	SAD	(600002		/YES. HOPPER EMPTY & CARD DONE?
	SKP			/YES - NORMAL CONDITION
	JMP	ERROUT		/READER ERROR, CHECK AT TASK LEVEL
	RCR
	SML			/COLUMN READY?
	JMP	CRDONE		/NO, MUST BE CARD DONE
	RAR			/YES
	AND	(7777		/REMOVE DATA & STORE IT
	DAC*	ICA
	ISZ	ICA		/BUMP POINTER FOR NEXT COLUMN
	ISZ	COLCNT		/INCREMENT COLUMN COUNT
	JMP	NODECL
CRDONE	ISZ	CDON		/SET SOFTWARE DONE FLAG
ERROUT	LAC	TST		/PUT STATUS INTO EV1
	DAC	EV1		/(MAKES IT NON-ZERO)
	LAC	(401000		/--DECLARE--
	ISA
NODECL	LAC	START		/RESTORE AC
	DBR
	JMP*	INT
	.EJECT
/
/SUBR. TO OUTPUT ERROR MESSAGES VIA LUN 3.  AC SHOULD CONTAIN
/ADDRESS OF ERROR MESSAGE BUFFER.
/
TTYOUT	0
	DAC	TECPB4		/SET CPB BUFFER ADDRESS.
	CAL	TE		/TYPE ERROR MESSAGE.
	CAL	WFECB		/WAITFOR EV.
	JMP*	TTYOUT
/
/ERROR MESSAGE BUFFERS AND TABLE OF PTRS.:
/
ERRPT	.+1
	ERRMG1
	ERRMG2
	ERRMG3
	ERRMG4
	ERRMG5
/
/
/
ERRMG1	ERRMG2-ERRMG1*1000/2+2
	0
	.ASCII '*** CD READER NOT READY'<15>
ERRMG2	ERRMG3-ERRMG2*1000/2+2
	0
	.ASCII '*** CD ILLEGAL PUNCH'<15>
ERRMG3	ERRMG4-ERRMG3*1000/2+2
	0
	.ASCII '*** CD PICK ERROR'<15>
ERRMG4	ERRMG5-ERRMG4*1000/2+2
	0
	.ASCII '*** CD BAD DATA'<15>
ERRMG5	ENDMSG-ERRMG5*1000/2+2
	0
	.ASCII '*** CD DATA MISSED/PHOTO ERROR'<15>
ENDMSG=.
	.EJECT
/ ***** CARD COL TO ASCII TRANSLATION TABLE *****
/
/EACH TABLE ENTRY REPRESENTS VALID ASCII CARD PUNCHES WITH
/THE FOLLOWING FORMAT:
/
/BITS 0 - 5	SIXBIT ASCII CHARACTER.
/BITS 6 - 17	CARD PUNCHES WITH THE FOLLOWING MAPPING:
/
/BIT 6 = ZONE 12
/BIT 7 = ZONE 11
/BITS 8 - 17  = ZONES 0 - 9.
/THE ASSEMBLER BUILDS THE TWOS COMPLEMENT OF BITS 6-17 VIA THE
/7777\+1 OPERATION.  THE TABLE IS ORDERED ACCORDING TO INCREASING
/MAGNITUDE OF CARD PUNCHES(CONSIDERED AS 12 BIT RIGHT JUSTIFIED
/INTEGER VALUES).
/EXAMPLE:  ASCII '9' HAS FOLLOWING TABLE REPRESENTATION:
/
/	710001\7777+1
/
/WHERE 0001 INDICATES ZONE 9 PUNCHED AND 71 IS SIXBIT ASCII '9'.
/
/GRAPHIC CHARACTERS FOR 026 PUNCHES ARE IN PARENTHESES BELOW:
/
CDTABL	CDTABL+1
	400000			/BLANK
	710001\7777+1		/9
	700002\7777+1		/8
	670004\7777+1		/7
	CP 340006,420006	/" (\)
	660010\7777+1		/6
	CP 470012,750012	/= (')
	650020\7777+1		/5
	CP 360022,470022	/, (^)
	640040\7777+1		/4
	000042\7777+1		/@
	630100\7777+1		/3
	CP 750102,430102	/# (=)
	620200\7777+1		/2
	CP 370202,720202	/: (_)
	610400\7777+1		/1
	601000\7777+1		/0
	321001\7777+1		/Z
	311002\7777+1		/Y
	301004\7777+1		/X
	CP 451006,771006	/? (%)
	271010\7777+1		/W
	CP 431012,761012	/> (#)
	261020\7777+1		/V
	CP 421022,371022	/RIGHT ARROW (")
	251040\7777+1		/U
	CP 501042,451042	/% (()
	241100\7777+1		/T
	541102\7777+1		/'
	231200\7777+1		/S
	CP 731202,351202	/](;)
	571400\7777+1		//
	552000\7777+1		/-
	222001\7777+1		/R
	212002\7777+1		/Q
	202004\7777+1		/P
	CP 462006,342006	/\ (&)
	172010\7777+1		/O
	CP 762012,732012	/; (>)
	162020\7777+1		/N
	CP 332022,512022	/) ([)
	152040\7777+1		/M
	522042\7777+1		/*
	142100\7777+1		/L
	442102\7777+1		/$
	132200\7777+1		/K
	CP 722202,412202	/! (:)
	122400\7777+1		/J
	CP 534000,464000	/& (+)
	114001\7777+1		/I
	104002\7777+1		/H
	074004\7777+1		/G
	CP 414006,364006	/^ (!)
	064010\7777+1		/F
	CP 744012,534012	/+ (<)
	054020\7777+1		/E
	CP 354022,504022	/( (])
	044040\7777+1		/D
	CP 514042,744042	/< ())
	034100\7777+1		/C
	564102\7777+1		/.
	024200\7777+1		/B
	CP 774202,334202	/[ (?)
	014400\7777+1		/2
CDTLN1	.-1-CDTABL/2
CDRALT	4402
	.EJECT
/
/ ***** INTERNAL VARIABLES *****
/
CDON	1		/CARD DONE FLAG.
TST	0		/TEMP STORAGE FOR STATUS.
STLA	0		/STL NODE. ADDR.
ARE	0		/ABORT REQ. EV.
CDR7CT	0		/SEVEN COUNTER USED BY THE 5/7 ASCII PACKING ROUTINE
EV	0		/INTERNAL EVENT VARIABLE
TG	0		/TRIGGER EVENT VARIABLE
XADJ	 0		/XR ADJUST CONSTANT TO SUBTRACT PAGE BITS
RN	0		/ADDRESS OF THE REQUEST NODE PICKED FROM AUEUE
RE	0		/ADDRESS OF REQUESTOR'S EVENT VARIABLE
HX1	0		/USER BUFFER HEADER ADDRESS
HX2	0		/USER BUFFER TEXT ADDRESS
CDRVAL	0		/BUFFER OVERFLOW FLAG WORD
CDWDCT	0		/WORD COUNT CHECK WORD SET FROM I/O REQUEST
ICA	0		/INTERNAL BUFFER CURRENT ADDRESS POINTER
CDCOLC	0		/CARD COL COUNT USED IN TRANSLATING CARDS
CDR5CT	0		/COUNTER FOR 5/7 ASCII PACKING
CDTPTR	0		/POINTER TO TRANSLATION TABLE
CDTLEN	0		/TRANSLATION TABLE LENGTH
CD7700	770000		/USED IN CARD TRANSLATION
CDCPTR	0		/POINTER TO CURRENT INTEM IN TRANSLATION TABLE
CDRWD3	0		//
CDRWD2	0		// THREE WORD SHIFT REG. FOR 5/7 ASCII PACKING
CDRWD1	0		//
PDVNA	0		/PHYSICAL DEVICE NODE ADDRESS
PDVTA	0		/ADDRESS OF ADDRESS OF TEV IN PHY DEV NODE
RRN	777777		/READ BEING PROC. FLAG.  -1 IF NOT BEING 
			/PROCESSED.  READ REQ. NODE ADDRESS IF BEING
			/PROCESSED.
TX12	0		/TEMP. FOR X12 STOR.
TX13	0		/TEMP. FOR X13 STOR.
TCWC	0		/TEMP. FOR REQ. WC.
EV1	0		/CARD READER EV.
COLCNT	0			/SHOULD EQUAL 120 OCT WHEN CDON
/
	.EJECT
/
/ ***** CAL PARAMETER BLOCKS *****
/
/
WFTCPB	20			/WAIT FOR TRIGGER CPB
	TG
/
CCPB	11			/CONNECT CPB
	EV
	15			/LINENUMBER
	INT			/ENTRY ADDRESS OF INTERRUPT SERVICE ROUTINE
/
/
WFECB	20			 /WAIT FOR EV CPB
	EV
/
DCPB	12			/DISCONNECT CPB
	0			/EV ADDRESS
	15			/INTERRUPT LINE NUMBER
	INT			/CURRENT INTERRUPT TRANSFER ADDRESS
/
TE	2700			/WRITE TO LUN 3.
	EV
	3
	2
TECPB4	XX
/
MTCPB	13			/MARK TIME REQ.
	EV
	12			/12 UNITS.
	1			/UNIT (TICK).
/
WFCRCB	20		/WAIRFOR CR INTERRS.
	EV1
/
WFCRCD	20		/WAIT FOR CARD DONE FLAG TO BE SET.
	CDON
/
	.END START
