/3 CARD READER FOR BUILD
/
/
/
/
/
/
/
/
/
/COPYRIGHT  (C)  1974 BY DIGITAL EQUIPMENT CORPORATION
/
/
/
/
/
/
/
/
/
/
/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 RESPONSIBILITY
/FOR ANY ERRORS THAT MAY APPEAR IN THIS DOCUMENT.
/
/THE SOFTWARE DESCRIBED IN THIS DOCUMENT IS FURNISHED 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 PROVIDED IN WRITING BY DIGITAL.
/
/DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY FOR THE USE
/OR RELIABILITY OF ITS SOFTWARE ON EQUIPMENT THAT IS NOT SUPPLIED BY
/DIGITAL.
/
/
/
/
/
/
/
/
/
/
	*0
	-1
DEVICE CR8E;DEVICE CDR;2030;4000;ZBLOCK 2

	CDRVERSION="C&77

/V3 CHANGES:

/1.	VERSION # IS NOW 1
/2.	FIXED BUG FOR CARDS WITH ODD NUMBER OF COLUMNS
/3.	CARD DONE FLAG IS CLEARED AT END

	*200

RCSF=6631
RCRA=6632
RCSP=6671
RCSE=6672
RCRD=6674

CDR,	CDRVERSION	/ENTRY POINT RELATIVE ZERO
CDR770,	7700		/"SMA CLA" CLEARS THE AC
CDRTMP,	0		/LESS THAN 400 - PROTECTS THE "SMA CLA"
	JMP CDRSET	/INITIALIZATION - BECOMES "RDF"
	TAD CDRCIF	/FORM "CIF CDF N" TO CALLING FIELDS
	DCA CDRXIT	/SAVE CALLING FIELDS
	TAD CDRCCF-1
	DCA CDRXIT-1	/RESTORE THE "ISZ CDR"
	TAD I CDR	/GET FUNCTION WORD
	AND CDR070	/GET BUFFER FIELD BITS
	TAD CDRCCF	/MAKE A "CDF N"
	DCA CDBCDF	/SAVE IT IN THE GET CHAR LOOP
	TAD I CDR	/GET FUNCTION WORD AGAIN
	ISZ CDR
	SPA		/IS IT A WRITE FUNCTION?
	JMP CDRERR	/YES - HARD ERROR
	AND CDR770	/GET COUNT BITS
	CIA
	DCA CDRWC	/SAVE WORD COUNT (DIVIDED BY 2)
	TAD I CDR	/GET BUFFER ADDRESS
	DCA CDRCA	/AND SAVE IT
	ISZ CDR		/THE BLOCK NUMBER IS IGNORED
CDRCCF,	CDF		/WE ARE IN FIELD 0
	DCA I CDRIN2	/RESET ^Z FLAG TO ZERO
CDRLP,	JMS I CDRIN4	/GET A CHARACTER
	DCA CDRTM1	/DATA FIELD STILL ZERO ON RETURN!
	JMS I CDRIN4	/GET NEXT CHARACTER
	DCA CDRTMP	/AND SAVE IT
	JMS I CDRIN4	/GET NEXT CHARACTER
	RTL
	RTL		/GET THE FIRST FOUR BITS OF IT
	DCA CDRTM2	/SAVE THE REST FOR LATER
	TAD CDRTM2
	AND CDR740	/ONLY 4 BITS
	TAD CDRTM1	/ADD THOSE BITS TO THE 1ST CHAR
CDBCDF,	HLT		/CDF TO BUFFER FIELD
	DCA I CDRCA	/STORE 1ST CHARACTER
	ISZ CDRCA	/BUMP POINTER TO BUFFER
CDR740,	7400		/PROTECT THE ISZ AGAINST SKIPS
	TAD CDRTM2
	RTL
	RTL		/NOW GET LOW ORDER 4 BITS
	AND CDR7400	/AND ONLY 4 BITS
	TAD CDRTMP	/ADD IN THE 2ND CHARACTER
	DCA I CDRCA	/AND STORE THE WORD
	ISZ CDRCA	/BUMP POINTER AGAIN
CDR070,	70		/PROTECT THE ISZ
	CDF 0		/CDRGCH NEEDS 0 DF ON ENTRY!
	ISZ CDRWC	/DONE?
	JMP CDRLP	/NO - LOOP
CDRERR,	ISZ CDR		/HERE WITH NEGATIVE AC ON WRITE - FATAL ERROR
	ISZ CDR		/IF ^Z THIS IS ZEROED
CDRXIT,	HLT		/RESTORE CALLING FIELDS
	JMP I CDR	/EXIT

CDRCA,	0		/BUFFER POINTER
CDRWC,	0		/WORD COUNT DIVIDED BY 2
CDRTM1,	0
CDRTM2,	0		/SPLIT WORD TEMPORARY
CDRCIF,	CIF CDF 0	/TO FORM EXIT WORD

CDRIN2,	CDRJMP-CDRLOC	/CORRECTED AT INITIALIZATION TIME
CDRIN4,	CDRGCH-CDRLOC

	0		/** FREE LOCATIONS - COME AND GET 'EM !
	0
	IFNZRO	.-277	<RESORC,_ERROR_>	/BUT THERE'S A CATCH
CDRTBL,	0021;2223;2425;2627;3031;3203;4007;3502
	2017;6364;6566;6770;7172;7514;0577;3637
	1552;5354;5556;5760;6162;0104;1211;3374
	0641;4243;4445;4647;5051;7316;3410;1376

/DO NOT INSERT ANYTHING BETWEEN "CDRTBL" AND "CDRBUF"!!

CDRBUF=.		/CARD BUFFER

CDRSET,	RDF		/INITIALIZATION CODE
	TAD CDRCCF
	DCA CDRSE1	/SAVE CALLING FIELDS
	CDF		/WE ARE IN FIELD 0
	JMS .		/FIND OUT OUR LOCATION
CDRLOC,	TAD CDRSE2	/ADDRESS TO MODIFY
	TAD CDRLOC-1	/CORRECT IT
	DCA CDRSE3	/SAVE IT
	TAD I CDRSE3	/GET DATA TO MODIFY
	TAD CDRLOC-1	/CORRECT IT
	DCA I CDRSE3	/AND RESTORE IT
	ISZ CDRLOC	/NEXT ADDRESS
	ISZ CDRSE4	/MORE?
	JMP CDRLOC	/YES - LOOP
	TAD CDRSET
	DCA CDR+3	/SET THE "RDF"
CDRSE1,	HLT		/RESTORE CALLING FIELDS
	JMP CDR+3	/AND BACK TO NORMAL

CDRSE3,	0		/MODIFY POINTER
CDRSE4,	-5		/FIVE LOCATIONS TO MODIFY

CDRSE2,	CDRIN2-CDRLOC	/LOCATIONS TO MODIFY
	CDRIN4-CDRLOC
	CDRIN5-CDRLOC
	CDRABF-CDRLOC
	CDRTAD-CDRLOC
*CDRBUF+50		/END OF THE BUFFER

CDRGCH,	0		/GET A CHARACTER ROUTINE - ENTER WITH DF=0
CDRJMP,	0		/THIS IS "JMP I CDRGCH" AFTER A ^Z
	ISZ CDRCNT	/MORE CHARACTERS IN THE INTERNAL BUFFER?
	JMP CDRGET	/YES - GET ONE
CDRGE4,	ISZ CDRCT2	/GIVE A 215, 212 FOR EVERY CARD
	JMP CDRCLF	/215, 212 ROUTINE
	CLL CLA CMA RTL
	DCA CDRCT2	/RESET COUNT TO -3
CDRGNC,	TAD CDRABF
	DCA CDRPT	/SET POINTER TO INTERNAL BUFFER
CDRGE0,	KSF		/KEYBORAD FLAG UP?
	JMP CDRGE7	/NO - TRY TO READ A CARD
	TAD CDR760	/FORCE THE PARITY BIT ON
	KRS		/READ STATIC FROM KEYBOARD
	TAD CDR175	/IS IT ^C?
	SNA
	JMP I CDR760	/YES - TO MONITOR VIA 07600
	TAD CDRM27	/IS IT ^Z?
	SZA CLA
	JMP CDRGE7	/NO - GET A CARD
	KCC		/KILL FLAG
CDRGEZ,	CLA CMA
	DCA CDRCNT	/RESET COUNTS TO SKIP
	CLA CMA
	DCA CDRCT2
	TAD CDRMOD
	DCA CDRJMP	/SET TO GIVE 0'S
	DCA I CDRIN5	/AND A SOFT ERROR
	TAD CDR232	/^Z
	JMP I CDRGCH	/EXIT

CDRGE7,	RCSE		/SELECT A CARD
	JMP CDRGE0	/NO GO - TRY AGAIN
	DCA CDRSW	/SET PACKING SWITCH
CDRGCL,	DCA CDRTIM	/INITIALIZE TIMEOUT COUNTER
CDRGE1,	RCSP		/CARD DONE?
	JMP CDRGE2	/NO - TRY FOR DATA READY
	RCRD		/CLEAR CARD DONE FLAG
CDRGE3,	TAD I CDRPT	/GET LAST TWO CHARACTERS
	SZA		/BOTH SPACES?
	JMP CDRGE5	/NO
	CLA CMA
	TAD CDRPT
	DCA CDRPT	/BACK UP POINTER ONE
	ISZ CDRCNT
	ISZ CDRCNT	/AND TAKE COUNT DOWN BY 2
	JMP CDRGE3	/TEST AGAIN OR...
	JMP CDRGE4	/IF COUNT IS ZERO THE A BLANK CARD

CDRGE5,	AND CDR077	/IS RIGHT HAND CHARACTER A SPACE?
	SNA CLA
	ISZ CDRCNT	/YES A SPACE - REDUCE COUNT
	TAD I CDRPT	/GET LAST NON-SPACE
	TAD CDR077	/THIS FORMS 7777 IFF WORD CONTAINS "_"
	AND CDRCNT	/THIS MAINTAINS 7777 IFF CDRCNT IS -1
	CMA
	SNA CLA		/ARE BOTH CONDITIONS TRUE?
	JMP CDRGEZ	/YES - MUST BE END OF FILE
CDRGE6,	TAD CDR077
	DCA CDRSW	/SET OFFSET FROM "CDRTBL"
CDRGET,	ISZ CDRSW	/BUMP OFFSET
	TAD CDRSW	/OFFSET INTO AC
	JMS CDRGE8	/GET A CHARACTER
	TAD CDR240	/MAKE IT ASCII
CDRMOD,	JMP I CDRGCH

CDRGE8,	0		/GET FROM BUFFER ROUTINE
	CLL RAR		/DIVIDE BY 2 - AND INTO LINK IS INDICATOR
	TAD CDRTAD	/ADDRESS OF "CDRTBL"
	DCA CDRTM3	/SET POINTER
	TAD I CDRTM3	/GET WORD
	SZL		/SHIFT?
	JMP .+4		/NO
	RTR		/YES
	RTR
	RTR
	AND CDR077	/GET 6 BITS
	JMP I CDRGE8

CDRGE2,	RCSF		/DATA READY?
	JMP CDRGEX	/NO - TRY FOR TIME OUT
	RCRA		/READ ALPHA
	JMS CDRGE8	/GET TABLE ENTRY
	ISZ CDRSW	/WHICH SIDE?
	JMP CDRGE9	/LEFT SIDE
	TAD I CDRPT
	DCA I CDRPT	/FORM RIGHT SIDE
	JMP CDRGCL	/CONTINUE

CDRGE9,	CLL RTL		/SHIFT LEFT
	RTL
	RTL
	ISZ CDRPT	/BUMP POINTER
	DCA I CDRPT	/STORE LEFT SIDE
	CLA CLL CMA RAL	/-2 V3 FROM SIS BULLETING JAN  73
	TAD CDRCNT
	DCA CDRCNT	/COUNT THE CHARACTERS
	CLA CMA
	JMP CDRGCL-1	/CONTINUE - SET SWITCH
CDRCLF,	CLA CMA
	DCA CDRCNT	/SET MAIN COUNT TO SKIP
	TAD CDRCT2
	CLL CMA RTL	/ALL THIS DOES IS...
	TAD CDRCT2	/MAKE A 2 OR -1
	TAD CDR213	/SO THIS MAKES A 215 OR 212
	JMP I CDRGCH

CDRGEX,			/TEST TIME OUT - FIRST DELAY USING CONSTANTS
CDR760,	7600		/MONITOR ADDRESS
CDR077,	77		/SIX BIT MASK
CDRM77,	-7700		/-"_ "
CDR175,	175
CDR240,	240		/ASCII SPACE
CDR213,	213		/215, 212 CORRECTION FACTOR
CDR232,	232		/ASCII ^Z
	ISZ CDRTIM	/THIS LOOP TAKES AT LEAST 100MS ON AN 8/E
	JMP CDRGE1
	DCA CDRCNT	/CLEAR COUNT IN CASE PARTIAL CARD READ (E.G. JAM)
	JMP CDRGNC	/TIMED OUT - RESTART CARD

CDRTM3,
CDRTIM,	0		/TIMEOUT COUNTER
CDRM27,	-27		/-27-3=-32 ^Z TEST
CDRCNT,	-1		/MAIN COUNT
CDRCT2,	-1		/215, 212 COUNT
CDRPT,	0		/BUFFER POINTER
CDRSW,	0		/SWITCH

CDRABF,	CDRBUF-1-CDRLOC	/MODIFIED LOCATIONS
CDRTAD,	CDRTBL-CDRLOC
CDRIN5,	CDRXIT-1-CDRLOC
	$

