	.TITLE  CD.... CR15/UC15 CARD READER EDIT #020
/ 
/ 
/                   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,1975 BY DIGITAL EQUIPMENT CORPORATION
/ 
/ 
        .EJECT
/
/EDIT #022	8/11/75	MJH XVM MOVEBYTE FIX
/EDIT #021	4/22/75 SCR UC15 EOF CARD FIX
/EDIT #020	2/2/74	SCR  CLEANUP
/EDIT #019	SCR	CR15 ERROR HANDLING; RRN SWITCH!
/EDIT #018	SCR	FIX CDON HANDLING CR15 VERSION
/EDIT #017	SCR	CLEANUP, !BOTH! DEVICES
/EDIT #016	SCR	MORE UC15 CODE
/EDIT #015	SCR  START TO PUT IN UC15 CODE
/EDIT #013	1-18-72
/EDIT #14	6-26-73
/COPYRIGHT 1973, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/C.W. KEMP ---- W.A. DESIMONE. ---- G. M. COLE

/
/CR15 CARD READER CONTROL HANDLER TASK.  THIS CONTROL WILL
/SUPPORT SORBAN AND DOCUMATION READERS.
/ CR15 CODE IS OBTAINED  WITH NO ASSEMBLY PPARAMETERS
/
/ TO OBTAIN UC15 CODE DEFINE UC15=0.
/   ADDITIONAL UC15 PARAMETERS:
/  DEFINE NOSPL=0 TO DISABLE SPOOLING FOR CARD READER. FOR INSTANCE
/  IF SPOOLER PACKAGE DOESN'T HAVE CARD READER ASSEMBLED IN FOR SPACE REASONS.
/ AN EQUATE FOR APILVL IS NECESSARY TO SET UP
/ IOT'S FOR CORRECT PRIORITY LEVEL TO CLEAR PIREX REQUEST.
/ PRESENTLY LEVEL 1 IS THE CARD READER ASSIGNMENT.
/
/     W   A   R   N   I   N   G   !   !
/
/  IN ORDER FOR THE UC15 HANDLER TO FUNCTION PROPERLY, THE
/  PDP11 MUST BE ABLE TO ACCESS OUR INTERNAL BUFFER
/  AND TCB'S. THIS MEANS THAT THEIR ADDRESS MUST BE LESS THAN
/   28K TO THE PDP11. THUS, IF THE PDP-11 LOCAL MEMORY IS 8K,
/  THIS HANDLER MUST RESIDE BELOW 20K IN PDP15 CORE!! THIS
/  IS EQUIVALENT TO 50000 OCTAL. SIMILARLY , IF THE LOCAL
/  PDP-11 MEMORY IS 12K, THE HANDLER MUST RESIDE BELOW
/  40000 OCTAL.
/
	.IFDEF	UC15
/
/
APISLT=55
APILVL=1
CRSI=APILVL*20+706101
SIOA=706001
LIOR=706006
CAPI=APILVL*20+706104
/
	.IFUND NOSPL
DEVCOD=5
	.ENDC
	.IFDEF NOSPL
DEVCOD=205
	.ENDC
	.ENDC
/
/EDIT 14 ADDS ASSEMBLY PARAMETER ERRLUN TO SPECIFY LOGICAL UNIT
/	FOR ALL ERROR MESSAGES, THE IS SET TO 3 IF USED INTERACTIVELY
/	MOST OF THE TIME OR TO 100 WHEN USED WITH PHASE 
/	III BATCH. LUN 100 IS DEFINED TO BE THE BATCH OPERATOR DEVICE.
/
	.IFUND	ERRLUN
ERRLUN=100
	.ENDC
/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.

/
/

/

/ 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 TRIGER EVENT VARIABLE IN PDVL NODE
/
	.IFUND	UC15
/
CWC=22		/WC DCH ADDRESS.
CCA=23		/CA DCH ADDRESS.
/
/PSUEDO-INSTR. FOR WF.SW SUBR.
/
WFOFF=SNA	/WAITFOR CR15 NOT READY.
WFON=SZA	/WAITFOR CR15 READY.
/

/

/CONDITIONS FOR LOAD READER CONDITION IOT (CRLC).

/
CC1=20		/CLEAR STATUS,DISABLE INTERRUPT AND DATA CHANNEL.
CC2=27		/CLEAR STATUS,START READ,ENABLE INTERRUPT AND DATA CHANNEL.
CC3=26		/CLEAR STATUS,ENABLE INTERRUPT,ENABLE DATA CHANNEL.
CC4=04		/ENABLE INTERRS. DISABLES DCH
/
/ *****  IOT INSTRUCTIONS *****
/
CRPC=706724		/CLEAR STATUS EXCEPT CARD DONE.(ALSO DISABLES INTERR.)

CRLC=706704		/LOAD READER CONDITIONS.
CRRS=706732		/READ STATUS INTO AC.
/
	.ENDC
/
.INH=705522		/INHIBIT INTERRUPTS.
.ENB=705521		/ENABLE INTERRUPTS.
/
	.EJECT

/----CR15 STATUS AND AC BIT ASSIGNMENTS.

/

/STATUS REGISTER BIT ASSIGNMENTS:

/

/	BIT 	TRANSLATION

/	

/	17	COLUMN READY

/	16	END OF CARD

/	15	DATA CHANNEL OVERFLOW

/	14	DATA CHANNEL ENABLED

/	13	READY TO READ

/	12	ON LINE

/	11	END OF FILE

/	10	BUSY

/	09	TROUBLE (= IOR OF BITS 4 - 8)

/	08	DATA MISSED

/	07	HOOPER EMPTY/STACKER FULL

/	06	PICK ERROR

/	05	MOTION ERROR

/	04	PHOTO ERROR

/	03-00	UNUSED

/

/AC BIT ASSIGNMENTS FOR LOAD CONDITION FUNCTION (CRLC)

/

/	BIT	FUNCTION

/

/	17	START READ

/	16	DATA CHANNEL ENABLE

/	15	INTERRUPT ENABLE

/	14	OFFSET CARD

/	13	CLEAR STATUS REGISTER

/

/	STATUS REGISTER BITS CONNECTED TO FLAG AND INTERRUPT REQUEST:

/

/	17	DATA READY(ONLY IF DATA CHANNEL NOT ENABLED)

/	16	CARD DONE

/	15	DATA CHANNEL OVERFLOW

/	09	ERROR CONDITION

/

/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
/
	.IFUND	UC15
	LAC	(CC1)		/CLEAR STATUS, DISABLE INTER, AND DCH.
	CRLC			/LOAD FUNCTION.
	.ENDC
	.IFDEF	UC15
	JMS	CLEAR	/CLEAR OUT PIREX DEVICE, WAIT FOR COMPLETE
	LAC	EV11K	/FIND OUT IF OK
	RTL		/PDP11 SIGN BIT TO OURS
	SMA		/SKIP IF TROUBLE
	JMP	WFTGR	/NOT, GO WAIT FOR WORK
	CAL	MSINIT	/PRINT PIREX HAS NO CD MESSAGE
	CAL	WFMS	/WAIT FOR MESSAGE COMPLETION
	CAL	(10	/EXIT
/
WFMS	20
	EV
MSINIT	2700
	EV
	ERRLUN
	2
	INITMS
INITMS	004002; 000000; .ASCII "*** NO CD IN PIREX"<15>
	.ENDC
	JMP	WFTGR		/WAIT FOR TRIGGER

/
HNAM	.SIXBT	'CD@@@@'	/HANDLER TASK NAME
/
	.IFUND	UC15
/
	.BLOCK	121+START-.
/
	.ENDC
/
	.IFDEF	UC15
/
	.BLOCK	53+START-.
/
	.ENDC
/ ***** END OF INITIALIZATION CODE *****

/
/******** THE ABOVE CODE IS OVERLAYED BY THE INTERNAL BUFFER ******
/******************************************************************
/
/  UC15  INTERRUPT-CAL INTERACTION WILL BE DIFFERENT
/    KEEP INITIAL PART SEPARATE
/
	.IFUND	UC15
/
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	/DEQUE 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
/
	.ENDC
/
	.IFDEF	UC15
/  UC15 CODE
/
/    THE GENERAL IDEA IS THAT ALL WAITS ARE DONE THRU
/  THE TRIGGER, WE FIGURE OUT HERE WHO SET THE TRIGGER. THIS
/  ALLOWS US TO GET OUT OF HUNG DEVICE, SINCE WE WAIT HERE,
/  AND CAN SEE AN ABORT COMING THRU.
/
WFTGR	CAL	WFTCPB	/WAIT FOR EVENT VARIABLE TG
PQ	LAC	TG	/FIND OUT WHO IS CALLING
	DZM	TG	/RESET
	RTL		/ABORT BIT TO SIGN BIT
	SPA!CLA!IAC	/SKIP IF NOT ABORT, 1 IN AC.
	JMP	PQ1	/GO DO ABORT IN REGULAR WAY. THE HANGING
/			/READ IS REMEMBERED IN RRN!
	SAD	CDON	/HAS A CARD BEEN DECLARED DONE BY INTERRUPT
	JMP	GOTCRD	/YEAH, GO TRANSLATE IT
	SAD	POST	/ARE WE WAITING FOR INTERRUPT
	JMP	WFTGR	/YES, AND IT HASN'T HAPPENED YET, SINCE
/			/CDON NOT SET. WAIT ON THIS CAL REQ, TO BE
/			/DONE AFTER THE INTERRUPT HAPPENS. IF ABORT
/			/COMES IN THE MEANTIME, HE IS PUT AT HEAD
/			/OF DEQUE OF WAITING REQ.'S SO WE DO HIM.
/
PQ1	LAC	PDVNA	/TRY TO DEQUE AFTER OPERATION BEFORE WAITING
	DAC*	(R1	/IN CASE WAITING FOR INTERRUPT HAS HELD OFF
	JMS*	(DQRQ	/A REQUEST.
	JMP	WFTGR	/DIDN'T FIND ONE, GO WAIT
/
	.ENDC
/
	DAC	RN		/YES -- SAVE ADDRESS OF REQUEST NODE
	TAD	XADJ		/SETUP XR TO ACCESS NODE
	PAX
/
/ ***** 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.
	.IFUND	UC15
	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-1)	/SET INTERN. BUFF ADDR-1 TO DCH CA.
	DAC*	(CCA)
	DZM*	(CWC)	/PREVENTS DOUBLE INTERRUPTS ON ERRORS!!!!
	LAC	TCWC		/RESTORE REQ. WC.
	DAC	CDWDCT
	DZM	EV1		/REINIT EV.  RETRY FROM ERROR.
	CRRS			/READ STATUS IN ORDER TO CHECK FOR READER READY

	AND	(60)		/AND ON-LINE.

	SAD	(60)		/STATUS BITS 12, 13 SET?
	SKP			/YES, ON-LINE AND READY FOR READ.
	JMP	ERR1		/NO, NOT READY.  TYPE MSG1 AND WAIT FOR READY.
	LAC	(CC2)		/CONDITION CODE 2 -- READ CARD.

	CRLC			/LOAD CONDITIONS.
	CAL	WFCRCB		/WAIT FOR INTERRUPT.

/

/
/
/UPON RESUMPTION FOLLOWING WAITFOR, EXAMINE EV AND TAKE THE FOLLOWING
/ACTION:
/
/IF EV BIT 9 = 0 (TROUBLE BIT), NO ERRORS.  TRANSLATE CARD PUNCHES
/TO ASCII AND PASS TO USER AS 5/7 PACKED ASCII.
/IF BIT 9 = 1 (TROUBLE BIT), ERROR BITS 08 TO 04 ARE CHECKED IN
/DESCENDING NUMERICAL ORDER.  THE FOLLOWING ERROR MESSAGES FOR THE
/GIVEN ERROR CONDITIONS ARE OUTPUT:
/
/DATA MISSED OR PHOTO ERROR - '*** CD DATA MISSED/PHOTO ERROR'
/PICK OR MOTION ERROR - '*** CD PICK ERROR'
/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 INTERR. LEVEL TO CONTENTS OF
	DAC	TST		/STATUS.  SAVE TEMP.
	SWHA			/SWAP HALVES FOR TROUBLE BIT CHECK.
	SMA!RAR			/IF NEG.,TROUBLE.
	JMP	TRANS		/NO TROUBLE.  GO TRANSLATE.
	SZL!RAR			/DATA MISSED?
	JMP	ERR4		/YES.
	SZL!RAR			/NO.  HOPPER EMPTY/STACK. FULL?
	JMP	TRANS		/YES. IGNORE.  WHEN NEXT CRD. READ CAUGHT AS NOT READY.
	SZL!RAR			/PICK ERROR?
	JMP	ERR3		/YES.
	SZL!RAR			/MOTION ERROR?
	JMP	ERR3		/YES.
	JMP	ERR4		/NO.  MUST BE PHOTO ERROR.
/
/
ERR4	ISZ	ERRPT
ERR3	ISZ	ERRPT
ERR2	ISZ	ERRPT
ERR1	LAC*	ERRPT		/ERRMSG. BUFFER ADDR. TO AC.
	JMS	TTYOUT		/TYPE MESSAAE.
	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)
/
/  NOW BRING BACK RN FROM RRN, IN CASE RN DESTROYED IN MEANTIME
/
	LAC	RRN
	DAC	RN
	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

	TAD	(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
/
	.ENDC
/
	.IFDEF UC15
/
/   IN THE CASE OF THE UNICHANNEL, WE RECIEVE A 42(10) WORD
/  BUFFER. THE FIRST WORD IS A BYTE COUNT (NOW ALWAYS 80(10)).
/  NOTE THAT AN EOF CARD HAS A BYTE COUNT OF 1!!
/  SPOOLER DOES CHECKSUM CALCULATION, NOT US.
/  THE SECOND IS A CHECKSUM SO ENTIRE BUFFER ADDS TO 0
/  !!!###MODULO 2^16 THAT IS###!!!. THEN ARE 40(10) WORDS
/  OF 'COMPRESSED COLUMN'. (SEE CR-11 DRIVER MANUAL). EACH
/  WORD HAS TWO EXTRANEOUS BITS AT LEFT, THE !SECOND CHAR!
/  OF THE PAIR, AND FINALLY THE FIRST CHAR OF PAIR AT RIGHTMOST
/  OF WORD. THE PDP-11 HAS ALREADY CHECKED FOR VALID PUNCH
/  COMBINATIONS (64 VALID CARD ASCII, PLUS 12-1-8 FOR ALTMODE).
/
RETRY	CLA!IAC		/SET VARIABLE SAY8ING WE'RE WAITING FOR
	DAC	POST	/INTERRUPT
	DZM	CDON	/AND SAY WE HAVEN'T GOTTEN IT YET
	LAC	TCBP	/ADDR OF TABLE TELLING PDP-11 TO READ CARD
	JMS	CDIU	/ROUTINE TO SEND REQUEST TO PDP-11
	JMP	WFTGR	/WAIT FOR COMPLETION INTERRUPT
/
/  COME BACK HERE WHEN CARD IS READ
/
GOTCRD	LAC	RRN	/RESTORE RN NODE
	DAC	RN
	DZM	POST	/CLEAR INTERRUPT FLAGS
	DZM	CDON	/BEST TO CLEAR POST FIRST!
	LAC	EV11	/EVENT VARIABLE FROM PDP-11
	RTL		/PDP-11 SIGN BIT TO OUR SIGN BIT
	SPA!CLL!RAR	/SKIP IF OK, START CLEARING HIGH BITS
	JMP	CDUCEC	/GO CHECK WHICH KIND OF PIREX ERROR
	LAC	TX12	/SETUP X12,X13 FOR USER BUFFER
	DAC*	(X12	/MANIPULATIONS. X12 HEADER POINTER
	LAC	TX13	/X13 DATA POINTER
	DAC*	(X13
	LAC*	(IBUF+2	/GET FIRST CHARACTER PAIR (2 WORD HDR)
	AND	(177777	/AND OFF MOVEBYTE BITS (EDIT 22)
	SAD	(104611	/SPOOLER USES AN ALT-ALT CARD AS AN END
/			/OF DECK CARD, WE SHOULD IGNORE IT!!
	JMP	RETRY	/IT WAS ONE, JUST READ THE NEXT CARD
	AND	(340	/12,11,0 PUNCHES IN FIRST COLM.=EOF
	TAD	(445	/IF IT IS ONE, MAKE A 1005
	SAD	(1005	/WELL, IF SO GO LACE 1005 AS HEADER
	JMP	REQCMA	/EOF CARD, JUST SET HEADER.
/
	LAC	(IBUF+2	/DATA STARTS AT BUFF+2
	CLL!RAL		/TOP 17 BITS ADDRESS, LAST IS RIGHT-LEFT FLOP
	DAC	CDIPTR	/TO GET INCOMING CHAR'S
	LAW	-120	/80 CHAR'S
	DAC	CDCOLC	/NOTE WE USE COUNTERS DIFERENT ALSO
PKINT	LAC	PAKI	/INIT 5/7 PACKER TO EXPECT
	DAC	PAKSW	/1ST CHAR OF A BUNCH OF FIVE
	LAC	CDWDCT	/WE USE AS COUNT OF PAIRS, NOT WORDS
	CLL!RAR		/SO DIVIDE BY TWO
	DAC	CDWDCT
CDRML2	LAC	CDIPTR	/WATCH IT! TOP 17 BITS ADDR, LOW BIT LEFT
	ISZ	CDIPTR	/RIGHT FLIP-FLOP. AND!! POINTER POINTS TO
/			/NEXT CHAR, NOT LAST ONE RETREIVED.
	CLL!RAR		/FLIP-FLOP TO LINK, ADDR AC
	DAC	CDT1	/HOLD POINTER IN TEMPORARY
	LAC*	CDT1	/GET CHARACTER PAIR
	SZL!RAL		/THESE THREE GET CORRECT CHAR
	SWHA!SKP	/TO LOW ORDER 8 BITS OF WORD
	RAR
	AND	(377	/STRIP OTHER CHARACTER
/			/AT THIS POINT HAVE CLOMNS 12,11,0,9,8,1-7
/			/WHERE 1-7 CODED IN THREE BITS
	DAC	CDT1	/HOLD
	SAD	CDALT	/ALT MODE SPECIAL CASE, NO REMAP
	JMP	CDGALT	/REJOIN AS SPECIAL CASE
	AND	(20	/IF NINE PUNCH, PECIAL CASE, REMAP TO 8,1 PUNCH
	SZA		/COMBO FOR OUR TRANSLATE. SKIP IF NOT NINE
	LAW	-7	/ADDED TO '9' GIVES '8' AND '1'
	TAD	CDT1	/REMAPPED, 
	DAC	CDT1	/SAVE, NOW TO MOVE BOTTOM FOUR BITS LEFT ONE
	AND	(17	/POSITION (9 POSITION NOW VACATED!)
	TAD	CDT1	/THIS DOES IT, LEAVING LOW ORDER BIT ZERO
/			/NOW COLUMNS 12,11,0,8,1-7,ZERO BIT!
	SKP!CLL		/HIDE YOUR HEAD. CLL FOR COMING RTR.SKIP
/			/OVER ALT-MODE RE-ENTRY
CDGALT	LAC	(240	/INDEX TO ALT MODE
	RTR		/RIGHT-LEFT TO LINK, INDEX TO AC
	TAD	(CDTABL	/TABLE ADDR
	DAC	CDT1
	LAC*	CDT1	/GET PAIR FROM TRANSLATE TABLE
	SNL		/HERE 0 IS LEFT, IN NORMAL SENSE
	SWHA
	JMS	PAK57	/5/7/ PACKER (IT STRIPS XTRA BITS)
	ISZ	CDCOLC	/80?
	JMP	CDRML2	/NO
	JMP	CDCLOS	/YES
/
/  TRANSLATE TABLE 4 GROUPS OF 16 CHAR'S, TWO PER WORD. 8 WORD
/  SPACE BETWEEN LAST TWO GROUPS, IN WHICH WE PUT OTHER STUFF
/  CONDITIONALIZED FOR 026-029 OF COURSE. LEFT HAND CHAR IS FIRST.
/
	.IFUND DEC026
CDTABL	040061	/BLANK, 1-PUNCH
	062063	/2-PUNCH,3-PUNCH
	064065	/4,5
	066067	/6,7
	070071	/8,9(ORDERED AS 8-1)
	072043	/8-2,8-3
	100047	/8-4,8-5
	075042	/8-6,8-7
	060057	/0,0-1
	123124	/0-2,0-3
	125126	/0-4,0-5
	127130	/0-6,0-7
	131132	/0-8,0-9(ORDERED AS 0-8-1)
	135054	/0-8-2,0-8-3
	045137	/0-8-4,0-8-5
	076077	/0-8-6,0-8-7
	055112	/11,11-1
	113114	/11-2,11-3
	115116	/11-4,11-5
	117120	/11-6,11-7
	121122	/11-8,11-9(ORDERED AS 11-8-1)
	041044	/11-8-2,11-8-3
	052051	/11-8-4,11-8-5
	073134	/11-8-6,11-8-7
	.ENDC
	.IFDEF DEC026
CDTABL	040061
	062063
	064065
	066067
	070071
	137075
	100136
	047134
	060057
	123124
	125126
	127130
	131132
	073054
	050042
	043045
	055112
	113114
	115116
	117120
	121122
	072044
	052133
	076046
	.ENDC
/
/  NOW THE 8 LOC. BREAK IN THE TABLE
/
/  THE 5/7 PACKER, A LITTLE TRICKY PAKSW KEEPS A PC WHICH
/  'REMEMBERS' WHICH CHARQCTER OF 5 WE ARE AT. TO INIT PACKER,
/  SEE TWO LINES OF CODE AT PAKINT. NORMAL 'FLUSH' OUT WOULD
/  BE TO SEND NUL CHAR'S UNTIL PAKSW=PAKI. IN THIS
/  HANDLER, PAST HISTORY SAYS WE TRUNCATE ALWAYS AT A WORD
/  PAIR BOUNDARY, EVEN FOR SHORT BUFFERS. I AM AFRAID TO
/  CHANGE THIS, EVEN THOUGH I DON'T LIKE IT.
/
PAK57	0		/CALL WITH CHAR IN AC, (DESTROYED)
/			/PUSHES CHAR'S THRU X13. EARLY END CHECK
/			/IN CDWDCT.
	AND	(177	/STIP XTRA
	CLL		/FOR ALL ROTATES AND SWAPS!
	JMP*	PAKSW	/TO WHATEVER ACTION THIS CHAR. NEEDS.
PAKSW	HLT		/POINTER TO ACTINS FOR CHARACTER
	JMP*	PAK57	/THAT'S ALL, OUT
PAKI	PAKST		/INIT PAKSW FOR FIRST CHAR.
PAKT	0		/TEMPORARY FOR PARTIAL WORDS
/
/  REST OF TRANSLATE TABLE
/
	.IFUND DEC026
	046101	/12,12-1
	102103	/12-2,12-3
	104105	/12-4,12-5
	106107	/12-6,12-7
	110111	/12-8,12-9(ORDERED AS 12-8-1)
	133056	/12-8-2,12-8-3
	074050	/12-8-4,12-8-5
	053136	/12-8-6,12-8-7
	.ENDC
	.IFDEF DEC026
	053101
	102103
	104105
	106107
	110111
	077056
	051135
	074041
	.ENDC
	175000		/ALT MODE, FOR BOTH PUNCH SETS.
/
/  NOW REST OF 5/7 PACKER
/
PAKQ	JMS	PAKSW	/5TH CHAR WRAP BACK TO 1ST. JMS TO PAKSW
/			/LEAVES ADDR OF ACTION FOR 1ST.!.
PAKST	RTL		/1ST CHARACTER ACTION, MOVE TO LEFT OF WORD
	SWHA
	DAC	PAKT	/HOLD AS PARTIALLY ASSEMBLED WORD
	JMS	PAKSW	/LEAVE POINTER TO 2ND CHAR
/
	RTL		/2ND CHAR ACTION
	RTL
	XOR	PAKT	/MARGE WITH FIRST
	DAC	PAKT	/WAIT FOR PART OF 3RD TO FILL WORD
	JMS	PAKSW	/LEAVE POINTER TO THIRD
/
	RTR		/3RD, TWO PARTS, FIRST IS TOP 4 BITS
	RAR		/RIGHT JUSTIFIED 1ST WORD OF PAIR
	DAC	PAKSW	/VERY-TEMPORARY IN HERE
	AND	(17	/ZAP OTHER BITS
	XOR	PAKT	/COMPLETE 1ST WORD OF PAIR
	DAC*	X13	/PLACE IN USER BUFFER
	LAC	PAKSW	/GET BACK THIRD CHAR (LINK STILL OK!!!)
	RAR		/2ND JOB, LOW THREE BITS OF CHAR TOP OF
	AND	(700000	/2ND WORD OF PAIR
	DAC	PAKT	/WHEW!, HOLD THAT IN PARTIAL WORD
	JMS	PAKSW	/LEAVE POINTER FOR FOURTH
/
	SWHA		/4TH, SNUG UP TO 3 BITS ON TOP
	RAR
	XOR	PAKT	/TOGETHER
	DAC	PAKT
	JMS	PAKSW	/LEAVE POINTER FOR 5TH
/
	ISZ	CDWDCT	/OVERFLOW SHORT BUFFER?
	SKP!RAL		/NO,  RAL LEAVE XTRA BIT OF PAIR ON RIGHT
	JMP	CDVER2	/UH-OH, GO CORRECT
	XOR	PAKT	/COMPLETE 2ND WORD OF PAIR
	DAC*	X13	/PLACE
	JMP	PAKQ	/GO PLACE PAKSW FOR FIRST CHAR OF FIVE
/
CDALT	211
CDIPTR	0		/POINTER TO INPUT DATA IN INPUT BUFFER
/			/FRMAT. LOW BIT RIGHT-LEFT FLIPFLOP
/			/TOP 17 BITS ADDRESS
CDT1	0		/TEMPORARY FOR TRANSLATION
POST	0		/0 WHEN NOT WAITING FOR INTERRUPT, 1 WHEN YES.
	.ENDC

/ 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	CDCOLC		/CDCOLC IS NEGATIVE
	AAC	22
	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
REDCOM	LAW	-1	/SET RRN, SAYING NO MORE READ OUTSTANDING
	DAC	RRN
REQCMP	CLA!IAC
SEV	JMS	SEVRN	/SUB. TO SET EV, RETURN NODE
	JMP	PQ	/GO LOOK FOR MORE WORK
/
/
/   SEVRN
/
/
/  ROUTINE  IS CALLED WITH VALE FOR EV IN AC
/  THE NODE ADDR. IS IN RN
/
/  EV IS SET, SIGNIFICANT EVENT DECLARED, IOCD ODOE, NODE RETURNED.
/
SEVRN	0
	PAL			/SAVE AC VALUE
	LAC	RN	/NODE ADDR
	DAC*	(R2	/SYSTEM ARGUMENT HOLDER
	TAD	XADJ	/ADJUST FOR PREESENT PAGE
	PAX		/FOR XR ADDRESSING
	LAC	6,X	/EVENT VARIABLE ADDRESS
	SNA		/SKIP IF REALLY ONE
	JMP	NOSET	/NOPE, SO DON'T SET
	TAD	XADJ	/MODIFY IT FOR ADDRESSING
	PAX
	PLA		/BRING BACK SETTING VALUE
	DAC	0,X	/THERE IT GOES!
NOSET	LAC	(401000	/DECLARE A SIGNIFICANT EVENT
	ISA
	LAC	(POOL	/GIVE NODE TO POOL
	DAC*	(R1	/SYSTEM ARGUMENT REG
	JMS*	(IOCD	/DECREMENT IO COUNT
	JMS*	(NADD	/GIVE BACK NODE
	JMP*	SEVRN	/THAT/S IT
/
/
/
/ ***** 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
/
	.IFUND	UC15
/
AEVM6	LAW	-6		/ILLEGAL FUNCTION.
	JMP	SAEV		/SET ABORT EV.
/
/ON ILLEGAL CARD PUNCH, WAIT FOR READER NOT READY FOLLOWED BY
/READER READY SEQUENCE BEFORE READING ANOTHER CARD.
/
ILLCP	LAC	(ERRMG2)	/TYPE 'ILLEGAL CARD PUNCH'.
	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	CRRS			/READ CARD READER STATUS.
	AND	(20)		/CHECK FOR READER READY FOR READ.
PV1	XX			/SNA OR SZA.  (READER READY IF NON-ZERO 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.
	LAC	(1)		/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	CLA!IAC			/SET CARD DONE FLAG.
	DAC	CDON
	JMP	CDABRT		/PROCEED WITH ABORT.
/
	.ENDC
	.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)
	.IFUND	UC15
	LAC	(CC1)		/CONDITION CODE 1 -- CLEAR CONTROL.
	CRLC
	CAL	DCPB		/DISCONNECT
	.ENDC
	.IFDEF	UC15
	JMS	CLEAR	/CLEAR DEVICE , WAIT FOR COMPLETION
	ISZ	CCPB		/MAKE CONNECT A DISCONNECT (BURP)
	CAL	CCPB		/DISCONNECT
	.ENDC
	ISZ	PDVTA		/POINT TO ASSIGN INHIBIT FLAG

	.INH			/INHIBIT INTERRUPTS.
	DZM*	PDVTA		///ZERO IT

	.ENB			///ENABLE INTERRUPTS.
	CAL	(10)		///EXIT
/
/
/ABORT REQUEST.
/
CDABRT	LAW	17000	/MASK TO KEEP HALF WORD TO CHECK ABORT VALIDITY
	AND	5,X	/HAS TO BE ZERO TO BE OK
	SZA		/SO SKIP IF OK
	JMP	EVM6	/ERROR RETURNED IF NOT
	LAC	PDVNA	/MT THE DEQUE FOR THE ABORTED TASK
	DAC*	(R1
	LAC	RN	/ABORT NODE
	DAC*	(R2
	JMS*	(DMTQ	/THIS ROUTINE DOES ALL WORK
/
/  NOW WAS THIS ABORT FOR AN OUTSTANDING READ?
/
	LAC	RN	/2+RN IS STL NODE ADDR
	TAD	XADJ	/USE AS IDENTIFIER
	PAX
	LAC	2,X
	SAD	STLA	/SAME ADDR FOR LAST READ DONE
	SKP!CLA!CMA	/SKIP IF SAME, SET UP -1
	JMP	REQCMP	/NOPE, WE'RE DONE, GO GIVE BACK NODE ETC.
	XOR	RRN	/NASTY, MAKES 0 IF NO READ NOW! IN PROGRESS
	SNA!CMA		/SKIP IF READ IN PROGRESS, RECREATE ITS NODE ADDR!
	JMP	REQCMP	/NOPE, JUST COMPLETE
	DAC*	(R2	/GIVE BACK NODE AND IOCD FOR SUSPENDED READ
	LAC	(POOL
	DAC*	(R1
	JMS*	(IOCD
	JMS*	(NADD
	CLA!CMA		/SET READ NOT HERE SWITCH
	DAC	RRN
	.IFUND	UC15
	LAC	(CC1	/CLEAR DEVICE
	CRLC
	.ENDC
	.IFDEF	UC15
	JMS	CLEAR	/AND CLEAR FOR UNICHANNEL
	.ENDC
	JMP	REQCMP		/DONE
/
/
/
/
	.EJECT

/

/ INTERRUPT SERVICE ROUTINE

/
INT	0
	DBA
	DAC	START		/SAVE AC
	.IFUND	UC15

	CRRS			/READ STATUS INTO AC.
	DAC	EV1		/SAVE FOR TASK LEVEL PROCESSING.
	AND	(2)		/CARD DONE?  BIT 16.
	SNA
	JMP	INT1		/NO.  DON'T CLEAR CARD DONE.
	DAC	CDON	/PLACE 2 INTO CDON TO SAY DONE
	LAC	(CC3)		/YES.  CLEAR CARD DONE.  LEAVE
	CRLC			/INTERR. AND DCH ENABLED.
INT1	CRPC			/CLEAR ALL BUT CARD DONE.
	LAC	(CC4)		/ENABLE INTERRS.  DISABLE DCH
	CRLC			/NEEDED SINCE CRPC DISABLES INTERRS.
	.ENDC
/
	.IFDEF	UC15
	CAPI			/CLEAR FLAG FROM PDP-11
	LAC	POST	/ARE WE WANTING AN INTERRUPT
	SNA		/SKIP IF YES/USE VALUE TO SET
	JMP	INTAC	/NO DO NOTHING
	DAC	CDON	/AS FLAG TO DISTINGUISH CARD DONE FROM CAL
	DAC	TG	/AND SET TG TO WAKE UP CAL LEVEL
	.ENDC
	LAC	(401000)	/DECLARE SIGNIF. EVENT.
	ISA
INTAC	LAC	START		/RESTORE AC.

	DBR

	JMP*	INT
	.EJECT
/
	.IFUND	UC15
/SUBR. TO OUTPUT ERROR MESSAGES VIA ERRLUN.  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 DATA MISSED/PHOTO ERROR'<15>
ERRMG5=.
	.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
	.ENDC

	.EJECT

/
/ ***** INTERNAL VARIABLES *****
/
CDON	1		/CARD DONE FLAG.
TST	0		/TEMP STORAGE FOR STATUS.
STLA	0		/STL NODE. ADDR.
ARE	0		/ABORT REQ. EV.
CDCOLC	0		/CARD COL COUNT USED IN TRANSLATING CARDS

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
CDRVAL	0		/BUFFER OVERFLOW FLAG WORD
CDWDCT	0		/WORD COUNT CHECK WORD SET FROM I/O REQUEST
/
	.IFUND	UC15
/
/  SAVE SOME ROOM FOR UC15, THESE ARE NOT NEEDED
/
ICA	0		/INTERNAL BUFFER CURRENT ADDRESS POINTER
CDR7CT	0		/SEVEN COUNTER USED BY THE 5/7 ASCII PACKING ROUTINE

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		//
EV1	0		/CARD READER EV.
/
	.ENDC
/
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.
/
	.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
/
	.IFUND	UC15
/
/  UC15 SAVE SPACE BY LEAVING OUT SOME CAL'S
/

/

/

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 ERRLUN.
	EV
	ERRLUN		/WRITE OUT THE ERROR MESSAG TO THE DESIRED
			/TELETYPE
	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
/
	.ENDC
/
/
	.IFDEF	UC15
/
/  I/O INFORMATION , ROUTINES , ETC. FOR UC15
/
/  TCB (TASK CONTROL BLOCK) TELLING PDP-11 TO SEND US A CARD
/
TCB	APISLT*400+APILVL	/TELL PDP-11 WHERE TO COME BACK
	DEVCOD			/PIREX CODE FOR CD;THE 200 BIT SAYS
/				/WE ARE NOT TO BE SPOOLED.
EV11	0			/EVENT VARIABLE FROM PDP11 TO US
	0			/DUMMY, HIGH PORTION OF 18 BIT
/				/ADRESS. NOT PRESENTLY USED
	IBUF			/POINTER TO BUFFER TO PUT CARD IN
	0			/UNIT #; FOR FUTURE GENERATIONS.
/
/  TCB TO TELL PDP11 TO CLEAR OUT CARD READER DEVICE
/
TCBK	0		/THIS WORKS, SEE PIREX FOR INFO.
	DEVCOD&177*400+200
EV11K	0		/EVENT VARIABLE FOR CLEAR OPERTAION
/
/  POINTERS TO TCB, TDBK
/
TCBP	TCB
TCBKP	TCBK
/
/
/  CDIU IS THE SUBROUTINE TO SEND A TCB TO THE PDP-11
/
/  CAL WITH THE ADRESS OF THE TCB IN THE AC
/
CDIU	0
	DZM	EV11	/CLEAR ONE COMING FROM PDP-11
	DZM	EV11K	/AND THE OTHER ONE, IN CASE IT  USED
	SIOA		/SKIP IF PDP-11 CAN TAKE REQUEST
	JMP	.-1
	LIOR		/TELL IT TO DO TCB WHOSE ADDRESS IN AC
	JMP*	CDIU	/THAT'S ALL THERE IS TO IT.
/
/
/  CLEAR  CLEARS SWITCHES, AND CD IN PIREX, WAITS FOR COMPLETE
/
CLEAR	0
	DZM	POST
	DZM	CDON
	LAC	TCBKP	/TCB FOR CLEAR
	JMS	CDIU
	CAL	WFCLER	/WAIT FOR CLEAROUT
	JMP*	CLEAR
/
WFCLER	20
	EV11K
/  CDUCEC EXAMINES NEGATIVE EVENT VARIABLES FROM PIREX
/
CDUCEC	CLL!RAR		/CLEAR OTHER TOP BIT
	TAD	(600000	/SIGN EXTEND TO PDP-15 WORD
	SAD	(777001	/THIS ONLY 'LEGAL' VALUE AT PRESENT
	JMP	RETRY	/THAT SAYS PIREX IS OUT OF NODES,
/			/WE SHOULD TRY AGAIN TO GET ONE
	JMS	SEVRN	/OTHERS, RETURN NEG VARIABLE AS EV.
/			/THIS IS SLIGHTLY FLAKEY, BUT WE
/			/REALLY SHOULD NEVER GET HERE!?!?
	LAW	-1	/SAY NO MORE READ OUTSTANDING
	DAC	RRN
	JMP	PQ	/BACK TO LOOK FOR MORE WORK
/
/
	.ENDC
	.END START
