/ .... EDIT #17 .... 3 FEB 70
 
/COPYRIGHT DIGITAL EQUIPMENT CORPORATION    1969/1970
/MAYNARD,MASS.
/CDB -- IOPS ASCII ONLY CARD READER HANDLER.
/CDB---BACKGROUND-FOREGROUND MONITOR SYSTEM
/TALKS TO CR01E, CR02B, AND CR03B CARD READERS.
/(NEW ^R PROCESSING) 1-28-70
/CDN NOT READY, WHERE N=
/    1     HOPPER EMPTY
/    2     FEED CHECK OR NO PASS.
/    3     ILLEGAL HOLLERITH CODE.
/    4     COLUMN COUNT ERROR
/    5     BAD DATA (CR03B ONLY)
/
/
/
/END-OF-FILE:
/	EOF CARD (ALL 1'S IN COLUMN 1)
/	EOF BUTTON DEPRESSED WITH HOPPER EMPTY
.MED=3
.SCOM=100
/
/--------------- CRO3B
/
	.IFUND	NOTGDI
CRSC=706722	/SELECT A CARD
CROR=706702	/IOR DATA AND STATUS INTO AC
CRCS=706704	/CLEAR STATUS REGISTER AND DATA BUFFER
CRSI=706721	/SKIP IF COR INTERRUPT IS SET
CRLA=706724	/IOR DATA BUFFER AND STATUS REGISTER INTO AC.
CROC=706716	/CLEAR AC,IOR DATA+STATUS,CLEAR STATUS
	.ENDC
/-----
/
	.IFDEF	NOTGDI
CRSI=706701		/SKIP ON COLUMN READY FLAG.
CRSD=706721		/SKIP ON CARD DONE FLAG.
CRCD=706724		/CLEAR CARD DONE FLAG.
CRSC=706744		/SELECT CARD, BINARY MODE.
CRRB=706752		/READ BUFFER, BINARY MODE.
CRSR=706741		/SKIP ON READER READY.
CREF=706761		/SKIP ON EOF BUTTON (CR02 ONLY)
	.ENDC
	.GLOBL	CDB.
CDB.	JMS	SWAP
	0		/ FOREGROUND BUSY REGISTER
	0		/ BACKGROUND BUSY REGISTER
	0		/ FOREGROUND .CLOSE REGISTER
	0		/ BACKGROUND .CLOSE REGISTER
CDSWCH	XX		/ ION OR IOF
CDWD6	XX		/ ION OR IOF  OR DBR
CDOUT	XX		/RETURN POINTER
/ START OF BACKUP REGISTERS
/ THESE ARE ALSO LIVE DATA REGISTERS
CDWD10	XX		/ JUMP TO FUNCTION
CDWD11	XX		/ CAL OWNER (0=F,1=B)
CDWD12	XX		/ .DAT SLOT NUMBER
CDWD13	XX		/ UNIT NUMBER - CAL ADDRESS.
CDWD14	XX		/MODE
CDRLBH	XX		/ADDRESS
CDWD16	XX		/WORD COUNT-INIT HAS REG TO STORE BUFFER SIZE
CDWD17	XX		/REAL OR NOT REAL - PRIORITY LEVEL IN BITS 0-2
/  END OF BACKUP DATA REGISTERS
	JMP CDINIT	/1 -- .INIT
CD7700	LAW 10000		/2 -- .OPER (IGNORED)
	JMP	CDIN	/3 -- .SEEK (IGNORED)
CD7740	LAW	14000	/4-- .ENTER (ILLEGAL)
	JMP	CDER06	/5-- .CLEAR (ILLEGAL)
CDFINI	JMP CDIGNR	/6 -- .CLOSE
	JMP CDIGNR	/7 -- .MTAPE (IGNORED)
CDRDPT	JMP CDREAD	/10 -- .READ (REALR)
	JMP	CDER06	/11-- .WRITE (ILLEGAL)
CDSTPS	0		/WAIT,WAITR - STOP I/O SWITCH.
	JMP	CDER06	/TRANSFER (ILLEGAL)
SCOM35	XX		/SAVE SCOM+35 LOC
	CDSTP		/FGD STOP IO
	CDSTP		/BGD STOP IO
CDID	0		/HANDLER ID
	.EJECT
/ SWAP I/O ROUTINE
SWAP	0
	XCT	CDB.+5	/ION OR IOF
	DBK		/FROM LEVEL 0
	JMP*	SWAP
/ STOP IO SUBROUTINE
CDSTP	0
	JMS	CDRAIS	/LV0, IOF
	LAC	CDCTLR	/DO NOT HANG IF
	SZA!CLA		/^R IN PROGRESS.
	JMP	CDCLER
	LAC	CDB.+1
	TAD	CDB.+2
CDCLER	DAC	CDSTPS	/0 IF NO I/O UNDERWAY.
CDFBSY	DZM	CDB.+1	/CLEAR IO BUSY SWITCHES
	DZM	CDB.+2
	DZM	CDB.+3	/CLEAR CLOSE SWITCHES
	DZM	CDB.+4
	DZM	CDCTLR	/^R FLAG.
	JMS	CDLOWR	/NON-PROTECTED SEQUENCE
	LAC	CDSTPS
	SZA		/WAIT UNTIL LAST INTERRUPT ARRIVES BEFORE EXITING
	JMP	.-2
	JMP*	CDSTP
CDCTLR	0		/^R IN PROGRESS IF NON-0.
/RAISE TO API LEVEL 0
/ TURN  OFF PIC
CDRAIS	0
	LAC	(400200
	ISA
CDIOF	IOF
	JMP*	CDRAIS
/DEBREAK FROM API LEVEL 0
/ TURN ON PIC
CDLOWR	0
	DBK
CDION	ION
	JMP*	CDLOWR
/SUBROUTINE TO CLEAR FLAGS
CDFLAG	0
	LAC	CDWD11	/0=FGRD, 1=BGRD
	TAD	CDFBSY	/DZM CDB.+1
	DAC	CDCLR	/CLEAR BGD OR FGD ON EXIT
	JMP*	CDFLAG
/SUBROUTINE TO CAUSE OUTPUTTING OF ERROR MESSAGE
CDWDCT=.
CDBERR	0
	DAC	CDLAW	/LAW CODE
	LAC*	(.SCOM+66
	DAC	CDTMP1
	JMS	CDRAIS	/PROTECTED SEQUENCE
CDLAW	XX		/LAW CODE
	JMS*	CDTMP1	/PRINT MESSAGE
CDTAUX	XX		/CALL ADDRESS.
	JMS	CDLOWR	/NON-PROTECTED SEQUENCE
	JMP*	CDBERR
	.EJECT
/ROUTINE FOR ILLEGAL FUNCTIONS
CDER06	LAW	5006	/ILLEGAL FUNCTION CODE
	DAC	CDTMP1
	LAC	CDWD13
	DAC	CDTAUX	/CAL ADDRESS.
	LAC	CDWD11
	SZA		/FGD
	LAC	(3000	/BGD
	XOR	CDTMP1
	JMS	CDBERR	/PRINT ERROR MESSAGE
/ROUTINE TO IGNORE CALL
CDIGNR	JMS	CDFLAG
/ COMMON EXIT SEQUENCE FOR CAL AND INTERRUPT
CDEXIT	LAC*	(.SCOM+54	/ADDRESS OF CALL4
	DAC	CDTMP1
	JMS	CDRAIS	/RAISE TO API LEVEL 0 + TURN OF PIC
	LAC	CDWD6
	SAD	CDDBR
CDSKP	SKP
	JMP	CDT.6	/CAL
	JMS*	CDTMP1	/INTERRUPT
	CDB.+7		/PC
	SCOM35
CDT.6	LAC	SCOM35
	DAC*	(.SCOM+35
CDCLR	NOP		/DZM CDB.+1(2) IF BUSY FLAG TO BE CLEARED.
CDIOT	NOP		/IOF OR IOT
	LAC	CDNOP
	DAC	CDCLR
	DAC	CDIOT
	LAC	CDSVAC	/RESTORE AC
	DBK		/EXIT FROM LEVEL 0
	XCT	CDB.+5	/ION OR IOF
	XCT	CDB.+6	/ION OR IOF OR DBR
	XCT	.+1
	XCT	.+1
	JMP*	CDB.+7	/RETURN
	.EJECT
/ INITIALIZATION ROUTINE
CDINIT	LAC	(44	/36 (DEC)
	DAC*	CDB.+16	/STANDARD BUFFER SIZE
CDIN	LAC*	(.SCOM+55
CDTLEN	DAC	CDIN
CDTMP1	JMS*	CDIN	/CALL .SETUP
CDCOLC	CRSI		/COLUMN READY IOT
CDSVAC	CDRINT		/INTERRUPT PROCESSOR
	.IFDEF	NOTGDI
CDRWD1	JMS*	CDIN	/CALL .SETUP
CDRWD2	CRSD		/CARD DONE IOT
	CDRINT
	.ENDC
CDCPTR	LAC	CDFINI	/JMP CDIGNR
CDIPTR	DAC	CDIN
CDLPTR	JMP	CDIGNR
	.EJECT
/READ ROUTINE
CDREAD	LAC	CDB.+14	/GET MODE
	SAD	(2
	JMP	.+3	/IOPS ASCII
	LAW	5007
	JMP	CDER06+1
	JMS	CDINPT
	JMP	CDLAW1	/NOT READY RETURN
	LAC	CRSCL
	DAC	CDIOT
	JMP	CDEXIT
/SUBROUTINE TO INITIATE READING OF A CARD.
/CALLING SEQUENCE:
/	JMS CDINPT
/	(NOT READY RETURN)
/	(READY RETURN)
CDINPT	0
	LAC	CDWD16	/WORD COUNT.
	DAC	CDWDCT
	.IFDEF	NOTGDI
	CREF		/EOF OR HOPPER EMPTY?
	JMP	CDOK	/NO.
	JMP	CDEOF
	.ENDC
CDOK	LAC	(CDBUFF	/80 WORD BUFFER.
	DAC	CDIPTR
	DZM*	CDIPTR	/CLEAR 1ST WORD.
	DZM	CDRVAL	/CLEAR HDR CODE AC.
	LAC	CDRLBH
	TAD	(2	/POINTER TO 1ST
	DAC	CDLPTR	/DATA WORD.
	LAC	CDIN
	SAD	CDFINI	/JMP CDIGNR
	JMP	.+3	/OK.
	LAW	5060	/.READ
	JMP	CDER06+1	/BEFORE .INIT.
M120	LAW	-120
	DAC	CDCOLC	/COLUMN COUNTER.
	.IFDEF	NOTGDI
/CHECK IF READER READY.
	CRSR		/READY?
	JMP*	CDINPT	/NO
	.ENDC
	ISZ	CDINPT	/BUMP EXIT.
	JMP*	CDINPT
	.EJECT
/SUBROUTINE TO CALL A ROUTINE IN THE RESIDENT
/MONITOR TO INITIATE A NOT READY REQUEST.
/SUPPLEMENTARY INFO IN AC.
CDMSG	0
	RTR		/SUPPLEMENTARY
	RTR		/INFO.
	DAC	CDARG3
	LAC	CDCTLR	/^R FLAG
	SZA!CMA		/AVOID DUPLICATE CAU.
	JMP*	CDMSG
	DAC	CDCTLR	/SET ^R FLAG
	LAC	CDWD11	/0=FGRD, 1=BGRD
	DAC	CDARG1
	LAC*	(.SCOM+64	/POINTER TO ^R QUEUER
	DAC	CDTMP1
	JMS	CDRAIS	/LV0, IOF
	JMS*	CDTMP1	/GO TO ^R QUEUER
CDARG1	XX		/0=FGRD, 1=BGRD
	.ASCII	/CD/
	.LOC	.-1
CDARG3	XX		/TYPE OF CDN  NOT READY MESSAGE.
	CDFRA+200000	/SUBROUTINE ON
	CDFRA+200000	/^R.
	DZM	CDCTLR	/TERMINAL ERROR.
	JMS	CDLOWR	/ION, DBK
	JMP*	CDMSG
/SUBROUTINE ENTERED AT API LEVEL 2 WHEN
/^R FROM KEYBOARD IS ASSOCIATED WITH
/THE CARD READER.
CDFRA	0
	DZM	CDCTLR	/CLEAR ^R FLAG
	.IFDEF	NOTGDI
	CREF		/EOF?
	JMP	CDOK2	/NO.
	LAC	CDDBR	/SET UP FOR EOF REPORT
	DAC	CDB.+6	/AND EXIT VIA COMMON
	LAC	CDION	/EXIT ROUTINE.
	DAC	CDB.+5
	LAC*	(.SCOM+35
	DAC	SCOM35
	LAC	CDFRA
	DAC	CDB.+7
	JMP	CDEOF
	.ENDC
CDOK2	JMS	CDINPT
	JMP	CDNRDY	/NOT READY RETURN.
CRSCL	CRSC		/SELECT A CARD
CDOUT2	ION
CDDBR	DBR
	JMP*	CDFRA
CDNRDY	LAW	1
	JMS	CDMSG
	JMP	CDOUT2
	.EJECT
/SUBROUTINE CDRMAP.
CDRMAP	0		/ENTRY TO REMAP FROM COLUMN TO ASCII.
	LAC (CDBUFF	/GET COLUMN-DATA BUFFER.
	DAC CDIPTR	/SET UP INPUT POINTER.
	LAW -20
	DAC CDCOLC
CDRM5	LAC (CDCTAB	/5-CHARACTER POINTER.
	DAC CDR5CT	/..
CDRML2	LAC* CDIPTR	/ALT MODE(12,1,8 PUNCH)?
	SAD CDRALT
	JMP CDGALT	/YES
	LAC CDTABL	/GET TOP OF TABLE.
	DAC CDTPTR	/SET TOP OF CURRENT TABLE
	LAC CDTLN1	/SET INITIAL (FULL) TABLE LENGTH.
CDRML4	DAC CDTLEN	/CURRENT LENGTH/2.
	ADD CDTPTR	/CURRENT TABLE TOP + LENGTH/2
	DAC CDCPTR	/CURRENT ITEM IN TABLE
	LAC* CDCPTR	/GET CURRENT ITEM.
	AND (7777		/THROW AWAY JUNK.
	SZA!CLL
	ADD CD7700	/REST OF 2'S COMPLEMENT WORD.
	TAD* CDIPTR	/CURRENT COLUMN
	SNA!CLA
	JMP CDCFND	/MATCH FOUND.
	SAD CDTLEN	/COLUMN .L. TABLE ENTRY AND CDTLEN .E. 0,
	JMP	CDHOL
	SNL		/L=0 JMP UP,L=1 JMP DOWN TABLE.
	JMP CDDPTR	/COLUMN .L. ENTRY.
	LAC CDCPTR	/SET TABLE TOP TO LOWER HALF.
	DAC CDTPTR	/NEW TABLE TOP.
CDDPTR	LAC CDTLEN	/UPDATE NEW TABLE LENGTH.
	CLL!RAR		/LENGTH = LENGTH/2
	JMP CDRML4	/GO GET NEW TABLE ENTRY.
CDGALT	LAW 4000		/ALT MODE
	JMP* CDR5CT
/COME HERE ON MATCH FOUND.
CDCFND	LAC* CDCPTR	/FOUND, GET CURRENT ENTRY.
	CLL!SMA		/GENERATE 7TH BIT.
	CML		/IT IS COMPLEMENT OF 6TH BIT.
	RAR
	AND	CD7740
CDCPUT	JMP*	CDR5CT	/GO TO APPROPRIATE
CDCTAB	JMP CDCN1		/CHARACTER PROCESSOR.
	JMP CDC2
	JMP CDC3
	JMP CDC4
	RAL!CLL		/5TH CHAR.
	RTL
	RTL
	RTL
	RTL
	XOR CDRWD2
	DAC CDRWD2
	LAC CDWDCT
	TAD (2
	DAC CDWDCT
	SMA
	JMP CDVER2
	LAC CDRWD1
	DAC* CDLPTR
	ISZ CDLPTR
	LAC CDRWD2
	DAC* CDLPTR
	ISZ CDLPTR
	ISZ CDIPTR
	ISZ CDCOLC
	JMP CDRM5
/THE BUFFER HAS BEEN REMAPPED.
/STORE A CARRIAGE RETURN IN
/THE TRAILER WORD AND SET UP
/THE HEADER WORD.
/
CDCLOS	LAC (64000	/CARRIAGE RETURN.
	DAC* CDLPTR
	LAC (22
	TAD CDCOLC
	CLL!RAL
	RTL
	RTL
	RTL
	RTL
	TAD CDRVAL	/ERROR CODES
	TAD (2		/IOPS ASCII
	DAC* CDRLBH
	JMP* CDRMAP
CDVER2	LAW -2		/SHORT BUFFER.
	TAD CDLPTR
	DAC CDLPTR
	LAC (60
	DAC CDRVAL
	JMP CDCLOS
CDHOL	LAW	3	/ILLEGAL PUNCH.
	JMP	CDER04
CDCN1	DAC	CDRWD1
CDCN3	ISZ	CDR5CT	/BUMP CHAR. POINTER.
	ISZ	CDIPTR
	JMP	CDRML2
CDC2	RAR!CLL
	RTR
	RTR
	RTR
CDCN2	XOR	CDRWD1
	JMP	CDCN1
CDC3	RTL
	RTL
	DAC	CDRWD2
	RAL
	AND	(17
	XOR	CDRWD1
	DAC	CDRWD1
	LAC	CDRWD2
	AND	(700000
CDCN4	DAC	CDRWD2
	JMP	CDCN3
CDC4	RAR!CLL
	RTR
	XOR	CDRWD2
	JMP	CDCN4
/TABLE OF CODES.
CDTABL	CDTABL+1
	400000		/BLANK
	710001\7777+1	/9	/THIS TABLE REPRESENTS A SIX-BIT CODE (LEFT-MOST)
	700002\7777+1	/8	/AND THE 2'S COMPLEMENT OF VALID ASCII
	670004\7777+1	/7	/CARD PUNCHES (RIGHTMOST 12 BITS). 7777+1 IS
	.IFUND DEC026
	420006\7777+1	/"	/ADDED TO THE 12 BIT CARD CODE TO GENERATE ITS
	.ENDC
	.IFDEF DEC026
	340006\7777+1	/(\) BACKSLASH 026 MODE
	.ENDC
	660010\7777+1	/6	/(12-BIT) RECIPROCAL BY THE ASSEMBLER.
	.IFUND DEC026
	750012\7777+1	/=	/
	.ENDC
	.IFDEF DEC026
	470012\7777+1	/(') QUOTE 026 MODE
	.ENDC
	650020\7777+1	/5	/IF THE PUNCHES IN A CARD COLUMN WERE
	.IFUND DEC026
	470022\7777+1	/'	/12-1 (A OR BINARY 4400) THE PROGRAM
	.ENDC
	.IFDEF DEC026
	360022\7777+1	/(^) UP-ARROW 026 MODE
	.ENDC
	640040\7777+1	/4	/WOULD JUMP HALFWAY INTO THIS TABLE AND
	000042\7777+1	/@	/PULL OUT A WORD. THE LEFTMOST 6-BITS.
	630100\7777+1	/3	/WOULD BE STRIPPED OFF AND REPLACED BY 77
	.IFUND DEC026
	430102\7777+1	/#	/TO COMPLETE THE NEGATION STARTED AT THE
	.ENDC
	.IFDEF DEC026
	750102\7777+1	/(=) EQUAL SIGN 026 MODE
	.ENDC
	620200\7777+1	/2	/ASSEMBLER LEVEL. THIS (NOW 18-BIT) NEGATIVE
	.IFUND DEC026
	720202\7777+1	/:	/NUMBER IS ADDED TO THE COLUMN BINARY A 0
	.ENDC
	.IFDEF DEC026
	370202\7777+1	/(_) LEFT ARROW 026 MODE
	.ENDC
	610400\7777+1	/1	/RESULT INDICATES A MATCH. A NON ZERO
	601000\7777+1	/0	/RESULT CAUSES A DECISION WHETHER TO JMP
	321001\7777+1	/Z	/HALFWAY INTO THE UPPER OR LOWER HALF,
	311002\7777+1	/Y	/EFFECTIVELY SHRINKING THE TABLE, UNTIL A
	301004\7777+1	/X	/MATCH IS FOUND.
	.IFUND DEC026
	771006\7777+1	/?	/
	.ENDC
	.IFDEF DEC026
	451006\7777+1	/(%) PER CENT SIGN 026 MODE
	.ENDC
	271010\7777+1	/W	/WHEN A MATCH OCCURS THE TABLE WORD IS
	.IFUND DEC026
	761012\7777+1	/>	/REFERENCED AGAIN TO GET THE ASCII
	.ENDC
	.IFDEF DEC026
	431012\7777+1	/(#) NUMBER SIGN 026 MODE
	.ENDC
	261020\7777+1	/V	/EQUIVALENT. IN THE EXAMPLE ABOVE
	.IFUND DEC026
	371022\7777+1	/_ (NUM. W)	/THE WORD POINTED TO BY A IS (013400).
	.ENDC
	.IFDEF DEC026
	421022\7777+1	/(") DOUBLE QUOTE 026 MODE
	.ENDC
	251040\7777+1	/U	/COMPLEMENT THIS NUMBER, CLEAR THE LINK,
	.IFUND DEC026
	451042\7777+1	/%	/AND ADD 400000 TO IT. (013400=764377)
	.ENDC
	.IFDEF DEC026
	501042\7777+1	/(()LEFT PAREN 026 MODE
	.ENDC
	241100\7777+1	/T	/(764377+400000)=364377 WITH LINK=1.
	541102\7777+1	/,	/
	231200\7777+1	/S	/COMPLEMENT THE RESULT (364377=413400)
	.IFUND DEC026
	351202\7777+1	/]	/XOR THE LEFTMOST BIT (41300=013400)
	.ENDC
	.IFDEF DEC026
	731202\7777+1	/(;) SEMI COLON 026 MODE
	.ENDC
	571400\7777+1	//	/ROTATE THE LINK INTO THE WORD AND
	552000\7777+1	/-	/STRIP OFF LOW ORDER 11-BITS.
	222001\7777+1	/R	/RESULT: A=(40400).
	212002\7777+1	/Q	/THIS RESULT IS SAVED AND SHIFTED LEFT
	202004\7777+1	/P	/7 TIMES. (404000=000101).
	.IFUND DEC026
	342006\7777+1	/\
	.ENDC
	.IFDEF DEC026
	462006\7777+1	/(&) AMPERSAND 026 MODE
	.ENDC
	172010\7777+1	/O
	.IFUND DEC026
	732012\7777+1	/;
	.ENDC
	.IFDEF DEC026
	762012\7777+1	/(>) GREATER THAN  026 MODE
	.ENDC
	162020\7777+1	/N
	.IFUND DEC026
	512022\7777+1	/)
	.ENDC
	.IFDEF DEC026
	332022\7777+1	/([) LEFT BRACKET  026 MODE
	.ENDC
	152040\7777+1	/M
	522042\7777+1	/*
	142100\7777+1	/L
	442102\7777+1	/$
	132200\7777+1	/K
	.IFUND DEC026
	412202\7777+1	/!
	.ENDC
	.IFDEF DEC026
	722202\7777+1	/(:) COLON  026 MODE
	.ENDC
	122400\7777+1	/J
	.IFUND DEC026
	464000\7777+1	/&
	.ENDC
	.IFDEF DEC026
	534000\7777+1	/(+) PLUS SIGN  026 MODE
	.ENDC
	114001\7777+1	/I
	104002\7777+1	/H
	074004\7777+1	/G
	.IFUND DEC026
	364006\7777+1	/^
	.ENDC
	.IFDEF DEC026
	414006\7777+1	/(!) EXCLAMATION  026 MODE
	.ENDC
	064010\7777+1	/F
	.IFUND DEC026
	534012\7777+1	/+
	.ENDC
	.IFDEF DEC026
	744012\7777+1	/(<)  .LESS THAN.  026 MODE
	.ENDC
	054020\7777+1	/E
	.IFUND DEC026
	504022\7777+1	/(
	.ENDC
	.IFDEF DEC026
	354022\7777+1	/(]) RIGHT BRACKET  026 MODE
	.ENDC
	044040\7777+1	/D
	.IFUND DEC026
	744042\7777+1	/<
	.ENDC
	.IFDEF DEC026
	514042\7777+1	/()) RIGHT PAREN  026 MODE
	.ENDC
	034100\7777+1	/C
	564102\7777+1	/.
	024200\7777+1	/B
	.IFUND DEC026
	334202\7777+1	/[
	.ENDC
	.IFDEF DEC026
	774202\7777+1	/(?) QUESTION MARK  026 MODE
	.ENDC
	014400\7777+1	/A
CDTLN1	.-1-CDTABL/2
CDRALT	4402
	.EJECT
/CARD READER INTERRUPT SECTION.
CDRINT	SKP		/PIC
	JMP	CDAPI	/API
	DAC	CDSVAC	/SAVE AC
	LAC*	CDID
	DAC	CDOUT	/SAVE PC,L,EM,MP
	LAC	CDION
	JMP	CDSTON	/TURN PIC ON ON EXIT
CDAPI	DAC	CDSVAC	/API ENTRY - SAVE AC
	LAC	CDRINT
	DAC	CDOUT	/SAVE PC,L,EM,MP
	DZM	CDRINT	/0=API ENTRY.
	IORS		/READ I/O STATUS
	SMA!CLA
	LAW	17740	/PIC OFF - BUILD IOF
	TAD	CDION	/PIC ON - BUILD ION
CDSTON	DAC	CDSWCH	/ION OR IOF ON EXIT
	LAC*	(.SCOM+35	/SAVE INTERRUPT HANDLER STATUS
	DAC	SCOM35
	CLA!CMA
	DAC*	(.SCOM+35	/SET INTERRUPT HANDLER STATUS
	LAC	CDRINT
	SZA
	DZM*	CDID	/PIC ENTRY - CLEAR WORD 0
	LAC	CDDBR
	DAC	CDWD6
	.IFDEF	NOTGDI
	CRSI		/SKIP ON COLUMN READY
	JMP CRDONE	/MAYBE DONE
	LAC CDCOLC	/COLUMN FLAG, GET CURRENT COUNT.
	RAL		/PUT OVERFLOW INDICATION IN LINK (0 IF SO).
	CRRB		/READ COLUMN, TURN OFF FLAG.
	ION
	SZL		/SKIP IF OVERFLOW HAS OCCURRED.
	.ENDC
/
/--------------------CRO3B
/
	.IFUND	NOTGDI
	CROC		
	ION
	SPA		/IF ERROR FLAG ON
	JMP CDRERR
	RCR
	SML
	JMP CRDONE
	RAR		/COLUMN READY
	AND (7777
	.ENDC
/
/-----
/
	DAC* CDIPTR	/OTHERWISE, INSERT THIS COLUMN IN BUFFER.
	ISZ CDIPTR	/BUMP BUFFER POINTER FOR NEXT TIME.
	ISZ CDCOLC	/COUNT 80 COLUMNS SERVICE.
CDNOP	NOP
	JMP	CDEXIT
CRDONE=.
	.IFDEF	NOTGDI
	CRCD		/CLEAR CARD DONE FLAG
	ION
	.ENDC
	LAC	CDSTPS
	DZM	CDSTPS
	SZA
	JMP	CDIGNR	/I/O STOPPED.
	LAC	CDCOLC
	SNA
	JMP	CDCNT
	SAD	M120
	JMP	CDPIK
	LAW	4	/MISSED COLUMN
	JMP	CDER04
CDPIK	LAW	2
	JMP	CDER04
/
/--------------------CR03B
/
	.IFUND	NOTGDI
CDRERR	AND	(340002
	SAD	(200002
	JMP	CRDONE	/HOPPER EMPTY - CARD DONE.
	SAD	(2
	JMP	CRDONE	/OUTPUT HOPPER FULL.
	SAD	(40002
	LAW	5	/BAD DATA
	SAD	(100000
	LAW	2	/NO PASS
	SAD	(300000
	.ENDC
CDLAW1	LAW	1	/INPUT HOPPER EMPTY
CDER04	JMS	CDMSG
	JMP	CDEXIT
/-----
/
CDCNT	LAC	CDBUFF	/EOF CARD(COLUMN 1=ALL 1'S)
	XOR (7777
	SNA		/NO
	JMP	CDEOF	/EOF CONDITION
CDINTX	JMS	CDRMAP
CDEMPT	JMS	CDFLAG	/CLEAR FLAGS
	LAC*	(.SCOM+52
	DAC	CDTMP1
	JMS	CDRAIS
	LAC	(CDB.
	JMS*	CDTMP1	/BUSY ROUTINE
	JMS	CDLOWR
	LAC	CDWD17
	SNA		/REALR?
	JMP	CDEXIT	/NO
	LAC	(JMP CDRDPT
	SAD	CDWD10
	SKP
	JMP	CDEXIT	/NO
	LAC*	(.SCOM+51	/YES
	DAC	CDTMP1
	JMS	CDRAIS
	LAC	CDWD17
	JMS*	CDTMP1
	JMS	CDLOWR
	JMP	CDEXIT
CDEOF	LAC	(1005	/EOF CODE
	DAC*	CDRLBH	/TO LINE
	JMP	CDEMPT	/BUFFER.
CDBUFF	.BLOCK 120	/80 COLUMNS.
CDTPTR=CDWD12
CDR5CT=CDWD13
CDRVAL=CDWD14
	.IFUND	NOTGDI
CDRWD1		/LOW ORDER 5/7 ASCII BUILDER
CDRWD2		/HIGH "     "    "      "
	.ENDC
	.END
