/1 TC08 DRIVER FOR RTS8 V2B			8/30/74
/
/
/
/
/
/
/
/
/
/COPYRIGHT  (C)  1974,1975,1976 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.
/
/
/
/
/
/
/
/
/
/
	XLIST	0
	VERS=	1
/ACCEPTS STANDARD MASS STORAGE TASK MESSAGE FORMAT

TASK=	DTA
INIWT=	0

DTCA=	6762
DTXA=	6764
DTLB=	6774
DTSF=	6771
DTRA=	6761
DTRB=	6772
DTACA=	7755
DTAWC=	7754

	IFNDEF	DTALOC	<DTALOC=4600>
	IFNDEF	DTAFLD	<DTAFLD=10>
	CUR=	DTAFLD
	FIELD	CUR%10
	*DTALOC
TMP,
START,	CAL
DONEFG,	SKPINS
	INTRPT
/MAIN HANDLER LOOP

LOOP,	CAL
	RECEIV		/GET A MESSAGE
ADDR,	0
	DCA	FLD
DTREDO,	AC7775
	DCA I	(TRYCT	/TRY 3 TIMES
	ISZ	DONEFG	/INITIALIZE EVENT FLAG
	STA
	TAD	ADDR
	DCA	ADDR
	JMS	GET
	AND	(7
	CDF CUR
	DCA I	(UNIT
	JMS	GET
	CDF CUR
	DCA I	(DFUN
	STA
	JMS	GET
	CDF CUR
	DCA I	(DLOC	/GET OS/8 STYLE ARGS
	JMS	GET
	CLL RAL
	CDF CUR
	DCA I	(DBLOCK	/DOUBLE BLOCK NUMBER
	TAD	(FSTINT
	DCA	IDISP	/INITIALIZE INTERRUPT DISPATCH
	IOF
	JMS I	(SETU	/INITIALIZE THE OPERATION
	TAD	(DTSF
	DCA	INTSKP	/ENABLE INTERRUPT TEST
	ION
	NOP		/BE NICE TO OTHER PEOPLE
	CAL		/(AND THEY'LL KICK YOU IN THE TASK)
	WAITE
PDONFG,	DONEFG		/WAIT FOR COMPLETION
	TAD	DONEFG
	SNA CLA		/IF EVENT FLAG DID NOT COME UP,
	JMP	NOPFAL	/BUT WE CAME OUT OF EFWT ANYWAY,
	AC7775		/A POWER FAILURE MUST HAVE OCCURRED.
	TAD	ADDR
	DCA	ADDR
	JMP	DTREDO	/TAKE IT FROM THE TOP
NOPFAL,	JMS	GET	/THIS JUST SETS THE DF AND ADDR
P7600,	7600
	TAD	STATUS
	DCA  I	ADDR
	TAD	FLD
	DCA	PFLD
	TAD	ADDR
	TAD	(-7	/GET POINTER TO MESSAGE EVENT FLAG
	CAL
	POST
STATUS,
PFLD,	HLT
	JMP	LOOP	/GET ANOTHER MESSAGE

GET,	0
FLD,	HLT
	ISZ	ADDR
	TAD I	ADDR
	JMP I	GET
/INTERRUPT ROUTINE BEFORE DISPATCHING

INTRPT,	0;0		/CHAIN INTO SKIP CHAIN
INTSKP,	CLA		/OR DTSF
	JMP I	INTRPT
	CDF CIF CUR
	DTRB
	JMP I	IDISP	/DISPATCH INTERRUPT

DSTOP,	DCA	STATUS
	DTRA
	AND	(200
	TAD	(6	/DISABLE INTERRUPTS WHEN TAPE THROUGH
	DTXA		/STOP TAPE, CLEAR ERRORS IN CONTROL
	TAD	P7600
	DCA	INTSKP
	TAD	PDONFG
	JMP	IDISP+1

IDISP,	HLT
	CIF 0
	POSTDS
	PAGE
/SEARCH AND TRANSFER LOGIC

DTGO,	TAD	(200
DTDC,	SZL
	TAD	(400
	DTXA		/START TAPE IN NEW (OLD) DIRECTION
RSTRT,	JMS I	(IDISP
FSTINT,	SMA CLA
	JMP	CKBLNO	/NO ERROR - CHECK FOR CORRECT BLOCK
	DTRB
	RTL
	RAL
	SMA CLA		/NEAT TEST - ONLY SELECT ERROR BAD ON SEARCH, BUT
	JMP	DTGO	/SINCE ENDZONE FLAG IS IN LINK WE WILL REVERSE ON EZ
DTERR,	ISZ	TRYCT
	JMP	TRYAGN	/TRY THREE TIMES ON ERRORS
	DTRB
	JMP I	(DSTOP	/OTHERWISE RETURN WITH ERROR FLAGS IN STATUS
TRYAGN,	JMS	SETU	/TRY AGAIN - REINITIALIZE OPERATION ON UNIT
	JMP	RSTRT	/GO BACK INTO SEARCH WAIT

SETU,	0		/ROUTINE TO INITIALIZE DT OP
	CDF CUR
	TAD	UNIT	/GET UNIT NUMBER
	TAD	(BLKTAB
	DCA	UB	/GET POINTER INTO CURRENT BLOCK TABLE
	TAD I	UB	/GET POSITION OF TAPE
	TAD	(12
	CMA STL		/IF DESIRED BLOCK IS MORE THAN 10 DECIMAL BLOCKS
	TAD	DBLOCK	/IN FRONT OF WHERE WE ARE, WE WANT
	CLA		/TO START FORWARD.
	TAD	UNIT
	RTR
	RTR
	TAD	(214	/IN EITHER CASE WE WANT TO SEARCH WITH
	DTCA DTXA	/INTERRUPTS ENABLED
	TAD	(CUR
	DTLB		/AS A NEAT HACK WE TELL THE CONTROL
	CDF 0		/TO PLACE TAPE BLOCK NUMBERS DIRECTLY
	TAD	UB	/INTO OUR CURRENT BLOCK NUMBER TABLE AS IT
	DCA I	(DTACA	/FINDS THEM, SAVING US SOME WORK
	JMP I	SETU

UB,	0
BLKTAB,	ZBLOCK	10	/ALL TAPES START REWOUND

TRYCT,	0
DFUN,	0
DLOC,	0
DBLOCK,	0
UNIT,	0
CKBLNO,	DTRA
	RTL
	CMA RTL		/DIRECTION IN LINK
	SNL CLA
	CML RTL		/SEARCH REVERSE TO BLOCK-2
	TAD I	UB	/GET BLOCK NUMBER FROM CONTROL BUFFER
	CIA
	TAD	DBLOCK
	SNA CLA
	SZL CLA
	JMP	DTDC	/A FEW LOCATIONS, A HAIRY ALGORITHM
	TAD	DLOC
	CDF 0
	DCA I	(DTACA
	CDF CUR
	TAD	DFUN	/SET ADDRESS AND FIELD FOR TRANSFER
	DTLB
	TAD	DFUN
	CLL RAL
	AND	(7600
	DCA	DBLCT
	RAL
	IAC
	STL RTL
	RTL
DL,	DTXA		/START TRANSFER
	CDF 0
	TAD	(7600
	DCA I	(DTAWC	/SET WORD COUNT TO 128 WORDS
	JMS I	(IDISP	/GIVE SOMEONE ELSE A CHANCE
	ISZ I	UB	/BUMP CURRENT TAPE BLOCK NUMBER
	SPA CLA		/ALL ERRORS DURING DATA TRANSFER ARE BAD
	JMP	DTERR
	TAD	DBLCT
	TAD	(7600
	SNA
	JMP I	(DSTOP
	DCA	DBLCT
	JMP	DL

DBLCT,	0
	PAGE
	$$
{
