/ 
/ 
/                   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, BY DIGITAL EQUIPMENT CORPORATION
/ 
/ 
        .EJECT
/ EDIT #61
/ EDIT #62	26 OCT 77 (JMW)	SUBROUTINE 'WFDT' USING WRONG
/				EVENT VARIABLE. (L. KACZOROWSKI,
/				CHEVELOT, SAGINAW, MICHIGAN).
/ EDIT #63	26 OCT 77 (JMW)	HANDLER NOT ABORTING I/O PROPERLY
/				FOR TASK CURRENTLY DOING I/O IF
/				DT NOT READY (L. KACZOROWSKI).
/
/ COPYRIGHT 1970,1971,1972,1973 DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/
/ DECTAPE I/O TASK         7/9/73           H. KREJCI
/   	      			        R. MCLEAN
/					W.A. DESIMONE
/					S. DELLER
/					M. HEBENSTREIT
/
/
/ THE REQUESTOR'S EVENT VARIABLE IS SET AS FOLLOWS
/   +1 -- FUNCTION PERFORMED
/   -6 -- UNIMLIMENTED FUNCTION
/   -7 -- ILLEGAL DATA MODE
/  -10 -- FILE STILL OPEN  [SEEK OR ENTER]
/  -11 -- FILE NOT OPEN  [READ OR WRITE]
/  -12 -- DECTAPE ERROR  [ALL FUNCTIONS]
/  -13 -- FILE NOT FOUND  [SEEK]
/  -14 -- DIRECTORY FULL [ENTER]
/  -15 -- DECTAPE FULL  [WRITE]
/  -16 -- OUTPUT WORD-PAIR COUNT TOO LARGE [WRITE]
/  -24 -- LUN ASSIGNMENT CHANGED [SEEK,ENTER,CLOSE,ATTACH,DETACH]
/  -30 -- PROTECT VIOLATION ON I/O
/  -777 -- POOL EMPTY 
/
/ THE CPB FORMATS ARE AS FOLLOWS:
/
/	CPB	FUNCTION CODE
/		EVENT VARIABLE ADDRESS
/		LOGICAL UNIT NUMBER
/		FDW-1
/		FDW-2
/		FDW-3
/
/	FDW = ADDITIONAL FUNCTIONAL DEPENDENT WORD REQUIRED BY
/	ATTACH,DETACH,SEEK,ENTER,INPUT,AND OUTPUT
/
/	ATTACH -- CODE 2400
/
/	DETACH -- CODE 2500
/
/
/
/
/	INPUT -- CODE 2600
/		FDW1- MODE INDICATOR
/		FDW2 - CORE BUFFER ADDRESS
/		FDW3 - BUFFER SIZE (MAX WORDS TO BE TRANSFERRED)
/
/	OUTPUT -- CODE 2700
/		FDW1 - MODE INDICATOR
/		FDW2 - CORE BUFFER ADDRESS
/
/	GET -- CODE 3000
/		FDW1 - BLOCK NUMBER (BLOCK NUMBER + 400000(8) REVERSE.)
/		FDW2 - BUFFER ADDRESS
/		FDW3 - WORD COUNT
/
/	PUT -- CODE 3100
/		FDW1 - BLOCK NUMBER (BLOCK NUMBER + 400000(8) REVERSE)
/		FDW2 - BUFFER ADDRESS
/		FDW3 - WORD COUNT
/
/
/	SEEK -- CODE 3200
/		FWD1 - FILE NAME 1ST HALF (SIXBIT)
/		FWD2 - FILE NAME 2ND HALF
/		FWD3 - FILE EXTENSION
/
/	ENTER -- CODE 3300
/		FWD1 - FILE NAME 1ST HALF (SIXBIT)
/		FWD2 - FILE NAME 2ND HALF
/		FWD3 - FILE EXTENSION
/
/	CLOSE -- CODE 3400
/
/
/	HINF -- CODE 3600
/
/
	.EJECT
/ PARAMETER DEFINITIONS:
/
R1=101
R2=102
R3=103
R4=104
R5=105
POOL=240	/POOL DEQUE LIST HEAD
PICK=120
PDVL=252	/PHYSICAL DEVICE DEQUE LIST HEAD
NADD=107	/NODE ADDITION ROUTINE ENTRY
NDEL=112	/NODE DELETION ROUTINE ENTRY
SNAM=123
VAJX=342
IOCD=345
DQRQ=337
DLAD=332
ALAD=325
DMTQ=361	/DEQUE AND DETACH FOR I/O RUNDOWN
X10=10
X11=11
X12=12
/
FW=000000	/FOREWARD
RV=040000	/REVERSE
NG=000000	/NO GO (STOP)
GO=020000	/GO
NM=000000	/NORMAL MODE
CM=010000	/CONTINUOUS MODE
MV=000000	/MOVE
SE=001000	/SEARCH
RD=002000	/READ DATA
WD=004000	/WRITE DATA
DI=000000	/DISABLE DT INTERRUPTS
EI=000400	/ENABLE DT INTERRUPTS
CE=000000	/CLEAR ERR FLAG
PE=000200	/PRESERVE ERR FLAG
CD=000000	/CLEAR DONE FLAG
PD=000100	/PRESERVE DONE FLAG
/
DTCA=707541	/CLEAR STATUS REGISTER-A
DTRA=707552	/READ STARUS REGISTER-A
DTRB=707572	/READ STATUS REGISTER-B
DTXA=707544	/XOR AC INTO STATUS REG-A
DTLA=707545	/LOAD STATUS REG-A FROM AC
DTDF=707601	/SKIP ON DECTAPE DONE FLAG
DTEF=707561	/SKIP ON DECTAPE ERR FLAG
/
.INH=705522
.ENB=705521
ECLA=641000
/
	.IFUND	DELTA	/DEFAULT DELTA (MIN BLOCK SEPARATION) OF FIVE
DELTA=5
	.ENDC
/
WCA	30	/WORD COUNT REGISTER ADDRESS
CAA	31	/CURRENT ADDRESS REGISTER ADDRESS
/
	.EJECT
BBUF=DTRQ		/BLOCK NUMBER READ (MUST PRECEED 'DBUF')
DBUF=DTRQ+1	/DATA BUFFER (ONE NORMAL DECTAPE BLOCK BUFFER)
/
/	DTRQ -- ONE TIME ONLY CODE TO INITALIZE THE DECTAPE HANDLER
/		XADJ IS SET UP AND THE HANDLER IS CONNECTED TO
/		THE API TRAP ADDRESS
/
/		THIS CODE IS STORED IN THE 400 WORD BUFFER OF THE
/		DECTAPE HANDLER.
/
DTRQ	LAC	(DTUEVA)	/PICK UP THE DECTAPE TRIGGER ADDRESS
	AND	(070000)	/MASK OFF THE PAGE BITS
	DAC	MXADJ	/COMPLEMENT OF XR ADJUSTEMENT
	TCA
	DAC	XADJ		/SAVE FOR XR ADJUSTMENT
	CAL	CONDT	/CONNECT REQUEST
	LAC	DTCONE	/IS DT CONNECT OK?
	SPA		/WAS WAIT OK?
	CAL	(10)	/NO EXIT
	LAC	(UNITAB-1)	/SET UP A TABLE OF ACTIVE PDVL 
	DAC*	(X11)	/DECTAPE NODES FOR DTA0-7
	LAW	-10	/SET UP A UNIT COUNT
	DAC	UNITCN
DTPDVL	LAC*	(PDVL)	/PICK UP THE ADDRESS OF THE FIRST PVDL NODE
DTNPV	TAD	XADJ	/SETUP TO PICK UP ENTRIES IN NODE
	PAX
	LAC	2,X	/LOOK AT THE NAME OF THE DEVICE
	SAD	DTASBT	/IS IT DTA?
	JMP	FNDPDV	/YES ENTER IT IN TABLE
NOFND	LAC	0,X	/NO-- THIS IS NOT THE CORRECT ENTER GET ANOTHER
	SAD	(PDVL)	/IS THIS THE END OF THE LIST?
	JMP	CON	/YES -- GO AND CONNECT
	JMP	DTNPV	/YES -- PICKUP ANOTHER ENTRY
FNDPDV	PXA		/SAVE NODE ADDRESS IN TABLE
	DAC*	X11
	LAC	(DTEV)	/PUT DT EVENT VARIABLE ADDRESS IN NODE
	DZM	DTEV	/CLEAR EVENT VARIABLE
	DAC	10,X
	ISZ	UNITCN	/CHECK TO SEE IF 10 UNITS
	JMP	NOFND	/CONTINUE SEARCH
CON	DTCA
	JMP	DTWFT	/YES -- WAIT FOR EVENT VARIABLE
CONDT	11	/CONNECT REQUEST
	DTCONE	/CONNECT EVENT VARIABLE
	4	/LINE
	DTINT	/INTERRUPT ADDRESS
/
DTCONE	0
/
	.LTORG
	.BLOCK	DTRQ-.+402
/
DTWFTD	DBK
DTWFT	CAL	WFDTEV	/WAIT FOR TRIGGER
FNR	.INH		/INHIBIT INTERRUPTS WHILE LOOKING AT DTEV
	LAC	DTEV
	AND	(100000) /MASK OFF I/O RUNDOWN BITS
	SZA
	JMP	ABORT	/GO ABORT TASK
	.ENB	/ENABLE INTERRUPTS NO ABORT REQUESTS
	DZM	DTEV	/CLEAR EVENT VARIABLE
	LAC	RAT	/IS THER A REAL ATTACH?
	SZA
	JMP	DLLKRT	/YES.  DEQUE REQ. FOR THIS LUN.
	LAC	CUS	/NO. IS THERE A FILE OPEN?
	SNA
	JMP	DLLUKP	/NO FIND A NODE POITER
DLLKRT	LAC	DTHEAD	/PICK UP THE HEADER OF THE DEQUE
	DAC*	(R1)
	JMS*	(DQRQ)	/PICK A NODE FROM THE QUEUE
	JMP	DTWFTA	/NO NODES IN THIS QUEUE  WAIT FOR NEXT EVENT ON THIS PDVL
	DAC	DTNODE	/EVENT OCCURED ON THIS NODE SAVE NODE ADDRESS
	TAD	XADJ
	PAX
	LAC	6,X	/PICK UP USER'S EVENT VARIABLE ADDRESS
	SNA		/IS IT ZERO?
	LAC	(DTUEVA)	/YES SET EVENTVARIABLE TO SELF
	DAC	DTUEVA	/STORE EVENT VARIABLE ADDRESS
	LAC	5,X	/PICK UP THE REQUEST TYPE
	AND	(000777)
	SAD	(17)	/IS IT AN ABORT?
	JMP	ABTDQD	/ABORT DEQUE'D GO ABORT I/O
	SAD	(24)	/IS IT AN ATTACH?
	JMP	ATTACH	/YES -- ATTACH DEVICE
	SAD	(25)	/IS IT A DETACH?
	JMP	DETACH
	SAD	(34)	/IS IT A CLOSE?
	JMP	CLOSE	/YES -- CLOSE FILE
	SAD	(26)	/IS IT A READ?
	JMP	READ	/YES -- READ A LINE
	SAD	(27)	/IS IT A WRITE?
	JMP	WRITE	/YES -- WRITE A LINE
	SAD	(30)	/GET?
	JMP	GET
	SAD	(31)	/PUT
	JMP	PUT
	SAD	(32)	/IS IT A SEEK?
	JMP	SEEK	/YES -- SEEK FILE
	SAD	(33)	/IS IT AN ENTER
	JMP	ENTER	/YES -- ENTER FILE
	SAD	(36)	/IS IT A HINF?
	JMP	HINF	/YES -- RETURN HINF INFORMATION
SEVM6	LAW	-6
	JMP	FLSREQ
/
/DTWFTB - EXIT TEST REQUEST IF MCR ASSIGN INHIBIT FLAG IS SET
/ AND THE QUEUE IS EMPTY THE HANDLER WILL EXIT.
/
DTWFTB	LAC	DTHEAD	/SET DTHEAD TO THE HEAD OF THE NODE
	AAC	-6
	DAC	DTHEAD
	LAC	(400004)
	ISA		/RAISE TO LEVEL5 TO PREVENT REASSIGN FROM CHANGING
	LAC	DTHEAD	/NODES --PICK UP PRESENT NODE HEAD IO 
	TAD	XADJ	/ADD PAGE BITS
	PAX
	LAC	11,X	/PICK UP ASSIGN INHIBIT BIT
	SMA
	JMP	DTWFTD	/NOT INHIBITED WAIT FOR EVENT
	LAC	(UNITAB-1)
	DAC*	(X10)	/CLEAR INHIBIT FLAGS AND TRIGGER EVENT VARIABLES
	LAW	-10
	DAC	UNITCN
EXITLP	LAC*	X10
	SNA		/IS THIS A NODE?
	JMP	EXIT	/NO EXIT
	PAX		/YES  PUT IT IN XR
	DZM	10,X	/TRIGGER EVENT VARIABLE ADDRESS
	DZM	11,X	/MCR ASSIGN INHIBIT FLAG
	TAD	MXADJ	/SUBTRACT THE XR ADJUSTMENT
	AAC	6	/POINT TO THE QUEUE
	DAC	DTHEAD
CLEARQ	LAC	DTHEAD	/PICK UP THE QUEUE HEAD
	DAC*	(R1)	/SET UP TO PICK UP NODES FROM THIS QUEUE
	JMS*	(PICK)	/EMPTY THE QUEUE SINCE DECTAPE IS LEAVING
	JMP	NXTUNT	/EMPTY QUEUE TRY THE NEXT NODE
	DAC*	(R2)	/SET UP TO ADD NODE TO POOL
	TAD	XADJ	/ADD XR ADJUSTMENT
	PAX
	LAC	6,X	/SET USER'S EVENT VARIABLE TO -24
	SNA
	LAC	(DTUEVA) /TO INDICATE REASSIGNMENT
	DAC	DTUEVA
	LAW	-24
	DAC*	DTUEVA
	LAC	(POOL)	/RETURN NODE TO POOL
	DAC*	(R1)
	JMS*	(NADD)
	JMP	CLEARQ	/SEARCH FOR NEXT NODE
NXTUNT	ISZ	UNITCN
	JMP	EXITLP
EXIT	DTRA
	AND	(EI!DI)
	SZA
	DTXA
	DBK
	CAL	DETAT
	CAL	(10)	/EXIT
DTWFTA	SZA		/IS THE DECTAPE ATTACHED
	JMP	DTWFT	/YES WAIT FOR AN EVENT VARIABLE
	DZM	CUS	/ATTACH CLEARED CLEAR ATTACH FLAGS
	DZM	RAT	/CLEAR REAL ATTACH FLAG ALSO
	JMP	DLLUKP	/SEARCH FOR ANOTHER QUEUE
/
/	DLLUKP	-- ROUTINE TO SEARCH THE PVDL FOR A DECTAPE
/		NODE TO BE SERVICED.
/		THE NODES ARE SEARCHED IN ROUND ROBIN ORDER
/
DLLUKP	LAC	(UNITAB-1)	/SET UP UNITABLE POINTER
	JMP	DTLKPA
DLLKP	LAC*	(X11)	/HAVE UNITAB REACHED THE END OF THE TABLE?
	SAD	(UNITAB+7)
	JMP	DTWFTB	/NO QUEUE'S AVAILABLE NOW
	SKP		/YES DON'T STORE IN X11
DTLKPA	DAC*	(X11)	/RESTORE XR11
	LAC*	X11	/PICK UP NODE ADDRESS
	SNA		/IS THIS ENTRY IN PDVL?
	JMP	DLLKP	/NO TRY NEXT ONE
	PAX		/PUT NODE POINTER IN XR
	AAC	6	/PUT HEADER ADDRESS IN DTHEAD
	TAD	MXADJ	/COMPLEMENT XR VALUE
	DAC	DTHEAD	/FOR AN INDICATION OF THE END OF THE DEQUE
	LAC	6,X	/PICK UP THE ADDRESS OF THE FIRST NODE
	SAD	DTHEAD	/IS THERE A NODE IN THIS QUEUE?
	JMP	DLLKP	/NO TRY AGAIN
	LAC	5,X	/YES - PICK UP UNIT NUMBER
	RTR!CLL		/PUT IN RIGHT THREE BITS
	RTR
	DAC	DTUN	/SAVE IT FOR FUTURE REQUESTS
	LAC	DTHEAD	/SET DTHEAD TO THE PDVL HEAD
	AAC	-6
	DAC	DTHEAD
	JMP	DLLKRT	/RETURN
/
/ ENTER -- SCAN FOR FILE NAME & EXT AND SELECT A DIRECTORY
/	ENTRY.  COPY THE MASTER BIT MAP.  INITIALIZE FILE
/	BIT MAP, AND BIT MAP SEARCH ROUTINES.  DETERMINE
/	STARTING BLOCK AND POINTER (NEXT BLOCK NUMBER).
/	SET RW-SWITCH TO READ.  SETUP PACKING POINTERS.
/
ENTER	LAC	CUS	/IS UNIT ALREADY OPEN
	SZA!CLA		/IS UNIT OPEN FOR READ OR WRITE?
	JMP	ERM10	/YES  SET EVENT VARIABLE TO -10 ERROR AND EXIT
	DZM	FLFND	/ZERO POINTERS
	DZM	MAXWPC
	LAW	-1	/OPEN UNIT FOR OUTPUT
	DAC	CUS
	LAC	(SE!RD)	/(SET RW SWITCH TO CHANGE FUNCTION
	DAC	RWSW	/FROM SEARCH TO READ-DATA)
			/(XR IS SETUP TO ACCESS REQUEST NODE)
	JMS	SESU	/FETCH FILE NAME & EXT, AND SCAN DIRECTORY
	JMP	EN3	/FILE FOUND -- SAVE DIRECTORY POINTER
	LAC	FDPTR	/FILE NOT FOUND -- IS A DIRECTORY ENTRY
	SMA!CLA		/AVAILABLE?
	JMP	EN4	/YES -- MOVE MASTER BIT MAP
	JMP	ERM14	/TO -14 AND FLUSH REQUEST
EN3	PXA		/THE DESIRED FILE ALREADY EXISTS, SAVE
	DAC	FDPTR	/POINTER TO ENTRY SO THAT IT MAY BE
			/OVERWRITTEN AT 'CLOSE'.
	LAW	-1
	DAC	FLFND	/SET FLAG TO INDICATE ENTRY FOUND
/
EN4	LAC	(DBUF-1) /SETUP TO MOVE THE FIRST 32 WORDS OF
	DAC*	(X10)	/THE DECTAPE BLOCK BUFFER TO THE
	DAC	X10SV	/SAVE FOR XR 10 SETUP
	LAC	(MBM-1)	/MASTER BIT MAP BUFFER AND TO
	DAC*	(X11)	/RECORD THE NUMBER OF BINARY ZEROS
	LAW	-40	/(AVAILABLE BLOCKS) IN 'BMABC'
	DAC	TEMP2
	DZM	BMABC
/
EN5	LAW	-22	/MOVE A WORD
	DAC	TEMP1
	LAC*	X10
	DAC*	11
EN6	RCL!SMA		/INCREMENT 'BMABC' (AVAILABLE BLOCK COUNT)
/			/BY THE NUMBER OF ZEROS IN WORD
	ISZ	BMABC
	ISZ	TEMP1
	JMP	EN6
/
	ISZ	TEMP2	/END OF MASTER BIT MAP
	JMP	EN5	/NO -- NEXT WORD
/
	LAW	-40	/YES -- CLEAR FILE BIT MAP
	DAC	TEMP1
EN7	DZM*	11
	ISZ	TEMP1
	JMP	EN7
/
	LAC	(MBM+3)	/SET UP FOR BIT MAP SEARCH (FOREWARD
	DAC	BMMP	/FROM BLOCK 101)
	AAC	+40
	DAC	BMFP
	LAC	(1000) /(SEARCH ROUTINE SKIPS DELTA BLOCKS BEFORE
	DAC	BMMASK	/TESTING FOR AVAILABLE BLOCKS.  INITIAL
	CLA!IAC		/CONDITIONS POINT TO BLOCK 70.  BLOCKS 71-100
	DAC	BMINCR	/ARE NEVER AVAILABLE.  IF DELTA IS LESS THAN
	AAC	+75	/NINE, SEARCH BEGINS AT BLOCK 103.)
	DAC	BMBLKN
/
	JMS	BMFNB	/FETCH FIRST BLOCK NUMBER
	SPA		/BLOCKS AVAILABLE?
	JMP	OOT	/NO -- FLUSH (ERR 15)
	DAC	SBA	/YES -- SAVE STARTING BLOCK NUMBER
	DAC	LBT	/AND SETUP FOR WRITING
	DAC	NBT
/
	DZM	DBUF+376 /IMAGE BUFFER
/
/SETUP PACKING POINTERS
/
	LAC	(SE!WD)	/SET R-W SWITCH TO CHANGE FUNCTION
	DAC	RWSW	/FROM SEARCH TO WRITE-DATA
	JMS	ATTCH	/PSEUDO ATTACH DEVICE
	JMP	FINREQ	/SET USER'S EVENT VARIABLE AND FETCH NEXT REQUEST
/
WRITE	LAC	CUS	/PICK UP BUSY SWITCH
	SMA!CLA		/ SUCCESSFUL ENTER -- SET CUS
	JMP	ERM11
	LAC	7,X	/CHECK FOR LEGAL MODES
	SAD	(4)	/DUMP MODE IS ILLEGAL
	JMP	ERM7
	AAC	-5
	SMA
	JMP	ERM7	/MODES GREATER THAN 5 ARE ILLEGAL
WR2	LAC	DTNODE	/PICK UP THE ADDRESS OF THE REQUEST NODE
	DAC*	(R2)	/SET UP TO VALIDATE ADDRESS REQUEST
	LAC	10,X	/PICK UP THE ADDRESS OF THE BASE OF THE REQUEST
	DAC*	(R3)
	DAC	UBUFA	/SAVE THE ADDRESS OF THE TRANSFER
	CLA!IAC		/THIS TIME SET UP FOR 1 WORD TO LOOK AT THE
	DAC*	(R4)	/MAXIMUM WORDS TO BE TRANSFERRED
	PXA		/SAVE XR
	DAC	XRSV
	JMS*	(VAJX)	/ADJUST PARAMETERS
	JMP	ERM30	/MEMORY PROTECT ERROR
	LAC*	(R3)	/PICK UP THE STARTING ADDRESS 
	TAD	XADJ	/ADD XR ADJUSTMENT
	PAX
	LAC	0,X	/PICK UP THE FIRST WORD OF THE TRANSFER
			/TO DETERMINE THE WORD COUNT
	SWHA		/MOVE THE WORD PAIR COUNT TO THE RIGHT 9 BITS
	AND	(177)	/MASK IT OFF
	CLL!RAL		/MULTIPLY IT BY 2
	DAC*	(R4)	/VALADATE THE REST OF THE WORDS
	LAC	UBUFA	/PICK UP THE USER'S ADDRESS
	DAC*	(R3)
	JMS*	(VAJX)	/VALADATE THE REQUEST
	JMP	ERM30	/PROTECT VIOLATION
	LAC	XRSV	/RESTORE XR
	PAX
	LAC	7,X	/CHECK FOR EOF REQUEST
	DAC	TEMP1
	LAC*	(R3)	/PICK UP THE ADDRESS OF THE TRANSFER
	TAD	XADJ	/ADD XR ADJUSTMENT
	PAX		/PUT IT IN XR
	LAC	TEMP1
	SAD	(5)
	JMP	NOTEO	/DON'T PUT DATAMODE IN EOF REQUEST
	LAC	0,X	/PICK UP THE FIRST WORD
	AND	(777000)
	XOR	TEMP1	/PUT DATAMODE IN REQUESTOR'S BUFFER
	DAC	0,X	/RESTORE THE WORD
NOTEO	LAC	X10SV	/PICK UP DECTAPE BUFFER
	DAC*	(X10)
	DZM	CKSUM	/CLEAR CHECKSUM
WRIT4	JMS	RDFW	/READ FIRST WORD OF BUFFER
	SWHA		/FIND WORD PAIR COUNT
	AND	(777)	/MASK IT OFF
	DAC	RDWPC	/SAVE WORD PAIR COUNT
	SNA		/IS IT ZERO?
	JMP	ERM23	/YES -23 ERROR
	AAC	-200	/IS IT GREATER THAN 177
	SMA
	JMP	ERM23	/YES -23 ERROR
	TAD	MAXWPC	/CHECK TO SEE IF IT WILL FIT IN THIS BLOCK
	SMA
	JMP	WRIT3	/YES OUTPUT BUFFER
	AAC	200
	DAC	MAXWPC	/SAVE WORD PAIR COUNT
	JMP	WRIT2	/MOVE IT TO BUFFER
WRIT3	ISZ	X10SV	/CLEAR CHECKSUM COUNT
	DZM*	X10SV
	JMS	BMFNB	/FIND NEXT BLOCK POINTER
	DAC	DBUF+377	/SET UP NEXT BLOCK POINTER
	LAC	NBT	/PICK UP POINTER TO NEXT BLOCK
	JMS	WFDT	/WAIT FOR WIRTE TO FINISH
	LAC	DBUF+377	/PICK UP NEXT BLOCK TO BE WRITTEN
	DAC	NBT	/SAVE IT
	SPA		/OUT OF TAPE?
	JMP	OOT	/YES ERROR
	DZM	MAXWPC	/CLEAR WORD COUNTER
	LAC	(DBUF-1)
	DAC	X10SV	/SET UP POINTER TO BUFFER
	LAC	XRSV	/RESTORE XR
	PAX
	JMP	WR2	/TRY AGAIN
WRIT2	LAC	RDWPC	/PICK UP DESIRED WORD PAIR COUNT
	TCA		/COMPLEMENT WORD PAIR COUNT
	DAC	RDWPC	/SAVE IT IN COUNTER
	LAC*	(X10)
	DAC	BUFCKS	/SAVE THE CHECKSUM POINTER
	DZM	0,X	/CLEAR THE CHECKSUM
	SKP
WR3	JMS	RDFW	/TRANSFER A BLOCK
	JMS	RDFW
	ISZ	RDWPC	/INCREMENT WORD PAIR COUNT
	JMP	WR3
	LAC	BUFCKS	/PICK UP THE POINTER TO THE CHECKSUM
	TAD	XADJ	/ADD XR ADJUSTMENT
	PAX		/PUT IT IN XR
	LAC	CKSUM	/PICK UP THE CHECKSUM
	TCA
	DAC	1,X	//STORE IT IN BUFFER
	LAC*	(X10)	/SAVE BUFFER POINTER
	DAC	X10SV
	JMP	FINREQ	/EXIT
/
/
CLOSE	LAC	CUS	/IS DECTAPE FILE OPEN
	JMS	DETCH	/CLEAR FILE OPEN SWITCH
	SMA!CLA!IAC	/IF MINUS MUST BE WRITE REQREST
	JMP	FINREQ	/NO EXIT
	LAC	X10SV
	DAC*	(X10)
	LAC	MAXWPC	/IS THERE ENOUGH ROOM FOR AN EOF IN THIS BLOCK?
	AAC	-174
	SPA
	JMP	EOFOK	/YES PUT IT IN
	DZM*	X10	/SET HEADER WORD TO 0
	JMS	BMFNB	/PICK UP ANOTHER BLOCK
	DAC	DBUF+377	/STORE ITS POINTER IN BUFFER
	LAC	NBT
	JMS	WFDT
	LAC	DBUF+377
	DAC	NBT
	SPA
	JMP	OOT	/NO MORE TAPE
	LAC	(DBUF-1)	/RESET DECTAPE BUFFER
	DAC*	(X10)
EOFOK	LAC	(1005)	/EOF HEADER
	DAC*	X10
	TCA
	DAC*	X10	/CHECKSUM
	DZM*	X10
/
	LAW	-1	/SET LAST BLOCK POINTER TO -1
	DAC	DBUF+377
	LAC	NBT	/PICK UP BLOCK POINTER
	JMS	WFDT	/WAIT FOR WRITE TO COMPLETE
	LAC	(NOP)	/INSURE THAT DIRECTORY IS WRITTEN
	DAC	DIRFWV	/IN THE FOREWARD DIRECTION
	LAW	-2
	DAC	DIROVS	/OVERSHOOT IS ALSO CORRECTED
	DTRA		/READ THE DECTAPE STATUS
	AND	(FW!RV)	//INSURE THAT THE DECTAPE IS MOVING IN THE FORWARD DIRECTION
	SZA
	DTXA
	LAW	-1	/CHECK FOR FILE TO BE DELETED
	SAD	FLFND
	JMS	DELBTM	/YES FILE FOUND GO DELETE IT FROM MASTER BITMAP
	LAC	(SE!RD)	/SET UP TO READ BLOCK 100
	DAC	RWSW
	LAC	(100)
	JMS	WFDT	/WAIT FOR BLOCK TO BE READ
	LAC	FDPTR	/PICK UP POINTER
	PAX		/PUT IT INXR
	LAC	FNE	/PICK UP FILE NAME
	DAC	0,X
	LAC	FNE+1
	DAC	1,X
	LAC	FNE+2
	DAC	2,X
	LAC	SBA
	TAD	(400000)	/ADD EXISTANCE BIT
	DAC	3,X
	LAW	-40
	DAC	TEMP1	/SET UP TO MOVE MASTER BIT MAP TO DIRETORY
	LAC	(MBM-1)
	DAC*	(X10)
	LAC	(DBUF-1)
	DAC*	(X11)
CLOSL	LAC*	X10	/MOVE BIT MAP
	DAC*	X11
	ISZ	TEMP1
	JMP	CLOSL
	LAC	(SE!WD)	/REWRITE BLOCK 100
	DAC	RWSW
	LAC	(100)	/WRITE BLOCK 100
	ISZ	ABTFL	/PROTECT AGAINST ABORT WHILE WRITING DIRECTORY
	JMS	WFDT	/WAIT FOR IO TO COMPLETE
	JMS	FNDBTM	/FIND FIND FILE BITMAP
CLOS1	LAC*	X11
	DAC*	X10
	ISZ	TEMP1
	JMP	CLOS1
	LAC	(SE!WD)	/SET UP TO WRITE BITMAP
	DAC	RWSW
	LAC	TEMP2
	JMS	WFDT
	DZM	ABTFL	/ABORT OK NOW
	JMP	FINREQ	/EXIT
/
/ DELBTM-- SUBROUTINE TO REMOVE OLD BITMAP FROM MASTER BITMAP
/
DELBTM	0
	JMS	FNDBTM	/FIND THE BITMAP REQUIRED
	LAC	(MBM-1)	/SET UP XR'S
	DAC*	(X11)
	DAC*	(X12)
	LAC*	X11
	XOR*	X10
	DAC*	X12
	ISZ	TEMP1
	JMP	.-4	/LOOP UNITL ALL OF MAP IS CHANGED
	JMP*	DELBTM
/
/ FNDBTM -- SUBROUTINE TO FIND A REQUIRED BITMAP
/
FNDBTM	0
	LAC	(SE!RD)	/CHANGE DIRECTION
	DAC	RWSW
	LAC	FDPTR	/PICK UP POSITION
	TAD	MXADJ	/SUBTRACT PAGE BITS
	TCA
	TAD	(DBUF+40)	/DETERMINE POSITION
	TCA
	CLL!RTR
	DAC	FBN
	LRS	3
	AAC	71	/DETERMINE POSITION
	DAC	TEMP2
	JMS	WFDT
	LAC	FBN
	CLL		/CLEAR LINK FOR MULTIPLY
	AND	(7)
	MUL
	40
	LACQ
	TAD	(DBUF-1)	/SET UP TO MOVE BITMAP
	DAC*	(X10)
	LAC	(FBM-1)
	DAC*	(X11)
	LAW	-40
	DAC	TEMP1	/SAVE FILE BITMAP SIZE
	JMP*	FNDBTM	/RETURN
/
OOT	LAW	-15	/OUT OF TAPE -- SET USER'S EVENT VARIABLE TO -15
	JMP	FLSREQ	/AND FLUSH REQUEST
/
/ SEEK -- READ DIRECTORY BLOCK.  SCAN FOR FILE NAME & EXT.
/         DETERMINE FIRST BLOCK OF FILE.  READ FIRST BLOCK.
/         LEAVE RW-SW SET TO READ.  INITIALIZE UNPACKING
/         POINTER.
/
SEEK	LAC	CUS	/IS UNIT ALREADY OPEN?
	SZA!CLA
	JMP	ERM10	/TO -10 AND FLUSH REQUEST
/
SK2	ISZ	CUS	/OPEN UNIT FOR INPUT
	LAC	(SE!RD)	/(SET R-W SWITCH TO SWITCH FROM
	DAC	RWSW	/SEARCH TO READ DATA)
			/(XR IS SETUP TO ACCESS REQUEST NODE)
	JMS	SESU	/FETCH FILE NAME & EXT AND SCAN DIRECTORY
	JMP	SK3	/FILE ENTRY FOUND -- AC CONTAINS START BLOCK NUM
	LAW	-13	/FILE ENTRY NOT FOUND -- SET USER'S EVENT
	JMP	FLSREQ	/VARIABLE TO -13 AND FLUSH REQUEST
/
SK3	DAC	LBT	/FILE NAME FOUND -- SET STARTING BLOCK
	DAC	NBT	/NUMBER IN 'LBT' & 'NBT'
/
	LAC	(JMP FXBLK)/FIND AND READ FIRST BLOCK OF FILE
	DAC	DISPX
	LAC	NBT
	JMS	WFDT
	LAC	(DBUF)	/SET UNPACKING POINTER
	DAC	RDBFP
	JMS	ATTCH	/PSEUDO ATTACH DEVICE
/
	JMP	FINREQ	/VARIABLE & FETCH NEXT REQUEST
/
/ SESU -- SEEK-ENTER SET UP SUBROUTINE.  XR MUST BE SETUP TO 
/         ACCESS REQUEST NODE -- XR IS LEFT SETUP TO ACCESS
/         THE FOUR-WORD DIRECTORY ENTRY IN BLOCK #100 (IF FILE
/         EXISTS ON TAPE).
/         RETURN ATJMS+1 IF FOUND
/         RETURN AT JMS+2 IF NOT FOUND
/
SESU	0
	LAC	7,X
	DAC	FNE+0
	LAC	10,X
	DAC	FNE+1
	LAC	11,X
	DAC	FNE+2
	LAC	(NOP)
	DAC	DIRFWV	/INSURE THAT DIRECTORY IS READ IN FORWARD
	LAW	-2
	DAC	DIROVS	/DIRECTION
	LAC	DTUN	/SELECT DECTAPE UNIT
	DTLA
/
	LAC	(JMP FXBLK) /FIND & READ BLOCK #100
	DAC	DISPX
	LAC	(100)
	JMS	WFDT
	LAC	(JMS	DIRFW)
	DAC	DIRFWV	/SET UP TO READ BLOCKS BACKWARDS IF NECESSARY
/
	LAC	(DBUF+40)/SCAN DIRECTORY FOR FILE NAME AND/OR UNUSED 
	TAD	XADJ	/DIRECTORY ENTRY (FOR ENTER)
	PAX
	AAC	340
	PAL
	LAW	-1	/(INDICATE NO UNUSED DIRECTORY  
	DAC	FDPTR	/ENTRY POINTER)
/
SE1	LAC	3,X	/IS THIS A EXISTENT FILE ENTRY
	SPA
	JMP	SE3	/YES -- CHECK NAME & EXT
	LAC	FDPTR	/NO -- SAVE POINTER TO FREE DIRECTORY
	SPA		/IFF THIS IS THE FIRST ONE FOUND
	PXA
	DAC	FDPTR
	PLA		/CALCULATE POSITION IN BIT MAP TABLE
	XOR	XADJ	/REMOVE XADJ BITS
	TCA
	TAD	FDPTR
	TCA
	DAC	FBN
	JMP	SE2	/AUG XR
/
SE3	LAC	0,X	/EXAMINE FIRST HALF OF NAME -- IS THIS THE
	SAD	FNE+0	/ENTRY FOR THE DESIRED FILE
	SKP
	JMP	SE2	/NO -- AUG XR
	LAC	1,X	/MAYBE -- CHECK SECOND HALF OF NAME
	SAD	FNE+1
	SKP
	JMP	SE2	/NO -- AUG XR
	LAC	2,X	/MAYBE -- CHECK EXTENTION
	SAD	FNE+2
	SKP
	JMP	SE2	/NO -- AUG XR
	LAC	3,X	/YES -- SET STARTING BLOCK POINTER IN AC
	AND	(7777)	/AND RETURN AT JMS+1
	JMP*	SESU
/
SE2	AXS	4	/AUGNEMT X-REG -- END OF DIRECTORY?
	JMP	SE1	/NO -- NEXT ENTRY
	ISZ	SESU	/YES -- RETURN AT JMS+2
	JMP*	SESU
/
/ BMFNB -- BIT MAP SUBROUTINES -- FIND NEXT BLOCK
/	BLOCK NUMBER IS RETURNED IN AC
/
BMFNB	0
	LAC	BMABC	/ARE THERE BLOCKS AVAILABLE?
	SZA!CMA		/NO -- EXIT WITH AC=-1
	JMP	BMFNB1	/YES -- MOVE WINDOW DELTA BLOCKS
	JMP*	BMFNB
/
BMFNB1=.		/MOVE WINDOW DELTA BLOCKS
	.REPT	DELTA
	JMS	BMMM
	JMS	BMRX	/WINDOW BEYOND ENDS OF TAPE?
	JMP	BMFNB1	/YES -- MOVE BACK DELTA BLOCKS
BMFNB2	LAC*	BMMP	/NO -- IS BLOCK IN WINDOW AVAILABLE?
	AND	BMMASK
	SNA		/NO -- MOVE WINDOW
	JMP	BMFNB4	/YES -- ALLOCATE BLOCK
BMFNB3	JMS	BMMM	/MOVE WINDOW ONE BLOCK
	JMS	BMRX	/WINDOW BEYOND ENDS OF TAPE?
	JMP	BMFNB3	/YES -- MOVE BACK ONE BLOCK
	JMP	BMFNB2	/NO -- TEST BLOCK IN WINDOW
/
BMFNB4	LAC*	BMMP	/AN AVAILABLE BLOCK HAS BEEN FOUND.  SET
	XOR	BMMASK	/CORESPONDING BITS IN BOTH MASTER
	DAC*	BMMP	/AND FILE BIT MAP IMAGES.
	LAC*	BMFP
	XOR	BMMASK
	DAC*	BMFP
	LAW	-1	/DECREMENT AVAILABLE BLOCK COUNT
	TAD	BMABC
	DAC	BMABC
	LAC	BMBLKN	/EXIT WITH BLOCK NUMBER IN AC
	JMP*	BMFNB
BMRX	0		/BIT MAP MOVE REVERSE SUBROUTINE
	LAC	BMBLKN	/OUT OF RANGE BLOCK NUMBER?
	SPA
	JMP	BMRX1		/(RANGE: 0 THRU 1077)
	TAD	(-1100)
	SMA
	JMP	BMRX1
	ISZ	BMRX	/NO -- RETURN AT JMS+2
	JMP*	BMRX
BMRX1	LAC	BMINCR	/YES -- COMPLIMENT INCREMENT
	TCA		/AND RETURN AT JMS+1
	DAC	BMINCR
	JMP*	BMRX
/
/BMMM -- BIT MAP MASK MOVE SUBROUTINE.  THE MAP WORD POINTERS
/	ARE UPDATED WHEN BIT OVERFLOWS MASK.
/
BMMM	0
	LAC	BMINCR	/INCREMENT DECTAPE BLOCK
	TAD	BMBLKN	/NUMBER PER 'BMINCR'
	DAC	BMBLKN
	LAC	BMINCR	/RAR OF RAL PER 'BMINCR'
	RAL
	LAC	BMMASK	/	INCR DIRECTION
	SZL!CLL!RAR		/	+1   RAR
	RTL		/	-1   RAL
	DAC	BMMASK
	SNL		/MASK OVERFLOW?
	JMP*	BMMM	/NO -- EXIT
	LAC	BMINCR	/YES -- RESET MASK PER 'BMINCR'
	AND	(400000)	/
	SZA!RAR		/	INCR MASK
	RTL		/	+1   400000
	DAC	BMMASK
	LAC	BMINCR	/UPDATE MAP POINTERS PER 'BMINCR'
	TAD	BMMP
	DAC	BMMP
	AAC	40	/UPDATE FILE BITMAP POINTER
	DAC	BMFP
	JMP*	BMMM	/EXIT
BMMP	0		/MASTER MAP POINTER
BMFP	0		/FILE MAP MASK
BMMASK	0		/BIT MAP MASK
BMINCR	0		/INCREMENT (+1 OR -1)
BMBLKN	0		/DECTAPE BLOCK NUMBER
BMABC	0		/AVAILABLE BLOCKS COUNT
FDPTR	0	/FREE DIRECTORY ENTRY POINTER
/
MBM	.BLOCK 40	/MASTER & FILE BIT MAP IMAGES (MUST BE
FBM	.BLOCK 40	/IN CONSECUTIVE CORE)
/
/ READ -- WAIT FOR BLOCK READIN IF NECESSARY.  UNPACK AND 
/ TRANSFER A LOGICAL RECORD TO 'INBUF'.  INITIATE NEXT BLOCK
/ READ IF LAST RECORD OF BLOCK AND NOT LAST BLOCK OF FILE
/
READ	LAC	CUS	/IS UNIT OPEN FOR READ?
	SNA!CLA!SPA
	JMP	ERM11	/TO -11 AND FLUSH REQUEST
	LAC	7,X	/PICK UP THE MODE
	AAC	-4
	SMA!CLA		/GREATER THAN 4?
	JMP	ERM7	/YES ERROR
RD2	LAC	10,X	/FETCH USER BUFFER ADDRESS
	DAC*	(R3)	/SET UP STARTING ADDRESS OF BUFFER
	LAC	11,X	/DETERMINE MAX WORD-PAIR COUNT
	AAC	+1
	RCR
	DAC	MAXWPC
	LAC	DTNODE	/PICK UP THE ADDRESS OF THE DECTAPE NONDE
	DAC*	(R2)
	LAC	11,X	/PICKUP THE MAX WORD COUNT
	DAC*	(R4)
	JMS*	(VAJX)	/VALADATE REQUEST
	JMP	ERM30	/PROTECT VIOLATION ERROR
	LAC*	(R3)	/PICKUP THE ADDRESS OF THE TRANSFER
	DAC	UBUFA
/
READ1	DZM	CKSUM	/SETUP FOR A NEW RECORD
	LAC	RDBFP	/PICK UP THE BUFFER POINTER
	SAD	(DBUF+376)	/IS THIS THE END OF THE BUFFER?
	JMP	READ4	/YES GO GET ANOTHER ONE
	TAD	XADJ	/ADD THE XR ADJUSTMENT
	PAX		/PUT IT IN XR
	LAC	UBUFA
	AAC	-1
	DAC*	(X10)
	DZM	RDVBTS
	JMS	RDFW	/FETCH FIRST WORD OF HEADER
	LMQ
	AND	(17)	/REQUEST MUST BE 'SEEK', 'ENTER', OR
	SAD	(05)	/'CLOSE')
	JMS	DETCH	/PSEUDO DETACH
	ECLA!LLS	11
	DAC	BUFADJ
	SZA		/ZERO WORD-PAIR COUNT?
	JMP	READ2	/NO -- UNPACK RECORD FROM BUFFER
READ4	LAC	NBT
	SPA!CLA!CMA		/IS BLOCK NUMBER LEGAL?
			/BLOCK NUMBER IS NOT ALWAYS POSITIVE IF
			/AN ERROR HAS OCCURED WHILE READING
			/SO THERE THIS TEST EXISTS
	JMP	ERM11	/DECTAPE ERROR IN READING DATAERR 12
	LAC	NBT
	JMS	WFDT
	LAC	(DBUF)
	DAC	RDBFP
	JMP	READ1
READ2	TCA		/SAVE 2'S COMPL WORD PAIR COUNT
	DAC	RDWPC
	TAD	MAXWPC	/IS RECORD IS TOO LONG?
	SMA!CLA
	JMP	READ3	/NO -- FETCH CHECKSUM WORD
	AAC	60	/YES -- INDICATE TRUNCATED RECORD
	JMS	RDSVB
	LAC	MAXWPC
	JMP	READ2
/
RDL1	JMS	RDFW
READ3	JMS	RDFW	/WORD PAIR COUNT OKAY -- FETCH CHECKSUM
/
RDXX	ISZ	RDWPC	/END OF RECORD?
	JMP	RDL1	/NO -- NEXT WORD PAIR
	LAC	CKSUM	/YES -- CHECKSUM OKAY?
	SNA!CLA
	JMP	RDXR	/YES -- SET VALIDITY BITS IN HEADER
	AAC	40	/NO -- INDICATE ERROR
	JMS	RDSVB
RDXR	LAC	BUFADJ	/RESTORE RDBFP FOR NEXT READ
	CLL!RAL
	TAD	RDBFP
	DAC	RDBFP
	LAC	UBUFA	/PICK UP THE BUFFER POINTER
	TAD	XADJ	/ADD THE XR ADJUSTMENT
	PAX
	LAC	0,X	/SET THE VALIDITY BITS IN
			/THE HEADER
	AND	(777717)
	XOR	RDVBTS
	DAC	0,X
/
	JMP	FINREQ	/TO +1 AND FETCH NEXT REQUEST
/
RDSVB	0		/SET VALIDITY BITS SUBROUTINE
	DAC	RDSVB1
	LAC	RDVBTS
	SZA
	JMP*	RDSVB
	LAC	RDSVB1
	DAC	RDVBTS
	JMP*	RDSVB
/
RDVBTS	0
RDSVB1	0
/
RDWPC	0
RDBFP	0
CKSUM	0
BUFCKS	0	/CHECKSUM POINTER FOR WRITE
BUFADJ	0
/
RDFW	0
	LAC	0,X
	DAC*	X10
	TAD	CKSUM
	DAC	CKSUM
	LAC	0,X
	AXR	1
	JMP*	RDFW
/
/	GET -- READ A BLOCK (400 WORDS MAX)
/
GET	LAC	CUS	/FILE OPEN?
	SZA
	JMP	ERM10	/YES ERROR
	LAC	DTUN	/SET UP THE UNIT NUMBER
	DTLA
	LAC	7,X	/PICK UP THE BLOCK NUMBER AND DIRECTION
	AND	(377777
	TCA
	TAD	(1100	/IS THIS A LEGAL BLOCK NO.?
	SPA
	JMP	BADBLK	/NO -- BLOCK NO. IS TOO HIGH
	LAC	7,X	/GET DIR. AND BLK. NO. AGAIN
	SMA
	JMS	FWDD	/FORWARD DIRECTION
	JMS	RIVD	/REVERSE DIRECTION
	LAC	(SE!RD)	/SET TO READ
	DAC	RWSW
	LAC	NBT	/SET UP TO START
	JMS	WFDT	/START DT
	LAC	UBUFA	/PICK UP USER'S BUFFER ADDRESS
	DAC*	(X10)	/AND MOVE CHARACTERS
	LAC	(DBUF-1)
	DAC*	(X11)
	LAC*	X11	/MOVE TO USER'S BUFFER
	DAC*	X10
	ISZ	MAXWPC
	JMP	.-3
	JMP	FINREQ	/FINISHED EXIT
/
/	PUT -- WRITE A BLOCK (400 WORDS MAX)
/
PUT	LAC	CUS	/FILE OPEN?
	SZA
	JMP	ERM10	/YES ERROR
	LAC	DTUN	/SET UP THE UNIT NUMBER
	DTLA
	LAC	7,X	/PICK UP BLOCK NUMBER AND DIRECTION
	AND	(377777
	TCA
	TAD	(1100	/IS THIS A LEGAL BLOCK NO.?
	SPA
	JMP	BADBLK	/NO -- BLOCK NO. IS TOO HIGH
	LAC	7,X	/GET DIR. AND BLK. NO. AGAIN
	SMA
	JMS	FWDD	/FORWARD DIRECTION
	JMS	RIVD	/REVERSE DIRECTION
	LAW	-400
	DAC	CKSUM
	LAC	(DBUF-1
	DAC*	(X10)
	DZM*	X10
	ISZ	CKSUM
	JMP	.-2	/CLEAR OUT BUFFER FIRST
	LAC	UBUFA	/MOVE BUFFER
	DAC*	(X10)
	LAC	(DBUF-1
	DAC*	(X11)
	LAC*	X10	/MOVE TO USER'S BUFFER
	DAC*	X11
	ISZ	MAXWPC
	JMP	.-3
	LAC	(SE!WD)	/SET UP TO WRITE
	DAC	RWSW
	LAC	NBT
	JMS	WFDT	/START DT
	JMP	FINREQ	/FINISHED RETURN
/ 
BADBLK	CLC		/BAD BLOCK NUMBER -- RETURN EV OF -12
	JMP	ERM11
/
FWDD	0
	ISZ	FWDD	/INCREMENT RETURN
	LAW	-2	/SET UP OVERSHOOT
	DAC	DIROVS	/DIRECTION
	LAC	(NOP)
	DAC	DIRFWV
	DTRA
	AND	(RV!FW)	/SET UP CONTROL
	SZA
	DTXA
	JMS	VALD	/DO VALADATION AND SET UP POINTERS
	JMP*	FWDD	/RETURN
/
RIVD	0
	LAC	(2)	/SET UP DIRECTION
	DAC	DIROVS	/FOR OVERSHOOT
	LAC	(JMS DIRFW)
	DAC	DIRFWV
	DTRA	/SET UP DIRECTION
	AND	(RV!FW)
	SNA!STL
	CLL
	LAC	(RV!FW)
	SNL
	DTXA
	JMS	VALD
	JMP*	RIVD	/RETURN
/
VALD	0
	LAC	(JMP	FXBLK	/SET UP DISPATCH TABLE
	DAC	DISPX
	LAC	7,X	/PICK UP THE BLOCK NUMBER
	SPA
	AND	(377777)	/MASK OFF BIT 0 IF REV. DIR. WAS SPECIFIED.
	DAC	NBT	/MAKE IT POSITIVE
	LAC	10,X	/PICK UP THE BUFFER POINTER
	DAC*	(R3)
	LAC	11,X	/PICK UP THE WORD COUNT
	DAC*	(R4)
	TCA
	DAC	MAXWPC	/SAVE IN POINTER
	TAD	(400)
	SPA!CLA		/IS IT LEGAL?
	JMP	ERM70
	LAC	DTNODE
	DAC*	(R2)
	JMS*	(VAJX)
	JMP	ERM30	/VALADATE ERROR
	LAC*	(R3)
	AAC	-1
	DAC	UBUFA	/SET UP USER'S BUFFER
	JMP*	VALD	/RETURN
/
ERM70	LAW	-70
	JMP	FINREQ+1
/
/
/ FINISH REQUEST -- SET USER'S EVENT VARIABLE TO THE CONTENTS OF AC,
/ DELETE NODE FROM REQUEST QUEUE, AND FETCH NEXT REQUEST.
/
FINREQ	CLA!IAC		/SET USER'S EVENT VARIABLE TO +1
	PAL		/SAVE THE ERROR FLAGS OR REQUEST OK FLAG
	LAC	DTUEVA	/PICK UP THE ADDRESS OF THE EVENT VARIABLE
	TAD	XADJ	/ADD XR ADJUSTMENT
	PAX
	PLA		/RESTORE THE REQUEST FINISHED FLAGS
	DAC	0,X	/SET THE EVENT VARIABLE
	LAC	(401000)/SET SIX
	ISA
	LAC	DTNODE	/PICK UP ADDRESS OF NODE
	DAC*	(R2)	/STORE IT TO RETURN NODE TO POOL
	LAC	(POOL)
	DAC*	(R1)
	JMS*	(IOCD)	/DECREMENT I/O REQUEST PENDING COUNT
	JMS*	(NADD)
	JMP	FNR	/RETURN AND GET NEXT NODE REQUEST
/
/ FLUSH REQUEST -- SET THE USER'S EVENT VARIABLE TO THE
/ TO THE QUANTITY IN AC (DONE BY 'FINREQ') AND 'CLOSE'
/ THE UNIT
ERM30	LAW	-30
	JMP	FLSREQ	/MEMORY PROTECT VIOLATION
ERM23	LAW	-7
ERM14	AAC	-3
ERM11	AAC	-1
ERM10	AAC	-1
ERM7	AAC	-7
/
FLSREQ	JMS	DETCH	/DETACH PSEUDO ATTACHES ON ILLEGAL REQUEST
FLSRQ1	DZM	CUS
	JMP	FINREQ+1
/
/	ABORT AND I/O RUNDOWN ROUTINES TO STOP I/O
/
IORD	LAC	DTEV	/PICK UP THE EVENT VARIABLE AND RESET IT
	XOR	(100000) /MASK OFF THE I/O RUNDOWN BIT
	.ENB		/ENABLE INTERRUPTS
	DAC	DTEV	/RESTORE EVENT VARIABLE
	LAC	UNITAB /DEQUE THE REQUEST
	TAD	MXADJ	/REMOVE XR ADJUSTMENT
	DAC*	(R1)
	JMS*	(DQRQ)
	JMP	WFDTW	/CAN'T HAPPEN BUT IF IT DOES ....
	DAC	ABTNOD	/SAVE THE ADDRESS OF THE ABORT NODE
	CLX		/FIND THE STL POINTER
	AXR	2
	LAC*	ABTNOD,X /PICK UP THE ABORTED TASK'S POINTER
	SAD*	DTNODE,X /ARE WE SERVICING IT NOW?
	SKP
	JMP	NOTACT	/NO DON'T ABORT IT
	LAC	ABTFL	/ABORT LEGAL NOW?
	SZA
	JMP	ABTCLA	/NO DON'T ABORT WHILE WRITING DIRECTORY
	DTRA		/STOP THE DT
	AND	(757777)
	DTLA		/UNCONDITIONALLY
IORD.X	JMS	DETCH	/(JMW:063)DETACH THE DECTAPE.
	LAC	DTNODE	/RETURN THE DT NODE TO THE POOL
	DAC*	(R2)
	LAC	(POOL)
	DAC*	(R1)
	JMS*	(IOCD)	/I/O COUNTDOWN
	JMS*	(NADD)	/ADD NODE TO POOL
	JMS	DQALL	/DEQUEUE THE REST OF THE NODES
	JMP	FNR	/FETCH NEXT REQUEST FINISHED HERE
/
ABTCLA	LAC	(DTUEVA	/ABORT WHILE WRITING DIRECTORY
	DAC	DTUEVA	/SET EVENT VARIABLE TO SELF AND PROCEED
NOTACT	JMS	DQALL	/DEQUE THE STACKED I/O REQUEST'S
	JMP	WFDTW	/WAIT FOR THE RUNNING DT TASK
/
DQALL	0
	LAC	(UNITAB) /SET UP TO CLEAR ALL THE PHYSICAL DEVICE NODES
	DAC	ABTPDV
	LAW	-10
	DAC	PDVCT
DQLP	LAC*	ABTPDV	/PICK UP THE FIRST NODE
	SNA
	JMP	DQFIN	/FINISHED NO MORE NODES
	TAD	MXADJ
	DAC*	(R1)
	LAC	ABTNOD	/PICK UP THE ADDRESS OF THE ABORT NODE
	DAC*	(R2)
	JMS*	(DMTQ)	/DETACH AND EMPTY QUEUE
	ISZ	ABTPDV	/POINT TO NEXT QUEUE
	ISZ	PDVCT	/FINISHED?
	JMP	DQLP	/NO KEEP TRYING
DQFIN	LAC	(POOL)	/RETURN ABORT NODE TO POOL
	DAC*	(R1)
	LAC	ABTNOD
	DAC*	(R2)
	AAC	6	/ADD 6 TO POINT TO EVENT VARITBLE ADDRESS
	DAC	ABTNOD
	LAC*	ABTNOD	/PICK UP EVENT VARIABLE
	TAD	XADJ	/ADD XR ADJUSTMENT
	PAX
	CLA!IAC
	DAC	0,X	/SET EVENT VARIABLE
	JMS*	(IOCD)	/DO AN I/O COUNT DOWN
	JMS*	(NADD)	/ADD A NODE TO THE POOL
	JMP*	DQALL	/RETURN TO CALLER ALL DONE
/
ABORT	LAC	DTEV	/CLEAR ABORT FLAG
	AND	(677777)
	.ENB		/ENABLE INTERRUPTS
	DAC	DTEV
	LAC	UNITAB	/FIND THE ABORT NODE
	TAD	MXADJ
	DAC*	(R1)
	JMS*	(DQRQ)	/DEQUEUE A NODE
	JMP	FNR	/CAN'T HAPPEN (I HOPE)
	DAC	ABTNOD	/SAVE THE NODE POINTER
	TAD	XADJ
	PAX
	LAC	5,X	/CHECK THE REQUEST TYPE
	SAD	(17)	/IS IT ABORT LUN 0
	SKP
	JMP	SEVM6	/ERROR ILLEGAL REQUEST KILL IT
	JMS	DQALL	/DO THE I/O RUNDOWN
	JMP	FNR	/FETCH NEXT REQUEST
/
ABTDQD	XOR	5,X	/WAS IT A LEGAL ABORT
	SZA		/?
	JMP	SEVM6	/NO RETURN -6 EV
	LAC	DTNODE
	DAC	ABTNOD	/SAVE IT IN ABORT NODE
	.INH		/RESET DECTAPE EVENT VARIABLE
	LAC	DTEV
	AND	(677777)
	.ENB
	DAC	DTEV	/CLEARING TTHE I/O RUNDOWN FLAG
	JMS	DQALL	/DO THE I/O RUNDOWN
	JMP	FNR	/FETCH TTHE NEXT REQUEST
/
/ HINF -- HANDLER INFORMATION THIS FUNCTION PROVIDES
/         THE USER WITH INFORMATION AS TO THE CHARACTERISTICS
/	  OF THE HANDLER -- FILE ORIENTED, INPUT, OUTPUT AND
/	  THE DEVICE AND UNIT NUMBERS
/
/
HINF	LAC	DTUN	/PICK UP THE UNIT NUMBER
	LRS	11	/PUT IT IN BITS 9-11
	AND	(700)
	XOR	HINFU	/INPUT,OUTPUT,FILE ORINETED,DT
	JMP	FINREQ+1
HINFU	340004
/
/ WFDT -- SUBROUTINE TO WAIT FOR 'DTEV' TO BE SET NON-ZERO.
/         IF POSITIVE, OPERATION WAS PERFORMED.  IF NEGATIVE,
/         OPERATION WAS NOT PERFORMED, CLOSE UNIT, SET USER'S EVENT 
/         VARIABLE TO THE NEGATIVE QUANTITY, AND FETCH NEXT
/         REQUEST.
/
WFDT	0
	JMS	DISP
WFDTW	CAL	WFDTEU
	LAW	-5
	DAC	ERCNT	/RESET ERROR COUNTER
	.INH		/INHIBIT ALL INTERRUPTS WHILE LOOKING AT EVENT VARIABLE
	LAC	DTEV
	AND	(100000)	/MASK OFF I/O RUNDOWN BIT
	SZA
	JMP	IORD		/I/O RUNDOWN REQUESTED
	LAC	DTEVA	/PICK UP STATUS AGAIN WHILE STILL INHIBITED
	.ENB		/AND THEN CLEAR THE STATUS
	DZM	DTEVA
	SMA
	JMP*	WFDT
/
	SAD	(400012)	/IS IT A SELECT ERROR
	SKP!CLC		/NO RETURN -12 TO  USER
	SKP
	JMP	ERM11
	LAC	DTUN	/PICK UP THE UNIT NUMBER
	LMQ
	ECLA!LLS 4
	TAD	DTMSNR+1	/PUT IT IN MESSAGE
	DAC	NTRD+1
	CAL	NTRDY	/PRINT MESSAGE ON LUN 3
	CAL	WFDTEU	/(JMW:062)WAIT FOR MESSAGE TO FINISH
	DZM	DTEVA	/(JMW:062)CLEAR EVENT VARIABLE
	LAC	OVSNRP	/PROTECT ENTRY AT FD1 IF TRYING TO RECOVER OVERSHOOT
	SZA!CLL
	STL
	LAC	(JMP	FD1)	/SET UP RECOVERY
	SZL		/OVERSHOOT?
	LAC	(JMP	FD2)	/YES DON'T RETURN AT FD1
	DAC	DISPX	/RETURN TO INTERRUPT ROUTINE
MTWF	CAL	MTRQ	/10 TIC MARK TIME REQUEST
	DTXA+10		/CLEAR EF AND DT FLAGS
	CAL	WFDTEU	/(JMW:062)WAIT FOR MARK TIME
	LAC	DTEV	/(JMW:063)
	AND	(100000	/(JMW:063) MASK OFF I/O RUNDOWN BIT.
	SNA		/(JMW:063) ABORT REQUESTED?
	JMP	MTWF.X	/(JMW:063) NO - CONTINUE.
	.INH		/(JMW:063) INHIBIT ALL INTERRUPTS
	XOR	DTEV	/(JMW:063) REMOVE IORD REQUEST.
	DAC	DTEV	/(JMW:063) RESTORE EV.
	.ENB		/(JMW:063) ENABLE INTERRUPTS.
	LAC	UNITAB	/(JMW:063) DEQUE THE REQUEST.
	TAD	MXADJ	/(JMW:063) REMOVE XR ADJUSTMENT
	DAC*	(R1	/(JMW:063)
	JMS*	(DQRQ	/(JMW:063)
	JMP	MTWF.X	/(JMW:063) JUST IN CASE
	DAC	ABTNOD	/(JMW:063) SAVE THE NODE ADDRESS
	CLX		/(JMW:063)
	AXR	2	/(JMW:063) FIND THE STL POINTERS
	LAC*	ABTNOD,X /(JMW:063) GET THE STL ADDRESS
	SAD*	ABTNOD,X /(JMW:063) SAME TASK?
	JMP	IORD.X	/(JMW:063) YES - ABORT CURRENT I/O
	JMS	DQALL	/(JMW:063) ABORT TASKS I/O
MTWF.X	DTEF		/(JMW:063) FLAGS CLEAR?
	SKP		/YES EXIT
	JMP	MTWF	/NO DO ANOTHER WAIT
	DZM	DTEVA	/CLEAR TRIGGER
	JMP	WFDT+1
/
/ INTERRUPT BLOCK
/
DTINT	0
	DBA
	DAC	DTSVAC	/SAVE AC DURING INTERRUPT SERVICE
	JMS	DISP	/SERVICE INTERRUPT
	LAC	DTSVAC	/RESTORE AC BEFORE RETURNING
	DBR
	JMP*	DTINT	/RETURN TO NEXT TASK
/
/ DISPATCH
/
DISP	0
DISPX	XX		/DISPATCH SWITCH
/
/ FXBLK -- FIND & TRANSFER BLOCK WHOSE NUMBER IS IN AC
/
FXBLK	DAC	FDBLK	/SAVE BLOCK NUMBER
/
FD1	LAC	FDBLK	/SEARCH FOREWARD
	JMS	SEARCH
	JMP	RWBLK	/BLOCK FOUND -- EXIT
	LAC	(FW!RV)	/OVERSHOOT -- SET REVERSE
	DTXA
	DAC	OVSNRP	/DEPENDS UPON FREE INSTRUCTION AFTER IOT
			/TO PROTECT AGAINST HANGING DT BY REVERSING DIRECTION
FD2	LAC	DIROVS	/MOVE TAPE BACK TWO
	TAD	FDBLK
	JMS	SEARCH
	NOP		/OVERSHOOT IF BLK-2 IS 
	LAC	(FW!RV)	/SET FOREWARD AND SEARCH FOR BLOCK
	DTXA
	DZM	OVSNRP	/CLEAR OVERSHOOT PROTECT FLAG DEPENDS UPON FREE
			/INSTRUCTION AFTER IOT
	JMP	FD1
/
/ DESIRED BLOCK NUMBER HAS BEEN FOUND, R/W BLOCK.  FLAGS ARE LEFT
/ SET UNTIL FUNCTION IS SWITCHED FORM SEARCH TO READ/WRITE SO THAT A
/ TIMMING ERROR WILL OCCURR IF THE SWITCH IS NOT MADE BEFORE THE DATA 
/ AREA HAS REACHED THE R/W HEADS.
/
RWBLK	LAW	-400	/SET WORD COUNT FOR A STANDARD DECTAPE BLOCK (256 WDS)
	DAC*	WCA
	LAC	(JMP XFRFIN)/SET DISPATCH SWITCH
	DAC	DISPX
	LAC	RWSW	/CLEAR FLAGS AND SWITCH FROM SEARCH TO READ/WRITE
	DTXA		/(IOT MUST IMMEDIATELY PRECEDE 'JMP* DISP')
	JMP*	DISP	/EXIT -- WAIT FOR INTERRUPT
/
/ REQUESTED BLOCK HAS BEEN READ -- SETUP FOR NEXT BLOCK REQUEST
/
XFRFIN	DTEF		/ERR FLAG?
	SKP
	JMP	RETRY	/YES -- RETRY
	LAC	(NG!GO!DI!EI!CE!CD)/RESET GO-BIT, DISABLE INTERRUPTS,
	DTXA		/AND CLEAR DT FLAGS.
	LAC	NBT	/UPDATE 'NBT' & 'LBT'
	DAC	LBT
	LAC	DBUF+377
	DAC	NBT
	ISZ	DTEVA	/SET EVENT VARIABLE POSITIVE
DIRFWV	NOP		/CHECK DIRECTION FOR NEXT BLOCK
/
XFINX	LAC	(401000)	/SET 6
	ISA
	LAC	(JMP FXBLK)	/SET DISPATCH SWITCH
	DAC	DISPX
	JMP*	DISP	/EXIT
/
FDBLK	0
DIROVS	-2	/OVERSHOOT BACKSPACE COUNT
/
/DIRFW AND DIRRV REVERSE THE DECTAPE DIRECTION WHEN NECESSARY
/
DIRFW	0
	TCA
	TAD	LBT
	SPA
	JMP*	DIRFW
	LAC	(2)
	DAC	DIROVS	/CHANGE DIRECTION
	LAC	(FW!RV)	/OF DECTAPE TO WRITE BACKWARDS
	DTXA
	LAC	(JMS	DIRRV)	/SET UP TRANSFER SWITCH
	DAC	DIRFWV
	JMP*	DIRFW
/
DIRRV	0
	TCA		/IN REVERSE DIRECTION
	TAD	LBT	/CHECK TO SEE IF DIRECTION CHANGE NEEDED
	SMA
	JMP*	DIRRV	/NO PROCEED
	LAW	-2
	DAC	DIROVS	/YES RESET POINTERS
	LAC	(FW!RV)
	DTXA		/AND REVERSE DECTAPE
	LAC	(JMS	DIRFW)
	DAC	DIRFWV
	JMP*	DIRRV
/
/ SEARCH -- SUBROUTINE TO SEARCH IN THE CURRENT DIRECTION FOR THE BLOCK
/           WHOSE BLOCK NUMBER IS IN AC.  RETURN WHEN THE BLOCK HAS BEEN FOUND.
/           THE DT FLAGS ARE CLEARED UPON ENTRY
/
/           IF BLOCK IS FOUND, RETURN AT JMS+1 WHTH FLAGS LEFT SET
/           IF OVERSHOT, RETURN AT JMS+2 WITH GO-BIT & FLAGS CLEARED
/
SEARCH	0
	DAC	RBUF	/SAVE NUMBER OF REQUIRED BLOCK
	LAC	(JMP SR1)	/SET DISPATCH SWITCH
	DAC	DISPX
	DZM*	WCA	/SET WORD COUNT TO AVOID OVERFLOW
	LAC	(BBUF)	/SET CORE ADDRESS TO STORE BLOCK NUMBERS IN 'BBUF'
	DAC*	CAA
/
	DTRA		/ALTER NECESSARY BITS OF DT STATUS REGISTER A SUCH
			/THAT FUNCTION IS SEARCH, MODE IS NORMAL, THE GO-BIT IS SET,
			/INTERRUPTS ARE ENABLED, & THE FLAGS ARE CLEARED
			/(THE DIRECTION IS UNCHANGED).
	AND	(GO!NG!NM!CM!MV!SE!RD!WD!EI!DI)
	XOR	(GO!NM!SE!EI!PE!PD)
	DTXA		/(IOT MUST IMMEDIATELY PRECEDE 'JMP* DISP')
/
	JMP*	DISP	/EXIT -- WAIT FOR INTERRUPT
/
/ A BLOCK HAS BEEN READ
/
SR1	DTEF		/ERR FLAG?
	JMP	SR3	/NO -- DESIRED BLOCK CHECK
	DTRB		/YES -- END ZONE?
	AND	(270000)
	SNA
	JMP	SROVS	/YES -- EXIT AT JMS+2
RETRY	DTRB		/READ THE ERROR STATUS
	ISZ	ERCNT	/INCREMENT ERROR COUNT
	SKP!RTL		/PUT SELECT ERROR BIT IN BIT 0
	JMP	FATAL	/FATAL ERROR CAN'T RECOVER
	RAL	
	SPA!CLL		/IS IT A SELECT ERROR?
	JMP	SELER	/YES GO OUTPUT MESSAGE
	DTXA+10		/CLEAR ERROR CONDITION AND TRY AGAIN
	JMP	SEARCH+2 /NO TRY AGAIN AND SEE IF IT CAN BE DONE THIS TIME
FATAL	DTRA		/STOP THE DECTAPE
	AND	(GO!NG)
	DTXA
	LAC	(400012)
	DAC	DTEVA
	JMP	XFINX	/SET EVENT VARIABLE TO NEGATIVE TO SIGNIFY FATAL ERROR
SELER	LAC	(400005	/RESET THE ERROR COUNT
	DAC	DTEVA
	LAC	(DI!EI)	/DISABLE INTERRUPT
	DTXA
	LAC	(401000)
	ISA		/SET SIGNIFICANT EVENT
	JMP*	DISP	/EXIT
SR3	LAC	BBUF	/DETERMINE DIFFERENCE BETWEEN DESIRED BLOCK
	AND	(1777)	/MASK OFF ILLEGAL BLOCK NUMBERS
	TCA		/AND JUST DETEECTED BLOCK NUMBERS.
	TAD	RBUF
	SNA!CLL		/DESIRED BLOCK?
	JMP*	SEARCH	/YES -- EXIT SEARCH AT JMS+1 WITH FLAGS SET
	TCA
	SMA		/CALCULATE DIFFERENCE BETWEEN DESIRED BLOCK
	TCA!STL		/AND BLOCK FOUND
	DAC*	WCA	/PUT IN TWO'S COMPLEMENT IN BLOCK COUNTER (WORD COUNT)
/			/NO -- HAS DESIRED BLOCK BEEN OVERSHOT?
	DTRA
	AND	(FW!RV)
	SNA
	JMP	SR4
	SNL
	JMP	SROVS	/YES (OVERSHOOT) -- EXIT SEARCH AT JMS+2
	JMP	SR5	/NO (OVERSHOOT) -- CLEAR FLAGS & WAIT FOR NEXT INTERRUPT
SR4	SZL
	JMP	SROVS	/YES (OVERSHOOT) -- EXIT SEARCH AT JMS+2
SR5	LAC	(NM!CM)	/NO (OVERSHOOT) -- SET CONTINUOUS MODE SEARCH
	DTXA
	JMP*	DISP	/EXIT -- WAIT FOR INTERRUPT
/
/ CONTROL WILL BE TRANSFERRED TO 'SR1' AT NEXT INTERRUPT
/
SROVS	LAC	(GO!NG!CD!CE)	/RESET GO-BIT, CLEAR FLAGS, AND
	DTXA			/EXIT SEARCH ROUTINE AT JMS+2
	ISZ	SEARCH
	JMP*	SEARCH
/
ATTACH	LAC	CUS	/CHECK TO SEE THAT NO FILE IS OPEN
	SZA!CLA
	JMP	ERM10	/FLUSH REQUEST ATTACH ILLEGAL WITH FILE OPEN
	LAC	DTHEAD	/PICK UP THE HEAD OF THE PVDL POINTER
	DAC*	(R1)
	LAC	DTNODE	/PICK UP THE NODE POINTER
	DAC*	(R2)
	JMS*	(ALAD)	/ATTACH LUN AND DEVICE
	JMP	FLSRQ1	/ERROR
	ISZ	RAT	/INDICATE REAL ATTACH
	JMP	FINREQ	/EXIT
/
/
DETACH	LAC	CUS	/CHECK TO SEE THAT NO FILE IS OPEN
	SZA!CLA
	JMP	ERM10	/DETACH CAN NOT BE DONE WITH FILE OPEN
	DZM	RAT	/CLEAR REAL ATTACH FLAG
	LAC	DTHEAD	/PUT PDVL HEAD IN R1
	DAC*	(R1)
	LAC	DTNODE	/PUT NODE NAME AND LUN IN R2
	DAC*	(R2)
	JMS*	(DLAD)	/DETACH LUN AND DEVICE
	JMP	FLSRQ1	/ERROR
	JMP	FINREQ
ATTCH	0		/PSEUDO ATTACH
	LAC	RAT	/CHECK TO SEE IF ATTACH HAS BEEN DONE
	SZA
	JMP*	ATTCH	/EXIT IF ALREADY ATTACHED
	LAC	DTHEAD	/PICK UP THE PDVL HEAD
	DAC*	(R1)
	LAC	DTNODE	/PICK UP THE POINTER TO THE NAME AND LUN
	DAC*	(R2)
	AAC	4
	DAC	TEMP1	/SAVE THE LUN
	LAC*	TEMP1
	DAC	LUNSV
	JMS*	(ALAD)	/ATTACH TO LUN AND DEVICE
	JMP	FLSRQ1
	JMP*	ATTCH
/
/
DETCH	0
	DZM	CUS	/CLEAR THE FILE OPEN SWITCH
	PAL		/SAVE AC
	LAC	DTNODE	/PICK UP THE NODE ADDRESS
	DAC*	(R2)
	AAC	4	/POINT TO THE LUN
	DAC	TEMP1
	LAC	LUNSV	/SET UP TO DETACH FROM THE LUN ATTACHED
	DAC*	TEMP1
	LAC*	(X10)	/SAVE X10 AND XR
	DAC	TEMP1
	PXA
	DAC	TEMP2
	LAC	RAT	/IS THIS A REAL ATTACH?
	SZA
	JMP	DETCH1	/YES EXIT1
	LAC	DTHEAD	/PICK UP THE PDVL POINTER
	DAC*	(R1)
	JMS*	(DLAD)	/DETACH THE PSEUDO ATTACH
	NOP		/ERROR EXIT CAN'T GET HERE UNLESS DETACHED AND THAT IS BAD
	LAC	TEMP1	/RESTORE BUFFER POINTER
	DAC*	(X10)
	LAC	TEMP2
	PAX
DETCH1	PLA
	JMP*	DETCH	/RETURN DETACHED
DETAT	12
	0
	4		/INTERRUPT LINE
	DTINT		/INTERRUPT ADDRESS
/
/
/
/
RBUF	0		/DESIRED BLOCK NUMBER (SEARCH)
/
NBT	0	/NEXT BLOCK TO BE TRANSFERRED
LBT	0	/LAST BLOCK TRANSFERRED
/
RWSW	0	/READ-WRITE SWITCH (CONSTANT TO SWITCH FROM SEARCH
		/TO READ OR WRITE VIA XOR A-REG)
/
DTUEVA	0	/USER'S EVENT VARIABLE ADDRESS
DTEV	0	/DECTAPE EVENT VARIABLE
DTUN	0	/TAPE UNIT NUMBER (BITS 0-2)
CUS	0	/CURRENT UNIT STATUS
		/   0 -- NO UNIT OPEN
		/   + -- UNIT (DTUN) IS OPEN FOR READ
		/   - -- UNIT (DTUN) IS OPEN FOR WRITE
FNE	.BLOCK 3	/FILE NAME & EXTENSION
SBA	0	/STARTING BLOCK ADDRESS FOR ENTER
XADJ	0	/XR ADJUST CONSTANT
MAXWPC	0	/MAX WORD-PAIR COUNT
UBUFA	0	/USER BUF ADDRESS
DTSVAC	0
/
TEMP1	0
TEMP2	0
DTASBT	.SIXBT	"DT@"
DTHEAD	0
DTNODE	0
UNITCN	0
MXADJ	0
UNITAB	.BLOCK	10
ERCNT	-5
FBN	0
X10SV	0
XRSV	0
FLFND	0
OVSNRP	0
RAT	0
LUNSV	0
ABTNOD	0	/ABORT NODE FOR I/O RUNDOWN
PDVCT	0	/PHYSICAL DEV COUNT FOR I/O RUNDOWN
ABTPDV	0	/PHYSICAL DEVICE POINTER FOR ABORT
ABTFL	0	/ABORT FLAG TO PROTECT AGAINST ABORT WHILE CLOSING
/
MTRQ	13		/MARK TIME REQUEST
	DTEVA		/(JMW:062)
	10		/10 TICKS
	1
/
NTRDY	2700
	DTEVA		/(JMW:062)
	3
	2
	NTMS
NTMS	DTMSNR-NTMS/2*1000+2
	0
	.ASCII	"**** READY"
NTRD	.ASCII	" DT 0"<15>
DTMSNR	.ASCII	" DT 0"
/
/
WFDTEV	20
	DTEV
WFDTEU	20
	DTEVA
DTEVA	0
/
	.END	DTRQ
