	.TITLE DTA.
 
/ .... EDIT #13 .... 2 JUN 70
/M. SIFNAS 
/COPYRIGHT 1969, 1970 DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
/BACKGROUND/FOREGROUND DECTAPE HANDLER
/N FILES OPEN WHERE N MAY BE DEFINED AT ASSEMBLY TIME AS A
/
/PARAMETER ASSIGNMENT: DN=N
/DEFAULT ASSUMPTION: DN=16(DEC)
/
/CALLING SEQUENCE:
	/CAL+.DAT SLOT(9-17)
	/FUNCTION
	/N ARGUMENTS(F OF FUNCTION)
	/NORMAL RETURN
/IF DTA. IS ASSEMBLED WITH RESMON, TTA. WILL BE DEFINED.
	.IFUND TTA.
	.GLOBL	DTA.
DT.PI=0			/CONDITIONALIZE IN BOTH
DT.API=0			/PI AND API CODE.
	.ENDC
	.IFDEF TTA.
	.LOC .+3&77774
	.IFDEF PI
DT.PI=0			/CONDITIONALIZE IN THE PI CODE.
	.ENDC
	.IFUND PI
DT.API=0			/CONDITIONALIZE IN THE API CODE.
	.ENDC
	.ENDC
/IOT ASSIGNMENTS
DTCA=707541
DTXA=707544
DTLA=707545
DTRA=707552
DTRB=707572
DTEF=707561
.MED=3
DTDF=707601
IDX=ISZ
	.IFUND .SCOM
.SCOM=100
	.ENDC
	.IFUND DN
DN=20			/16 FILES OPEN
	.ENDC
DELTA=5
	.EJECT
DTA.	JMS	DTSWAP	/(0) SWAP LIVE AND BACKUP CELLS
	0		/(1) FORE BUSY CELL (NON 0=BUSY:-.DAT SLOT#)
	0		/(2) BACK BUSY CELL
	0		/(3) FORE .CLOSE CELL (NON0=.CLOSE OR .OPER)
			/WHERE DTA. PLACES .OPER "AC"+1 IN .CLOSE CELL
	0		/(4) BACK .CLOSE CELL
DTSWCH	XX		/(5) ION OR IOF (PIC STATE ON INTERRUPT
			/OR CAL ENTRIES)
DTWRD6	XX		/(6) ION, IOF OR DBR (CAL/INTERRUPT LEVEL
			/SWITCH: DBR IF INTER.; SAME AS WD 5
			/IF CAL LEVEL
DTTOUT	XX		/(7) RETURN POINTER (INTER. LEVEL: INTER-
			/RUPTED ADDR.; CAL LEVEL: RETURN CELL
			/AFTER CAL ARGUMENTS
/START OF BACKUP DATA CELLS
DBACK=.
	XX		/(10) JMP FUNCTB
	XX		/(11) USER CAL IN PROGRESS:0=FORE; 1=BACK
	XX		/(12) .DAT SLOT#(18 BIT NEG., IF NEG.)
	XX		/(13) BITS 0-2: UNIT#
			/ BITS 3-17: ADDR OF CAL FOR .MED EXITS
	XX		/(14) .INIT - FILE TYPE:0=INPUT; 1=OUTPUT
			/ .READ,.REALR - DATA MODE
			/ .WRITE,.REALW-  "    "
			/	0=IOPS BIN
			/	1=IMAGE BIN
			/	2=IOPS ASCII
			/	3=IMAGE ALPHA
			/	4=DUMP(5,6,7 MAY APPEAR, BUT ILLEGAL)
			/ .MTAPE-.MTAPE FUNCTION (0-17)
			/ .TRAN - DIRECTION (0-3)
			/ .OPER - SUBFUNC (1-3)
	XX		/(15) .INIT - USER RESTART ADDR.
			/ .READ ,.REALR - LINE BUFFER
			/ .WRITE,.REALW - ADDRESS
			/ .OPER,.ENTER, - ADDR.OF DIRECTORY
			/ .SEEK - ENTRY BLOCK
			/ .TRAN - CORE ADDR.
	XX		/(16) .INIT - ADDR. FOR BUFF. SIZE
			/ .READ,.REALR - LINE BUFFER W.C.(CAL)
			/ .WRITE,.REALN - "     "     "  (FROM
			/ W.P.C. EXCEPT DUMP MODE - (WPC*2)
			/ W.P.C. EXCEPT DUMP MODE - (WPC*2)
			/ .TRAN - WORD COUNT
	XX		/(17) .TRAN - DEVICE ADDR. (BLK.#)
			/ .FSTAT - ADDR. FOR DIRECTORY CODE
			/ .REALR,.REALW - COMPLETION RETURN
			/ ADDR.; BIT 0-2: PRIORITY LEVEL
			/ .READ,.WRITE -0
/BACKUP DATA CELLS END WITH WD.17
	.EJECT
/FUNCTION DISPATCH TABLE
	JMP	DTIN	/(20) .INIT - 1
	JMP	DTOPER	/(21) .OPER -2
	JMP	DTSEEK	/(22) .SEEK - 3
	JMP	DTENTR	/(23) .ENTER - 4
	JMP	DTCLER	/(24) .CLEAR - 5
	JMP	DTCLOS	/(25) .CLOSE - 6
	JMP	DTMTAP	/(26) .MTAPE - 7
DREAD	JMP	DTREAD	/(27) .READ(.REALR)-10
DWRITE	JMP	DTWRIT	/(30) .WRITE(.REALW)-11
	XX		/(31) .WAIT,.WAITR-12(BY CAL HANDLER)
	JMP	DTRAN	/(32) .TRAN-13
DSCM35	XX		/(33) .SCOM+35 STORAGE
	DFSTOP		/(34) 15 BIT ADDR OF SUB TO STOP F I/O
	DBSTOP		/(35) 15 BIT ADDR OF SUB TO STOP B I/O
	-1		/(36) HANDLER I.D. CODE (MUST BE 0)
/I.D. CODE IN CELL (36) IS TEMPORARILY -1 FOR
/FIELD TEST VERSION TO ALLOW .INIT INTO DTA.
/START OF LIVE DATA CELLS (SEE 10-17 ABOVE)
DLIVE	XX		/L10
	XX		/L11
	XX		/L12
	XX		/L13
DTRWAY	XX		/L14
	XX		/L15
	XX		/L16
DTWD17	XX		/L17
DSWCT=DLIVE-.		/LIVE CELL COUNT
DSCM56	0		/.SCOM+56 STORAGE (GETBUF POINTER)
	.EJECT
/END OF LIVE DATA CELLS
DTER06	LAW	6	/ILLEGAL FUNCTION FOR HANDLER: .ERR 006
	STL		/L=1=TERMINAL ERROR
DTEROR	DAC	DERLAW
	SNL		/IF TERMINAL ERROR,
	JMP .+4
	DTRA		/CLEAR FLAGS
	AND (757400
	DTXA
	LAC	DLIVE+1	/USER:0=F;1=B
	SZA
	LAC	(3000	/BIT7=1=B
	XOR	(1000	/BIT8=1=F
	SZL
	XOR	(4000	/BIT6=1=TERMINAL
	XOR	DERLAW
	DAC	DERLAW
	LAC*	(.SCOM+66	/MONITOR ERROR ROUTINE POINTER
	DAC	DERTEM
	.IFDEF DT.API
	LAC	(400200
	ISA		/RAISE TO LEVEL 0
	.ENDC
	.IFDEF DT.PI
	IOF		/PIC OFF
	.ENDC
	.EJECT
DERLAW	XX		/ERROR CODE
	JMS*	DERTEM
DERPNT	XX		/CAL ADDR.,STATUS,ETC-TO BE PRINTED WITH ERROR
	.IFDEF DT.API
	DBK
	.ENDC
	.IFDEF DT.PI
	ION
	.ENDC
	JMP DTEMPT	/I/O REQ. DONE
DERTEM	0		/TEMP FOR ERROR ROUTINE POINTER
/DTA INTERRUPT SERVICE
DTPIC=.
	.IFDEF DT.PI
	.IFUND DT.API
DTINT=.
	.ENDC
	DAC	DTSVAC	/SAVE AC
	LAC*	(0
	DAC	DTMPOT	/SAVE PC,L,EM,MP IN TEMP.
	LAC	DTION
	.IFDEF DT.API
	JMP DTSTON
	.ENDC
	.ENDC
	.IFDEF DT.API
DTINT	JMP	DTPIC
	DAC	DTSVAC	/API  "   ,SAVE AC
	LAC	DTINT	/PC,L,EM,MP
	DAC	DTMPOT	/TEMP.
	.IFDEF DT.PI
	DZM	DTINT	/0=API ENTRY
	.ENDC
	IORS		/READ I/O STATUS
	SMA!CLA
	LAW	17740	/PIC OFF - BUILD IOF
	TAD	DTION	/PIC ON -    "   ION
	.ENDC
DTSTON	DAC DBRLIT+1
/NOW CHECK SWITCHES: DNOIO (-1 IF IGNORE PHONY INTERRUPT);
/		  DTIGNR (-1 IF BGRD I/O LEFT GOING WHILE
/			FGRD CALL BEING HONORED)
	LAC DTIGNR	/BGRD I/O GOING SW.
	RAR		/SAVE IN LINK
	LAC DNOIO		/IGNORE PHONY INTERR. SW.
	DZM DNOIO
	DZM DTIGNR
	SNL!SMA		/SKIP ON "OR" CONDITION
	JMP DTSTOY	/NEITHER SET: NORMAL INTERR.
	.EJECT
/IF GO BIT ON, TURN IT OFF
	DTRA
	DAC DBDONE	/TEMP
	AND (20000
	SZA
	DTXA
	SNL!CLA		/L=1 IF DTIGNR WAS SET
	JMP DBDSET	/GET OUT; ONLY DNOIO WAS SET
/IF STATUS B INDICATES NO ERRORS AND FUNCTION WAS READ OR WRITE
/(MEANING BGRD I/O WAS REALLY DONE,DBDONE WILL BE SET (NON-0)
/TO TAKE ADVANTAGE OF TRANSFER DONE RATHER THAN AUTOMATICALLY
/RESTARTING BGRD I/O
	DTRB		/EF SET?
	SPA!CLA		/NO
	JMP DBDSET	/YES, IGNORE TRANSFER
	LAC DBDONE	/STATUS A
	AND (7000		/CHECK FOR READ,WRITE
	XOR (1000		/SEARCH=1000
DBDSET	DAC DBDONE	/0(CLEAR) IF SEARCH;NON 0 IF DONE
	LAC DTSVAC	/RESTORE INTERRUPTED AC
DBRLIT	DBR
	XX		/ION OR IOF (STATE BEFORE INTERRUPT)
	XCT .+1
	XCT .+1
	JMP* DTMPOT	/EXIT
/CONTROL COMES HERE FOR NORMAL INTERRUPT
DTSTOY	LAC DTMPOT	/PC, ETC
	DAC DTTOUT	/REAL EXIT = DTA.+7
	LAC DBRLIT+1	/ION OR IOF
	DAC	DTSWCH	/.DTA+5
	LAC*	(.SCOM+35
	DAC	DSCM35
	CLA!CMA
	DAC*	(.SCOM+35
	.IFDEF DT.PI
	.IFDEF DT.API
	LAC DTINT
	SZA
	.ENDC
	DZM*	(0	/PIC ENTRY
	.ENDC
	LAC	DBRLIT
	DAC	DTWRD6	/SETUP WD6 (DBR) FOR EXIT
	.EJECT
/STATUS B-0=EF
/	1=MK. TK. ERR.
/	2=EOT
/	3=SELECT ERR
/	4=PARITY ERR.
/	5=TIMING ERR.
/	11=DTF
/STATUS A-0-2=UNIT#
/	3=FORW.(0),REV(1)
/	4=GO(1),STOP(0)
/	5=NORM.(0),CONT.(1)
/	6-8=FUNCTION (SEARCH=1,READ=2,WRITE=4)
/	9=DISABLE DTF,EF(0),ENABLE(1)
/	10=CLEAR EF(0)
/	11=CLEAR DTF(0)
	DTRB			/READ DTA STATUS B
	SMA
	.EJECT
/DTDIS = JMP DTSRCK ON SEARCH
/DTDIS = JMP DTRDWT ON READ OR WRITE
DTDIS	XX
	AND	(330000
	SZA!RTL			/SELECT ERROR
/DTERJ=	JMP	DTERS		/ON SEARCH
/	JMP	DTERT		/ON READ OR WRITE
DTERJ	XX
/WITH THE DEVICE (UNIT) NOT READY, IT IS NOW NECESSARY TO DEFER
/THE DESIRED IOT, ANNOUNCE THE NON-TERMINAL ERROR AND EXIT FROM THE
/HANDLER SET UP TO CONTINUE WHEN ^R IS TYPED ON THE USER'S CONTROL TTY.
 
	LAC	DLIVE+1		/0=FGRD; 1=BGRD
	TAD	(DFIOAC		/POINT TO FGRD OR BGRD SAVED AC REG.
	DAC	DPIOTB
	DTRA
	AND	(740000		/SAVE STATUS A
	XOR	(21400
	DAC*	DPIOTB
	DTLA+10			/CLEAR A, FLAGS, DISABLE FROM INT.
	DZM	DBDONE
	LAC	DTIOF		/EXECUTE IOF IN PLACE OF IOT
	DAC	DTIOT
	JMS	DTMSG		/INITIATE NOT READY MSG.
	JMP	DTNOR
 
/SUBROUTINE TO CALL A ROUTINE IN THE RESIDENT MONITOR TO INITIATE A
/NOT READY MESSAGE.
/CALLING SEQUENCE:
/	JMS	DTMSG
/	RETURN WITH DFCTLR (DBCTLR) NON-0 IF REQUEST HONORED.
/	OTHERWISE, DFCTLR (DBCTLR) IS SET TO 0 AND A TERMINAL
/	ERROR WILL RESULT.
 
DTMSG	0
 
/DETERMINE WHICH JOB (FGRD OR BGRD) IS CURRENTLY MANIPULATING
/THIS DEVICE.
 
	LAC	DLIVE+1		/0=FGRD; 1=BGRD
	DAC	DTARG1
	TAD	(DFCTLR		/COMPUTE ADDRESS OF THE
	DAC	DTTMP2		/APPROPRIATE ^R FLAG.
	LAC*	DTTMP2		/EXIT IF MESSAGE ALREADY
	SZA!CMA			/REQUESTED FOR THIS DEVICE.
	JMP*	DTMSG
	DAC*	DTTMP2		/SET ^R FLAG.
	LAC	DLIVE+3		/UNIT NUMBER (BITS 0-2) IF
	DAC	DTARG3		/APPLICABLE.
	LAC*	(.SCOM+64		/POINTER TO ^R QUEUER IN MONITOR.
	DAC	DTTMP1
	.IFDEF DT.API
	LAC	(400200		/RAISE TO API LEVEL 0.
	ISA
	.ENDC
	.IFDEF DT.PI
	IOF
	.ENDC
	JMS*	DTTMP1		/GO TO ^R QUEUER.
DTARG1	XX			/0=FGRD; 1=BGRD.
	.ASCII	/DT/		/DEVICE NAME.
	.LOC	.-1
DTARG3	0			/UNIT NUMBER (BITS 0-2) IF APPLICABLE.
	DTFRA+100000		/FGRD ^R SUBR + DEVICE'S API LEVEL.
	DTBRA+100000		/BGRD ^R SUBR + DEVICE'S API LEVEL.
 
/SKIP ON RETURN IF REQUEST HONORED. IF NOT, ^R QUEUER WILL ALREADY
/HAVE REQUESTED A TERMINAL ERROR.
 
	DZM*	DTTMP2		/CLEAR ^R FLAG - REQUEST NOT HONORED.
	.IFDEF DT.API
	DBK			/DEBREAK FROM LEVEL 0.
	.ENDC
	.IFDEF DT.PI
	ION
	.ENDC
	JMP*	DTMSG
 
/FOREGROUND ^R PROCESSOR.
/SUBROUTINE ENTERED AT API LEVEL 1, PIC OFF, WHEN ^R IS INPUT FROM
/KEYBOARD.
 
DTFRA	0
 
	DZM	DFCTLR		/CLEAR FGRD ^R FLAG.
	JMS	DTSRCH		/SET UP FOR SEARCH.
	LAC	DFIOAC		/AC FOR IOT
	DTLA
	ION
	DBR			/DEBREAK FROM LEVEL 1.
	JMP*	DTFRA
 
/THE ^R IN PROGRESS FLAGS MUST INITIALLY BE SET TO 0 AND MUST
/BE CLEARED IN THEIR RESPECTIVE STOP I/O ROUTINES.
 
DFCTLR	0			/FGRD ^R FLAG.
DBCTLR	0			/BGRD ^R FLAG.
 
/BACKGROUND ^R PROCESSOR.
/ENTERED AT API LEVEL 1, PIC OFF, WHEN ^R IS INPUT FROM KEYBOARD.
 
DTBRA	0
 
	DZM	DBCTLR		/CLEAR BGRD ^R FLAG.
	LAC	DTA.+1		/FGRD BUSY REGISTER.
	SZA
	JMP	DTBOUT		/FGRD BUSY--EXIT.
	JMS	DTSRCH		/SET UP FOR SEARCH.
	LAC	DBIOAC		/AC FOR IOT.
	DTLA
DTBOUT	ION
	DBR			/DEBREAK FROM LEVEL 1.
	JMP*	DTBRA
 
DTTMP2=.
DPIOTB	0
DFIOAC	0			/FGRD AC FOR IOT.
DBIOAC	0			/BGRD AC FOR IOT.
 
/ERROR IN SEARCH MODE
DTERS	SPA
	JMP	DTEOT		/EOT-CHANGE DIRECTION
	LAC	(20000		/SET UP GO BIT
	SNL			/MARK TK
	JMP	DTXIOT		/TIMING - RETRY
	ISZ	DTERCT		/RETRY OVERFLOW
	JMP	DTXIOT		/NO, RETRY
	LAW	-1		/YES. FORCE ERROR MSG;
	DAC	DTERCT		/FALL THRU
DTERS1	STL			/FOR DTTIM
	ISZ	DTERCT
	JMP	DTTIM		/RETRY
	DTRA			/GET UNIT #
	RTL
	RTL			/INTO 15-17
	AND (7
	DTRB-10			/IOR STATUS B
	DAC	DERPNT		/SET UP TO PRINT STATUS B
	CLA			/IRREC. DTA ERROR
	JMP	DTER12		/MK. TK. OR EOT DURING READ OR WRITE
/ERROR DURING READ OR WRITE
DTERT	SZL!SPA!RTL		/PARITY OR TIMING
	JMP	DTERS1		/MK. TK. OR EOT DURING TRANSFER
	SMA!STL			/PARITY - SET LINK FOR TIMING ERR. TO TURN ON GO BIT
	JMP	DTTIM		/TIMING ERROR.
	.EJECT
/PARITY ERROR
DTPART	ISZ	DTERCT	/INDEX PARITY ERROR CT.
	JMP DTTIM-1	/TRY AGAIN 
	LAC* (30		/WC OVERFLOW?
	SMA		/NO, MUST GET REST OF DATA
	JMP DTRDWT	/YES, ACCEPT DATA AS IS
	DAC DTCCA		/TEMP STORE REMAINDER
	LAC DTWC		/(ORIG. WC - REMAINDER)
	CMA!STL		/LINK WILL BE COMPLEMENTED ON TAD DTCCA
	TAD (1
	TAD DTCCA
	RTR
	RTR
	RTR
	RTR
	TAD DTBLC		/FORMER BLK #
	DAC DTBLC
	DAC DTNXBK	/NEW BLK # -DTSAFE
	LAC DTCCA		/RESET WC FOR REMAINDER
	DAC DTWC
	LAC* (31
	DAC DTCCA		/REST CURR ADDR
	LAW -10
	DAC DTERCT	/RESET PARITY TRY COUNT
/LINK MUST BE 0 FOR PARITY SINCE GO BIT REMAINS ON FOR PARITY ERR.
	CLL
DTTIM	JMS	DTSRCH	/SET UP FOR SEARCH
	LAC	DTTR	/CLEAR OUT READ OR WRITE BITS
	SZL		/PARITY ERR.
	XOR (20000	/TIMING ERR.;TURN GO BIT BACK ON
	DTXA
	JMP	DCHK2	/SEARCH AGAIN FOR RETRY
/PHYSICAL DATA TRANSFER IS COMPLETED, I/O REQ. MAY NOT BE
/CHECK TO SEE IF BLOCK WAS DIRECTORY
DTRDWT	DZM	DTEOTZ	/SET DOUBLE END ZONE SWITCH
L7777	LAW	-100	/WAS DIR. (BL 100) READIN
	TAD	DTBLC
	SNA		/NO
	LAC	DTDRGT	/GET DIR SWITCH SET
	SZA!CLC		/YES-CLEAR
	JMP	DTRWEN
	DAC	DTDRGT
	DAC DTRASV	/CLEAR STATUS A SAVED
	LAC	DLIVE+3	/UNIT#(BITS 0-2)
	AND	(700000
	DAC	DTNCOR	/SET DIR. INCORE SWITCH
	.EJECT
/STOP DECTAPE ANS SEE IF THERE IS ANY MORE TO DO FOR THIS REQUEST
DTRWEN	LAC	DBDONE		/BGRD DONE SW.SET?
	DZM	DBDONE
	SZA			/NO, NORMAL CASE
	JMP	DTRWN3		/YES, GO BIT ALREADY TURNED OFF
	LAC	(20000		/CLEAR GO BIT
	DTXA
DTRWN3	ION
	LAC	DTWRWT		/MORE TO DO FOR THIS REQUEST?
	SNA
	JMP	DTEMPT		/REQUEST COMPLETED
	XCT	DTWRWT		/CONTINUE PRESENT REQ.
/SEARCH INTERRUPT SERVICE
DTSRCK	CLC
	DAC	DTEOTZ		/SET DOUBLE END ZONE SWITCH
	LAC	DTBCA		/BLK# JUST READ
	SAD	DTBLC		/BLK SEARCHED FOR
	JMP	DCHKF		/MAYBE-CHECK DIRECTION
	CMA
	TAD	DTBLC		/BLK# SEARCHED FOR-BL# READ
DCHKC	XCT	DCHKCX		/OVERSHOOT-FORW=SMA!CLA; SPA!CLA=REV.
	JMP	DTXIOT		/CONT. SEARCH, SAME DIRECTION
DTEOT	DAC	DTEOTS		/CLEAR (0) OR SET (-) EOT SWITCH
DCHK2	LAC	DTBLNC		/FORW: SUB. 2 FROM BL# TO SEARCH
DCHKC3	TAD	DTNXBK		/REV; AND 2 FROM BL# TO SEARCH -DTSAFE
	DAC	DTBLC
	CLC			/CHANGE SIGN OF BLK INCR.
	TAD	DTBLNC		/FOR NEXT DIRECTION CHANGE
	CMA
	DAC	DTBLNC
/THIS ROUTINE INSURES CORRECT SETTING OF DTBLC
/ON 1ST ENTRY INTO END ZONE
	LAC	DTEOTS		/END ZONE ENTERED SWITCH
	SMA
	JMP	DCHKC4		/NOT ENTERED
	ISZ	DTEOTZ		/DOUBLE END ZONE SWITCH SET
	JMP	DCHKC4		/NO
	LAC	DTNXBK		/STORE BL# TO TRANSFER -DTSAFE
	DAC	DTBLC		/INTO BL# TO SEARCH FOR
DCHKC4	LAC	DCHKCX		/SMA!CLA TO SPA!CLA
	XOR	(1000		/OR VICE VERSA
	DAC	DCHKCX
	LAC	DTEOTS		/EOT SWITCH
	RAL			/L = 1 = EOT
	LAC	(40000
	SZL			/NO EOT
	XOR	(20000		/EOT - SET GOBIT
	DZM	DTEOTS		/CLEAR EOT SWITCH
	JMP	DTXIOT		/CHANGE SEARCH DIRECTION
	.EJECT
/SUBR. TO CLEAR OUT TABLE DBPT AND .BFTAB,CLEAR BUSY, AND CLOSE SW.
/L=0=FGRD STOP
/L=1=BGRD STOP
DZSTOP	0
	CLA!RAL
	DAC DZT3		/0=F;1=B
	LAC DBPT		/DBPT TABLE COUNT
	DAC DZCNT
	LAC LDBPT1	/DBPT TABLE POINTER
	DAC DZPNT
DZCK	LAC DZT3
	RAR		/USER INTO LINK
	LAC* DZPNT	/PICK UP DBPT ENTRY
	SNA		/MAY NEED CLEARING
	JMP DZNDEX	/NEXT ENTRY
	DAC DZT1		/BUFFER POINTER
	TAD (2
	DAC DZT2		/.BFTAB POINTER
	LAC* DZT2
	DAC DZT2
	LAC* DZT2		/.BFTAB ENTRY (BIT0=0=F;0=1=B)
	SZL!SPA		/(AND SKIP)
	CML!CMA
	SZL!SPA
	JMP DZNDEX	/NO, ONLY CLEARED IF F+F OR B+B
	LAC* DZT2
	AND (200000
	SNA		/IN USE, CLEAR IT
	JMP DZNDEX
	XOR* DZT2
	DAC* DZT2
	DZM* DZT1		/CLEAR .DAT SLOT
	IDX DZT1
	DZM* DZT1		/CLEAR USER
	IDX DZT1
	DZM* DZT1		/CLEAR .BFTAB POINTER
	DZM* DZPNT	/CLEAR DBPT POINTER
	.EJECT
DZNDEX	IDX	DZPNT
	ISZ	DZCNT
	JMP	DZCK		/CHECK NEXT ENTRY
	LAC	DZT3		/0=F; 1=B
	TAD	(DZM DTA.+1	/DIRECTLY CLEAR BUSY FLAG
	DAC	.+3
	TAD	(2
	DAC	.+2
	XX
	XX			/DIRECTLY CLEAR CLOSE SWITCH
	JMP*	DZSTOP
DZCNT	0
DZPNT	0
DZT1	0
DZT2	0
DZT3	0
/SET UP FOR SEARCH MODE
DTSRCH	0
	LAC	(DTBCA		/SET UP CA AND WC
	DAC*	(31		/FOR SEARCH
	DZM*	(30		/WC
	LAC	(JMP DTSRCK	/SET UP INT. SERV.
	DAC	DTDIS		/FOR SEARCH
	LAC	(JMP DTERS
	DAC	DTERJ
	JMP*	DTSRCH
DCHKF	LAC	DTDTR		/TRANSFER DIRECTION .DTSAFD 
	XOR	DTBLNC
DLITSM	SMA!CLA
	JMP	DCHKC3		/CHANGE SEARCH DIR. AGAIN
/
/THIS IS IT, SET UP TO READ OR WRITE
/CRUCIAL THAT READ/WRITE BE EXECUTED WITHIN 200 MICRO.S.
/FROM SEARCH TO READ/WRITE
	LAC	DTWC		/SET UP-WC
	DAC*	(30
	LAC	DTCCA		/CA-1
	DAC*	(31		/FOR TRANSFER
	LAC	(JMP DTRDWT	/SET UP TRANSFER COMPLETE JMP
	DAC	DTDIS
	LAC	(JMP DTERT	/SET UP ERROR JMP
	DAC	DTERJ
	LAC	DTTR		/READ (13000) OR WRITE (15000)
DTXIOT	DTXA
	LAC	DTIOF
	DAC	DTIOT		/SET UP NOP IN EXIT IOT
	JMP	DTNOR		/INTERR SERV. EXIT TO CONT. I/O
	.EJECT
/STOP I/O SUBR'S
/FOREGROUND STOP SUBR.
DFSTOP	0
	.IFDEF DT.API
	LAC (400200	/RAISE TO API LEVEL 0
	ISA
	.ENDC
	.IFDEF DT.PI
	IOF		/PIC OFF
	.ENDC
	LAC	DTA.+1	/F BUSY?
	SNA!CLL
	JMP DFSTP1	/NO, DO NOT STOP DECTAPE
	JMS DTSTOP	/STOP F I/O IF UNDERWAY
	CLL!CLC
	DAC DTRASV	/CLEAR SAVED STATUS A (-1)
DFSTP1	JMS DZSTOP	/CLEAR F BUFFERS (LINK MUST=0)
	DZM DFCTLR	/FGRD ^R FLAG.
	.IFDEF DT.API
	DBK
	.ENDC
	.IFDEF DT.PI
	ION
	.ENDC
	JMP* DFSTOP
/BACKGROUND STOP SUBR
/ONLY IF BUSY AND RUNNING
DBSTOP	0
	.IFDEF DT.API
	LAC (400200
	ISA
	.ENDC
	.IFDEF DT.PI
	IOF
	.ENDC
	LAC	DTA.+2	/B BUSY?
	SNA!STL
	JMP	DBSTP1	/NO
	LAC	DLIVE+1	/B RUNNING?
	SNA!CLA!STL
	JMP DBSTP1	/NO, DO NOT STOP DECTAPE
	JMS DTSTOP	/STOP B I/O IF UNDERWAY
	STL!CLC
	DAC DTRASV	/CLEAR SAVED STATUS A (-1)
DBSTP1	JMS DZSTOP	/CLEAR B BUFFERS (LINK MUST=1)
	DZM DBCTLR	/BGRD ^R FLAG.
	.IFDEF DT.API
	DBK
	.ENDC
	.IFDEF DT.PI
	ION
	.ENDC
	JMP* DBSTOP
	.EJECT
/DBEX: SUBR. TO SEE IF ACTIVE BUFF. IS ONE WANTED
/IF NOT, DBEX SWAPS IN RIGHT ONE USING SUBR. DRESBF
/AND SWAPS OUT WRONG ONE
/CALLING SEQUENCE:
/	JMS	DBEX
/	XX			/BUFFER OK RETURN
/	XX			/NOT FOUND RETURN
/DBEX USES DTEMP, DTEMP1, DTEMP2, DTEMP3, DTEMP4
/WHERE DTEMP3 POINTS TO FOUND ENTRY
/DTEMP4 POINTS TO AVAILABLE ENTRY SLOT IF NO ENTRY FOUND
DBEX	0
	LAC	DLIVE+2		/IS .DAT SLOT SAME AS ACTIVE ONE?
	SAD	DSLOT
	SKP!CLL			/YES, CHECK B/F
	JMP	DBCHEK		/NO, CHECK BUFFER ASSIGNMENT
	LAC	DLIVE+1		/0=F; 1=B
	SAD	DUSER
	JMP*	DBEX		/SAME USER, SAME .DAT SLOT, NO SWAP
DBCHEK	LAC	DLIVE+1		/L ALREADY=0
	RTR			/S=1 IF B
	TAD	(DBUFSZ+500
	DAC	DGBUF+1		/SET UP BUFF SIZE FOR CALL TO GETBUF
	LAC	DBPT
	DAC	DTEMP		/SET UP BUFF TABLE COUNT
	LAC	LDBPT1
	DAC	DTEMP1
	LAC	(JMP DBC4		/JMP DBC4- UNTIL EMPTY SLOT IS FOUND
	DAC	DBC2
	DZM	DTEMP4		/CLEAR EMPTY SLOT POINTER
DBC1	LAC*	DTEMP1
	SNA
DBC2	XX			/JMP DBC4 OR JMP DBC3
	DAC	DTEMP2		/BUFF. ADDR. POINTER
	DAC	DTEMP3
	LAC*	DTEMP2		/SAME .DAT SLOT?
	SAD	DLIVE+2
	SKP			/YES, CHECK B/F
LJDBC3	JMP	DBC3		/NO
	IDX	DTEMP2		/INDEX TO BF CELL
	LAC*	DTEMP2		/SAME USER?
	SAD	DLIVE+1
	JMP	DBSWAP		/ALREADY HAVE BUFFER, SWAP IN
DBC3	IDX	DTEMP1
	ISZ	DTEMP
	JMP	DBC1
	LAC	DTEMP4		/FREE ENTRY POINTER
	IDX	DBEX
	SZA			/FILE CAPACITY OVERFLOW
	JMP*	DBEX		/NOT FOUND
	JMP	DTER17		/.ERR 17
	.EJECT
/FREE ENTRY SLOT FOUND
DBC4	LAC	DTEMP1		/SAVE FREE ENTRY POINTER
	DAC	DTEMP4
	LAC	LJDBC3		/JMP DBC3
	DAC	DBC2
	JMP	DBC3
DBSWAP	LAC	DTEMP3		/POINTER TO INCOMING BUFFER
	JMS	DRESBF
	JMP*	DBEX
/DRESBF=SUBR. TO SWAP IN APPROP. BUFF. AREA
/AND SWAP OUT ACTIVE AREA IF MEANINGFUL
/CALLING SEQUENC:
/	AC=NEW BUFF. AREA POINTER
/	JMS	DRESBF
/LINK USED IN SUBR. TO DETERMINE SWAP OUT
/DRESBF USES DTEMP4, DTEMP1, DTEMP2, DTEMP3
DRESBF	0
	DAC	DTEMP4		/TEMP. STORE NEW BUFF. POINTER
	LAC	DBUFAD		/ACTIVE AREA MEANINGFUL?
	SZA!CLL
	STL			/L=1=MEANINGFUL, SO SWAP
	DAC	DTEMP1
	LAC	DBPNT		/(DBUFF
	DAC	DTEMP2
	LAW	-DBUFSZ
	DAC	DTEMP3
DRES1	LAC*	DTEMP2		/ACTIVE AREA
	SZL			/DO NOT SWAP OUT
	DAC*	DTEMP1		/DO SWAP OUT
	LAC*	DTEMP4		/SWAP NEW AREA IN
	DAC*	DTEMP2		/ACTIVE AREA
	IDX	DTEMP4
	IDX	DTEMP1
	IDX	DTEMP2
	ISZ	DTEMP3
	JMP	DRES1
	JMP*	DRESBF
	.EJECT
/DDZM=SUBR. TO ZERO OUT BLOCK OF CELLS
/CALLING SEQUENCE
/	AC=-BLOCK COUNT
/	JMS	DDZM
/	XX			/BLOCK POINTER
/SUBR. USES DTEMP2, DTEMP1
DDZM	0
	DAC	DTEMP2		/COUNT
	LAC*	DDZM		/GET BLOCK POINTER
	IDX	DDZM		/INDEX TO EXIT
	DAC	DTEMP1
	DZM*	DTEMP1
	IDX	DTEMP1
	ISZ	DTEMP2
	JMP	.-3
	JMP*	DDZM
/.INIT DECTAPE ROUTINE
DTIN	LAC	(377		/255(10)--RETURN STANDARD LINE BUFFER SIZE
	DAC*	DLIVE+6		/TO USER (CELL 16)
/
/ONCE ONLY CODE TO .SETUP API CH. ADDR. AND SKIP CHAIN
/AFTER 1ST .INIT THESE CELLS ARE USED FOR TEMP STORAGE
DTONCE	LAC*	(.SCOM+55		/.SETUP POINTER
DTERCT	DAC	DTEMP
DTMPOT	JMS*	DTEMP		/.SETUP API CH. REG. 44
		DTDF		/DECTAPE DONE FLAG
		DTINT		/INTERR. SERV. ADDR.
DTSVAC	JMS*	DTEMP
		DTEF		/DECTAPE ERROR FLAG
DTIOAC		DTINT
	LAC	DBPT		/-DN
DTBCA	JMS	DDZM		/INIT BUFFER TABLE TOO
LDBPT1	.DSA	DBPT+1
DTCT	LAC*	(.SCOM+56		/GETBUF POINTER
DTCT1	DAC	DSCM56
DTCT2	LAC	(JMP .+2
	DAC	DTONCE
/
/ONCE ONLY CODE ENDS HERE
	JMS	DBEXAB		/GET A BUFFER FOR THIS FILE
	LAC	DLIVE+4
	DAC	DTIOSW		/INPUT=0;OUTPUT=1
	JMP	DTEMPT		/DONE, EXIT
DBUFFX	LAC	D.BFTP		/.BFTAB ENTRY ADDR.
	DAC	DTEMP
	IDX	DTEMP
	JMP	DBUFCR		/INIT NEW BUFF
	.EJECT
/CALL MONITOR GETBUF SUBR.
/CALLING SEQ.:
/	JMS DBRBUF
/	XX			/RETURN WITH BUFF. INITIALIZED
/AUTO INIT SUBR.
DBEXAB=.
DBRBUF	0
	JMS	DBEX		/SUBR. TO SWAP IN BUFF. IF NECESSARY
	JMP	DBUFFX		/EXIT FORBUFFER IN, SET UP TO INIT IT
/NO BUFF ASSIGNED, GET ONE
/DTEMP4 POINTS TO EMPTY DBPT SLOT
	.IFDEF DT.API
	LAC	(400200		/RAISE TO API LEVEL 0
	ISA
	.ENDC
	IOF			/PIC OFF
DGBUF	JMS*	DSCM56		/.GETBUF
	XX			/REQUIRED BUFF SIZE; S=1=B,S=0=F;SET IN DBEX
	SNA			/BUFFER AVAILABLE FROM MONITOR
	JMP	DTEMPZ		/NO BUFF, EXIT (MSG ALREADY OUT)
	DAC	DTEMP		/AC=ADDR OF BFTAB ENTRY ON RETURN
	IDX	DTEMP		/POINTER TO BUFFER ADDR.
	LAC*	DTEMP
	DAC*	DTEMP4		/STORE IN DBPT
	.IFDEF DT.API
	DBK			/DEBREAK FROM LEVEL 0
	.ENDC
DTION	ION			/PIC ON
/SWAP IN APPROP. BUFF. TO ACTIVE BUFF. AREA+INITIALIZE
	JMS	DRESBF
	.EJECT
/ROUTINE TO CLEAR AND INITIALIZE BUFFER POINTERS
DBUFCR	LAW	-DBUFSZ
	JMS	DDZM		/CLEAR NEW BUFFER AREA VARIABLES
DBPNT	.DSA	DBUFF
/INIT. BUFFER VARIABLES
	LAC	DLIVE+2		/.DAT SLOT
	DAC	DSLOT
	LAC	DLIVE+1		/USER
	DAC	DUSER
	LAC*	DTEMP		/BUFFER ADDR.(EXTERNAL)
	DAC	DBUFAD
	TAD	(DBUFSZ		/POINTER TABLE SIZE
	DAC	DLMBIT		/FILE BIT MAP POINTER
	DAC	DLMCL		/DDZM POINTER
	TAD	(40
	DAC	DLTDIR		/DIRECTORY BIT MAP POINTER(DTDIR)
	TAD	(40
	DAC	DLTBUF		/DATA BUFFER POINTER(DTBUF)
	TAD	(3
	DAC	DLB003		/DTBUF+3
	TAD	(35		/DTBUF+40
	DAC	DTLB40
	TAD	(337		/DTBUF+377
	DAC	DTLINK
	LAC	DLTDIR
	TAD	(203
	DAC	DLTSYS		/DTDIR+203
	TAD	(40
	DAC	DLB203		/DTBUF+203
	LAC	(377
	DAC	DTROOM		/INIT DUMP PARAMETER
	LAW	-40
	JMS	DDZM		/DZM FILE BIT MAP
DLMCL	XX
	CLC
	DAC	DTDRGT		/CLEAR DIR. SEARCH SW.
	DAC	DTRASV		/INIT SAVED STATUS A(CLEAR=-1)
	TAD	DTEMP		/.BFTAB ENTRY ADDRESS
	DAC	D.BFTP
	DAC	DTNCOR		/CLEAR DIR IN CORE SWITCH
	LAC	DBUFAD		/BE SURE REAL BUFFER (POINTERS)
	JMS	DRESBF		/MATCH INTERNAL DTA. BUFFER
	JMP*	DBEXAB
	.EJECT
/FOR SHARED DEVICES, WHEN I/O REQUEST COMPLETED,
/CONTROL COMES HERE TO DETERMINE WHETHER SWAP OF
/BACKUP AND LIVE CELLS IS REQUIRED;
/BGD I/O WILL BE STARTEDIF WAITING TO START (BOTH DBIGNR AND DBDONE=0)
/IF BGRD I/O GOING BUT NO INT. YET (DTIGNR=-1), DTNOR (COMMON CAL AND INTERR. EXIT)
/IF BGRD I/0 GOING AND DONE (DBDONE=NON-0), GO TO DTRDWT
/		TO FINISH BGRD INT. SERV.
DTNORS	LAC	DTA.+2		/B BUSY FLAG ON?
	SNA			/YES
	JMP	DTNOR		/NO
	LAC	DTBCLR		/IS IT SET UP TO CLEARED(DTBCLR=NOP)?
	SAD	DTLNOP		/NO
	JMP	DTNOR		/YES
/BGRD I/O HAS BEEN DEFERRED UNTIL COMPLETION OF FGRD I/O
/BACKUP (BGRD) DATA CELLS MUST BE SWAPPED INTO LIVE DATA CELLS
	JMS	DSWON		/JUST SWAP LIVE AND BACKUP CELLS
DTNORT	JMS	DBEXAC		/SWAP BUFFERS
/BGRD I/O WILL NOT BE STOPPED UNLESS FGRD MUST ACCESS TAPE
	.IFDEF DT.API
	LAC	(400200		/RAISE TO API LEVEL0
	ISA			/PROTECTED HERE ONLY BECAUSE DTSWAP UNPROTECTS
	.ENDC
	.IFDEF DT.PI
	IOF			/PIC OFF
	.ENDC
	LAC	DTIGNR		/BGRD I/O SW. GOING SET?
	DZM	DTIGNR
	SZA			/NO, EITHER DONE OR NOT STARTED
	JMP	DTNOR		/YES, GOING AND STILL TRANSFERRING
	.IFDEF DT.API
	DBK			/DEBREAK FROM LEVEL 0
	.ENDC
	.IFDEF DT.PI
	ION
	.ENDC
	LAC	DBDONE		/BGRD DONE SW. SET?
	SZA			/NO, START IT UP
	JMP	DTRDWT		/YES, FINISH INTERR. SERVICE FOR BGRD.
	LAC	DBCTLR		/WAIT FOR BGRD ^R.
	SNA
	XCT	DLIVE		/START BGRD I/O (JMP FUNCTB)
DTNOR	LAC*	(.SCOM+54		/ADDR OF CALL4
	DAC	DTTMP1
	.IFDEF DT.API
	LAC	(400200		/RAISE TO API LEVEL 0.
	ISA
	.ENDC
DTIOF	IOF
	LAC	DTWRD6
	SAD	DBRLIT
	SKP			/INTERR.
	JMP	DTT.6		/CAL
	JMS*	DTTMP1
	.DSA	DTA.+7		/DTTOUT
	.DSA	DSCM35		/TEMP FOR .SCOM+35
	.EJECT
DTT.6	LAC	DSCM35		/RESTORE IN INTERRUPT
	DAC*	(.SCOM+35		/HANDLER FLAG.
DTFCLR	SKP			/NOP IF FLAG TO BE CLEARED
	DZM	DTA.+1		/FOREGROUND BUSY FLAG.
DTBCLR	SKP			/NOP IF FLAG TO BE CLEARED
	DZM	DTA.+2		/BACKGROUND BUSY FLAG.
	LAC	DLSKP		/RESET
	DAC	DTFCLR		/SWITCHES.
	DAC	DTBCLR
	LAC	DTIOAC		/AC FOR IOT
DTIOT	XX			/IOF OR IOT(DTLA OR DTXA)
	LAC	DTSVAC		/RESTORE AC.
	.IFDEF DT.API
	DBK			/FROM LEVEL 0.
	.ENDC
	XCT	DTA.+5		/ION OR IOF
	XCT	DTA.+6		/ION OR IOF OR DBR
	XCT .+1
	XCT .+1
	JMP*	DTA.+7		/RETURN POINTER.
DTTMP1	0			/TEMP
	.EJECT
/.OPER ROUTINE TO INTERPRET:
/.DLETE (SUBFUNCTION 1)
/.RENAME (SUBFUNCTION 2)
/.FSTAT (SUBFUNCTION 3)
DTOPER	JMS	DBEXAB		/SWAP BUFF CHECK - AUTO .INIT IF NOT DONE
	JMS	DTCKCL		/CHECK DIRECTORY FOR THIS FILE
	DAC	DTNXBK		/SAVE FOR AC=0ON NOT FOUND
	SNA
	JMP	DTFST		/NOT FOUND-RETURN WITH AC=0
	XCT	DTSK5		/PICK UP 1ST BLK OF FILE
	XOR	(400000
	DAC	DTNXBK		/CLEAR FILE COMPLETE BIT
	LAC	DLIVE+4		/SET UP SUBFUNTION DISPATCH(1-3)
	TAD	(JMP DTOPTB
	DAC	DTOPTB
	LAC	DLTDIR		/SETUP FOR TRAN OF
	DAC	DTBMPT		/DIR BIT MAP TO DIR ENTRY SECTION
	DAC	DTNCOR		/CLEAR DIR.IN CORE SW.
DTOPTB	XX
	JMP	DTLET		/1=.DLETE
	JMP	DTREN		/2=.RENAM
DTFST	LAC*	DTWD17		/3=.FSTAT
	XOR	(100000		/RETURN TYPE (1 IN 0-2)
	DAC*	DTWD17		/TO USER
	DZM	DTCLSS		/CLEAR FILE ACTIVE SW.
	LAC	DLIVE+1		/USER: F=0; B=1
	TAD	(DAC DTA.+3
	DAC	DTFSTX		/SETUP AC RETURN FOR .OPER IN .CLOSE SW
	LAC	(1		/ULTIMATELY:0 IF NOT FOUND OR 1ST BLK#
	TAD	DTNXBK 
DTFSTX	XX			/DAC DTA.+3 OR DTA.+4
	JMP	DTFEND		/I/O REQ. DONE - RELEASE BUFFER
/.RENAM ROUTINE
DTREN	DAC	DRENSW		/SET RENAME SW. FOR PROPER CLOSE
				/DTUDRP ALREADY SET UP IN DTSK1
	XCT	DTSK5		/GET 4TH WD OF OLD ENTRY
	XCT	DTNTR3		/SAVE IN DTESAV+6
	JMP	DTCLS6		/WRITE OUT NEW DIRECTORY
/.DELETE ROUTINE
DTLET	LAW	-4		/SETUP FOR DELETE
	JMS	DDZM		/DZM DT1SAV
DLSAV	.DSA	DT1SAV
	JMP	DTCLS3		/FILE BIT MAP+DIRECTORY
	.EJECT
/CHECK DIRECT. IN CORE SUBR.
/IF DIRECTORY IS NOT IN,INTERR.SERV. WILL RETURN
/TO DRET1 AFTER IT IS IN
DTDRCK	0
DRET1	LAC	DLIVE+3		/D IN ? (DTNCOR MUST MATCH UNIT # IN DLIVE+3, 0-2)
	AND	(700000
	SAD	DTNCOR		/NO
	JMP	DTDRC1		/YES - CHECK PARITY
	LAC	(JMP DRET1	/SET UP
	DAC	DTWRWT		/INTERRUPT RETURN
	JMS	DCALST		/SET UP CAL RETURN
	LAC	(13000		/READ PARAM
	JMS	DTDRIN		/BRING IN DIRECTORY
	JMP	DTNOR		/I/O REQ STARTED
DTDRC1	LAC	DTERCT		/DIRECTORY UNACCEPTABLE
	SZA			/WITH PARITY ERROR.
	JMP*	DTDRCK		/OK
DSET61	LAC	DLIVE+3		/PRINT UNIT # +
	AND	(700000		/OFFENDING BLK # (71 - 100)
	XOR	DTNXBK
	DAC	DERPNT
	LAW	61		/DIRECTORY OR FILE BIT MAP
	JMP	DTEROR-1	/TERMINAL ERROR.
/CALL IN DIRECTORY SUBR.
DTDRIN	0
	DAC	DTTR		/TRANSFER DIRECTION SWITCH
	LAC	DLT100
	DAC	DTNXBK		/BL# TO TRANSFER
	DZM	DTDTR		/TRANSFER FORWARD
	DZM	DTDRGT		/SET IND. TO SET DIR IN CORE SWITCH
	LAC	DTCLSS		/0 IF SEEK, ENTER
	SZA
	LAC	(40		/NOT 0 IF CLOSE (DTBUF
	TAD	DLTDIR		/(DTRDIR
DTDRN1	JMS	DTWCS		/SETUP WC,CA
	JMP*	DTDRIN
/DIRECTORY SEARCH SUBR.
DTSK1	0
	DAC	DTUDRR		/USER DIR. ENTRY POINTER
	DZM	DTDTR		/SET TRANSF. DIRECTION=FORWARD
DTSK2	CLC			/SYSTEM TAPE?
	XOR*	DLTSYS		/WD3 OF SYS BIT MAP
	SNA!CLA			/NO,56 FILES
	LAW	-30		/YES, 24 FILES
	SMA
	LAW	-70
	DAC	DTFPCT		/DIR. POINTER=DTDIR+40=DTBUF
	XOR	L7777		/(777700
	DAC	DBLKLC		/50 IF 24;10 IF 56
	LAC	DLTBUF		/DIR. POINTER=DTDIR+40=DTBUF
DTSK3	DAC	DTDES		/ENTRY SECTION POINTER
	DAC	DTCURE		/CURR. ENTRY, WD0, POINTER
/NEXT FILE NAME ENTRY
	LAC	DTUDRR		/USER DIR. ENTRY POINTER
	DAC	DTUDRP
	LAW	-4
	DAC	DTCT1S		/MATCH COUNT
	DAC	DTCTS		/COUNT OF ENTRY WDS TO CHECK
	ISZ	DTCTS
	.EJECT
/NEXT WORD OF CURRENT ENTRY
DTSK5	LAC*	DTDES		/DTA DIR. ENTRY (.E.)
	SAD*	DTUDRP		/USER D.E.
	ISZ	DTCT1S		/WD N OF ENTRY SATCHES
	ISZ	DTDES		/NEXT WD OF DTA ENTRY
	ISZ	DTUDRP		/NEXT WD OF USER ENTRY
	ISZ	DTCTS		/ENTRY WD COUNT
	JMP	DTSK5		/CONT. MATCH CHECK
DTSK6	LAC	DTCURE
	ISZ	DTCT1S		/MATCH
	SKP			/N
	JMP*	DTSK1		/YES-CURRENT ENTRY POINTER IN AC
	TAD	(4		/INDEX TO NEXT ENTRY
	ISZ	DTFPCT		/INDEX FILE ENTRY CT.
	JMP	DTSK3		/NEXT ENTRY
	CLA
	JMP*	DTSK1		/YES-CAN'T FIND FILE NAME
/CLOSE FILE SUBR
DTCLOS	JMS	DBEX		/HAVE BUFFER?
	SKP			/YES. SWAPPED IN.
	JMS	DBEXAB		/XCT .GETBUF IN CASE OF .TRAN CLOSE
				/(NORMALLY, BUFFER IS PRESENT).
	LAC	DTIOSW		/I OR O
	SNA!CLC
DLFEND	JMP	DTFEND		/INPUT-CLEAR SWITCHES EXIT
	LAC	DTWREX		/WRITE EXECUTED AFTER .ENTER
	SZA!CLC			/CLC TO SET DTEOF
	JMP	DTCLS2		/YES
	JMS	DTCBIT		/NO-CLEAR BIT MAP
	JMP	DTFEND
DTCLS2	DAC	DTEOF		/SET EOF SWITCH(-1)
	DAC	DLIVE+6		/WC=-1
	LAC	(JMP DTCLS3
	DAC	DTWRWT		/SET UP INTERR. RETURN
	DZM	DLIVE+4		/FAKE DATA MODE = IOPS BIN
	LAC	DTFILE		/IF .MTAPE .CLOSE,
	SZA
	JMS	DTBUFC		/CLEAR BUFFER.
	LAC	(15000		/OUTPUT
	JMS	DTMCK
	LAC	DLEOFH		/EOF HEADER POINTER (DTEOFH
/FAKE ARG FOLLOWS
	LAW	-1		/GET DIR IND. (0=GET)
	JMP	DTWRT1
DTCLS3	LAC	DTFILE		/IF .MTAPE,
	SZA
	JMP	DTFND1		/RELEASE BUFFER.
	LAC	(JMP DTCLS4	/SET INTERR. RETURN
	DAC	DTWRWT
	LAW	-50
	TAD	DBLKLC
	SNA!CLA			/NON 0 IF 56 ENTRIES
	LAW	-4
	TAD	DLIT77
	.EJECT
DTCLT	DAC	DTNXBK		/BIT MAP BLOCK #
	LAC	DTFPCT		/FILE COUNT
	TAD	(10
	DAC	DTFPCT
	SMA!CLC
	JMP	DTCLQ		/FILE BIT MAP IS IN THIS BLOCK
	TAD	DTNXBK		/DECR. BIT MAP BL# BY 1
	JMP	DTCLT		/TRY NEXT BLOCK BACK
DTCLQ	DZM	DTDTR		/SET TRANSF. DIRECT. SW. = FORW.
	JMP	DTSEK1		/READ BIT MAP BLOCK INTO DIR. BIT MAP
DTCLS4	LAC	(JMP DTCLS6	/SET INTER. RETURN
	DAC	DTWRWT
	LAC	DTERCT		/RETRY COUNT
	SNA			/OK IF SKIP
	JMP	DSET61		/PAR ERR IN FILE BIT MAP
	LAC	DTFPCT		/REL. BIT MAP POINTER
	CLL!RAL			/X 40
	RTL
	RTL
	TAD	DLTBUF		/(DTBUF
	DAC	DTOLBM
	DAC	DTXROL		/OLD BIT MAP ADDR.
	LAC	DLTDIR		/DIR. BIT MAP ADDR.
	JMS	DTXOR		/XOR OLD FILE BIT MAP INTO DIR. BIT MAP
	LAC	DLMBIT		/NEW FILE BIT MAP ADDR
	DAC	DTXROL
	LAC	DTOLBM		/OLD BIT MAP ADDR
	JMS	DTXOR		/XOR NEW INTO OLD BIT MAP
	LAC	(15000
	JMP	DTSEK2		/OUTPUT BIT MAP BLOCK
/SUBROUTINE TO XOR BIT MAP 1 INTO BIT MAP 2
/ALSO CLEARS BIT MAP 1 IF LINK = 0 ON ENTRY
DTXOR	0
	DAC	DTXRNW		/BIT MAP 2 ADDR
	LAW	-40
	DAC	DTCTS
DTXOR1	LAC*	DTXROL		/BIT MAP 1 POINTER
	XOR*	DTXRNW		/BIT MAP 2 POINTER
	DAC*	DTXRNW
	SNL!CLC			/DO NOT CLEAR BIT MAP 1, CLC FOR SETTING DTNCOR
	DZM*	DTXROL		/CLEAR BIT MAP 1
	ISZ	DTXROL
	ISZ	DTXRNW
	ISZ	DTCTS
	JMP	DTXOR1
	JMP*	DTXOR
	.EJECT
DTCLS6	JMS	DTDRCK		/LOAD DIRECTORY INTO DTBUF
	LAC	DTBMPT		/DT. BIT MAP POINTER
	DAC	DTCLRP		/NIT. DIR ENTRY SECT. POINTER
	LAW	-40		/DIR. ENTRY SECTION COUNT
	DAC	DTCT
	LAC	DLTBUF		/(DTBUF)
	DAC	DTCT1
DTCLS5	LAC*	DTCLRP		/TRANSFER DIR. BIT MAP
	DAC*	DTCT1		/TO FRONT OF DIR. ENTRY SECTION
	ISZ	DTCLRP
	ISZ	DTCT1
	ISZ	DTCT
	JMP	DTCLS5
	LAC	DRENSW		/RENAME SWITCH SET?
	SZA
	LAC	(3		/YES, PICK UP NEW NAME
	TAD	DLSAV		/(DT1SAV
	DAC	DTFIN
	LAC	DTCURE		/ADD 40 TO ACCOUNT FOR BLOCK MOVE
	TAD	(40
	DAC	DTCURE
	LAW	-4
	DAC	DTCT
DTCLS7	LAC*	DTFIN		/NEW FILE NAME (4 WDS)
	DAC*	DTCURE		/INTO DIRECTORY ENTRY SECTION
	ISZ	DTFIN
	ISZ	DTCURE
	ISZ	DTCT
	JMP	DTCLS7
	LAC	DLFEND		/SET INTERR. RETURN (JMP DTFEND
	DAC	DTWRWT
DTCL7A	LAC	(15000		/REWRITE DIRECTORY
	JMS	DTDRIN
	LAC	(JMP DTCL7A
	JMS	DCALST		/SET UP CAL RETURN
	JMP	DTNOR		/CONTINUE I/O EXIT
	.EJECT
DTFEND	LAC DTFILE	/IF .MTAPE,
	SNA!CLC		/NO DIRECTORY.
	DAC DTNCOR	/CLEAR DIR IN CORE SWITCH
/RELEASE BUFFER
DTFND1	LAC DTFILE	/IF .MTAPE, DON'T RELEASE
	SZA
	JMP DTEMPT	/BUFFER AFTER A .CLOSE.
	LAC DBPT		/MAX FILE COUNT
	DAC DTEMP
	LAC LDBPT1	/BUFFER TABLE POINTER
	DAC DTEMP1
	LAC DBUFAD	/CLEAR BUFFER ADDR FROM DBPT
DTFSAD	SAD* DTEMP1
	DZM* DTEMP1	/MATCH - CLEAR
	IDX DTEMP1
	ISZ DTEMP
	JMP DTFSAD
	DZM DSLOT		/CLEAR .DAT SLOT POINTER
	DZM DBUFAD	/CLEAR BUFFER ADDR
	LAC* D.BFTP
	AND (577777
	DAC* D.BFTP	/CLEAR BIT 1 IN BUFTAB ENTRY
	JMP DTEMPT	/I/O REQ. DONE
/.TRAN ROUTINE
DTRAN	JMS DBEXAB	/BUFFERSWAP CHECK - AUTO .INIT
	LAC DLIVE+7	/BLK #
	JMS DTSET		/SETUP BL#, ETC
	LAC DLIVE+5	/CORE ADDR.
	JMS DTWCS		/SETUP CA AND START SEARCH.
	LAC DLIVE+6	/WC
	DAC DTWC
	LAC (JMP DTRAN+1	/SET UP CAL LEVEL RETURN
	JMS DCALST
	LAC DLFEND	/(JMP DTFEND
	DAC DTWRWT	/SET UP INTERR. RETURN TO RELEASE BUFFER
	JMP DTNOR		/COMMON EXIT - I/O STARTED
	.EJECT
/SUBROUTINE TO SET UP BLOCK #, TRANSFER DIRECTION
DTSET	0
	DAC DTNXBK
	LAC DTRWAY	/TRANSFER DIRECTION(DLIVE+4)
	RTR
	SMA!CLC		/OUTPUT
	LAC (11000	/INPUT
	XOR (2000
	AND (17000
	DAC DTTR		/WRITE (15000) OR READ (13000)
	SZL!CLA		/FORWARD
DLM1	LAW -1
	DAC DTDTR		/TRANSFER DIRECTION SWITCH
	JMP* DTSET
/SUBR TO SET .REALR OR .REALW SWITCH
DRLXEK	0
	LAC DTWD17	/REAL TIME READ OR WRITE?
	SNA		/YES, SET SW.
	JMP* DRLXEK
	LAC DLIVE+1	/0=F;1=B
	TAD (DRELR	/2 CELL SAVE AREA
	DAC DRELT		/TRMP
	DAC* DRELT
	JMP* DRLXEK
/SUBR. TO SET UP CAL LEVEL RETURN TO HANDLER
/FOR BGRD ONLY
/CALLING SEQUENCE
/	AC=JMP XX		/XX=RETURN POINT
/	JMS DCALST
DCALST	0
	DAC DCALTP	/TEMP
	LAC DLIVE+1	/0=F;1=B
	SNA
	JMP* DCALST	/F
	LAC DCALTP
	DAC DBCALR+1
	LAC (JMP DBCALR
	DAC DLIVE
	JMP* DCALST
DBCALR	JMS DBEXAC	/CHECK FOR BUFF. PRESENT
	XX		/JMP HANDLER CAL LEVEL RETURN
DCALTP	0		/TEMP
	.EJECT
/.MTAPE ROUTINE
 
DTMTAP	LAC	DLIVE+4		/.MTAPE FUNCTION CODE.
	SNA
	JMP	DTMREW		/REWIND (MOVE TAPE-BOT)
	SAD	(2
	JMP	DTBKSP		/BACKSPACE
	JMS	DBEX		/HAVE BUFFER?
/IGNORE OTHER .MTAPE FUNCTIONS.
	JMP	DTEMPT		/YES. EXIT.
	JMP	DTCLOS		/NO. GET ONE - THEN RELEASE IT.
 
/.MTAPE BACKSPACE
 
DTBKSP	JMS	DBEXAC		/NO AUTO INIT
	LAC	WSW		/WSW=- IF LAST COMMAND WAS .WRITE
	DZM	WSW
	CLL!RAL			/DON'T CHANGE DTNXBK
	LAC	DTNXBK		/DECREASE BLK # BY 5
	SZL
	JMP	DTMRW1		/DON'T CHANGE DTNXBK
	TAD	DTDECR		/-5 IF FORW.; +5 IF REV.
	SAD	(2		/IF BLK 1,2,1075, TURN AROUND
	SKP
	SAD	(1
	SKP
	SAD	(1075
	SKP
	SPA			/IF <0, ASSUME TURN AROUND
	JMP	DTMTP2
	DAC	DTCT		/TEMP STORE
	TAD	(-1100
	SMA
	JMP	DTMTP2		/IF -, ASSUME TURN AROUND
	LAC	DTCT		/OK
	DAC	DTNXBK
	JMP	DTMRW1
DTMTP2	LAC	DTMPAS		/LAST BLK # OF LAST PASS
	TAD	(LAC DTMBAK
	DAC	.+1
	XX
	DAC	DTNXBK		/RESET CURRENT BLK #
	SNA
	JMP	DTMRW1
DFLPLT	JMS	DTMFLP
	LAC	DTDTR		/FLIP TRANSFER DIRECTION SWITCH
	CMA
	DAC	DTDTR
	LAW	-2
	TAD	DTMPAS
	DAC	DTMPAS
	JMP	DTMRW1
DTMFLP	0
	DAC	DTWCS		/SAVE ENTRY AC
	IDX	DTMPAS		/INDEX .MTAPE PASS COUNT
	JMS	DDIRAL		/FLIP DTDIRA
	CLC
	TAD	DTDECR		/-5 TO +5 OR VICE VERSA.
	CMA
	DAC	DTDECR
	LAC	DTWCS		/RESTORE AC ON EXIT.
	JMP*	DTMFLP
 
DTMBAK	0			/BACKSPACE TURN TABLE.
	1077
	4
	1073
	3
DTMBAC	1076			/.MTAPE WRITE TURN TABLE.
	6
	1070
	7
	777777			/EOF AFTER 1075 BLOCKS.
 
/.MTAPE REWIND
 
DTMREW	JMS	DBEXAB		/AUTO INIT
	DZM	DTNXBK		/SET BLK # TO READ/WRITE = 0
	DZM	DTCNBK
	DZM	DTMPAS		/INIT PASS COUNT
	DZM	WSW		/CLEAR LAST WRITE SWITCH
	DZM	DTDTR		/SET TRANSFER DIRECTION = FWD
	LAC	(1		/INIT TRANSFER DIRECTION SW'S=FORWARD
	DAC	DTDIRL
	DAC	DTDIRA		/FOR NEXT FREE BLOCK SEARCH.
	DAC	DTSKNT		/SET SEEK/ENTER/REWIND EXECUTED SW.
	LAW	-5
	DAC	DTDECR
	DAC	DTFILE		/NON FILE ORIENTED DTA
DTMRW1	LAC	(13000
	JMP	DTSEK3		/READ FIRST DATA BLOCK (0)
 
	.EJECT
/SUBR. TO SET UP CA, WC AND TRANSFER
/ALL DECTAPE I/O MACROS USE THIS ROUTINE TO ACTUALLY INITIATE I/O
/ONLY AT THIS POINT IS THE DECISION MADE TO STOP BGRD I/O;I.E.,
/ONLY IF FGRD IS REALLY GOING TO ISSUE AN IOT
/AC=CORE ADDR. OF TRANSFER ON ENTRY
DTWCS	0
	DAC DCALTP	/TEMP.
	.IFDEF DT.API
	LAC (400200	/RAISE TO LEVEL 0
	ISA
	.ENDC
	.IFDEF DT.PI
	IOF
	.ENDC
	JMS DTSTOP	/STOP I/O ROUTINE
	.IFDEF DT.API
	DBK
	.ENDC
	.IFDEF DT.PI
	ION
	.ENDC
	LAC DCALTP	/CORE ADDR.
	TAD DLM1
	DAC DTCCA		/ADDR.-1
DTUMSK	LAW -400
	DAC DTWC		/WORD COUNT (2'S COMP)
	LAW -10
	DAC DTERCT	/PARITY ERROR RETRY COUNT
	LAC DUSER
	SNA!CLC		/BGRD
	JMP DTSUP		/FGRD, ALWAYS START FROM SCRATCH
	SAD DTRASV	/IF CLEAR (-1), START FROM SCRATCH
	SKP
	JMP DTWCGO	/CONTINUE SEARCH AS BEFORE
	.EJECT
DTSUP	LAC	DTDTR		/TRANS. DIRECT. SWITCH
	AND	(1000		/AND
	XOR	DLITSM		/SMA!CLA=SEARCH FORW.
	DAC	DCHKCX		/SPA!CLA=SEARCH REV.
	LAC	DTNXBK
	DAC	DTBLC
	LAC	DTDTR
	SMA!CLA			/-2 ON TRANSFER FORW.
	LAW	-4		/+2 ON TRANSFER REV.
	TAD	(2		/(2
	DAC	DTBLNC		/SEARCH BLOCK INCREMENT
	LAC	DLIVE+3		/TEMP STORE UNIT #
	AND	(700000
	DAC	DTIOAC
	LAC	DTDTR		/TRANS. DIRECTION SW.
	AND	(40000
	XOR	(21400		/UNIT+21400=SEARCH FORW.
	XOR	DTIOAC		/UNIT+61400=SEARCH REV.
DTWCGO	DAC	DTIOAC		/SET UP AC FOR IOT EXECUTION
	LAC	(DTLA		/SET UP IOT FOR EXECUTION
	DAC	DTIOT		/DURING DTNOR COMMON EXIT
	JMS	DTSRCH		/SET UP FOR SEARCH
	DZM	DNOIO		/CLEAR IGNORE PHONY INTERR. SW.
	JMP*	DTWCS		/EXIT SUBR
	.EJECT
/.READ, .WRITE COMMON SETUP SUBR.
DTMCK	0
	DAC	DTTR		/READ (13000) OR WRITE (15000)
	LAC	DTSKNT		/.SEEK, .ENTER SWITCH
	SNA!CLC
	JMP	DTER12		/.SEEK, .ENTER NOT EXECUTED (DTER11)
	XCT*	DTMCK		/L.B. OR DTA BUF. L.B. ADDR.
	DAC	DTUHP		/HEADER POINTER
	DAC	DTUDP		/DATA POINTER
	LAC	DLIVE+6		/USER WC(OR WPC IF WRITE)
	DAC	DTUWC
	LAC	DLIVE+4		/DATA MODE
	DAC	DTDMOD
	IDX	DTMCK		/INDEX TO DUMP EXIT
	SAD	(4
	JMP	DTMCK2		/DUMP MODE
	LAC*	DTUHP		/COMPUTE W.C. FROM L.B.H. W.P.C
	JMS	DTGWPC
	ISZ	DTMCK		/IOPS, IMAGE EXIT
	JMP*	DTMCK		/EXIT,
/DUMP MODE
DTMCK2	LAC	DTUWC		/SAVE USER WC
	DAC	DTWCSV
	DZM	DTWPC
	XCT*	DTMCK		/JMP DTRDUM OR JUMP DTWDUM
/SUBR. TO TRANSF. WPC FROM HEADER TO DTWPC
DTGWPC	0
	RTR
	RTR
	RTR
	RTR
	AND	(776
	DAC	DTWPC		/T. STORE L.B.W.P.C.
	SNA
	JMP	DTER23
	AND	(400
	SNA!CLA
	JMP*	DTGWPC		/L.B.W.C. IN AC
DTER23	LAC	DLIVE+3		/UNIT #, CAL ADDRESS.
	AND	(700000		/PRINT UNIT # +
	XOR	DTNXBK		/OFFENDING BLK #.
	DAC	DERPNT
	LAC	(4		/.ERR 23-ILL. WPC.(0 OR GREATER THAN 177)
	JMP	DTER17
/SUBR. TO ADD TO CHKSUM AND INDEX COUNTS
DTUPTR	0
	TAD	DTCKSM		/ADD DATA WD TO CKSM.
	DAC	DTCKSM
	ISZ	DTUDP
	ISZ	DTRHPT
	ISZ	DTBFCT		/INCR DTA BUF COUNT
	ISZ	DTWPC
	JMP*	DTUPTR		/ALWAYS EXITS HERE ON OUTPUT
	JMP	DTRDE		/END LINE ON INPUT
	.EJECT
/SUBR. TO CHECK ACTIVE FILE
DTCKCL	0
	LAC	DTCLSS		/PREVIOUS FILE CLOSED
	DZM	DTWRWT		/CLEAR I/O RETURN SW
	SZA!CLA
	JMP	DTER10		/NO-FILE STILL ACTIVE
	DZM	DTFILE		/SET SWITCH TO FILE-ORIENTED.
	LAC	DLIVE+5		/SAVE USER D.E. POINTER
	DAC	DTUDRP		/1ST TIME IN ON CAL
	JMS	DTNTRZ
	JMS	DTDRCK		/CHECK FOR DIRECTORY IN CORE
	LAC	DLSAV		/USER D.E. POINTER
	JMS	DTSK1		/DIR. SEARCH FOR FILE
	DAC	DTCLSS		/CLEAR OR SET CLOSE SWITCH
	JMP*	DTCKCL
/COMMON SUBR. TO CHECK ACTIVE CELL SWAP; INIT NOT EXECUTED
/IF NO BUFF ASSIGNED, .ERR 60
DBEXAC	0
	JMS	DBEX		/ACTIVE AREA SWAP
	JMP*	DBEXAC		/OK
	LAC	DBEXAC		/CHECK CALLER
	AND	(77777		/IF OUT OF DTNORS,IGNORE ERR.
	SAD	(DTNORT+1
	JMP*	DBEXAC		/IGNORE* WILL DO XCT DLIVE CODE
	LAW	60		/.INIT NOT EXECUTED: IOPS
	JMP	DTEROR-1		/TERMINAL ERROR
/DTA SEEK FILE SUBR
DTSEEK	JMS	DBEXAB		/BUFFER SWAP CHECK - AUTO .INIT IF NOT DONE
				/I/O SW = 0 BY VIRTUE OF DBUFCR
	JMS	DTCKCL		/CHECK DIRECTORY FOR THIS FILE
	SNA!CLC			/DTA DIR. ENTRY POINTER IN AC
	JMP	DTER14		/FILE NOT FOUND (DTER13)
	XCT	DTSK5		/PICK UP 1ST BLK # OF FILE
	XOR	(400000		/CLEAR FILE COMPLETE BIT
	DAC	DTNXBK		/1ST BLK # TO READ
	DAC	DTSKNT		/SET .SEEK, .ENTER EXECUTED SWITCH
	DZM	DTWRWT
DTSEK1	LAC	(13000
DTSEK2	DAC	DTNCOR		/CLEAR DIR. IN CORE SWITCH
DTSEK3	DAC	DTTR		/INPUT
	XOR	(13000
	SZA
DLCOUB	JMP	DTCOUB		/OUT
	DZM	DTDMOD		/CLEAR DATA MODE TO BYPASS DUMP CHECK
	JMP	DTRNX1
	.EJECT
/L.B. TO DTA BUF (.WRITE) OR DTABUF TO L.B. (.READ)
DTRWT	0
DTWT2	LAC*	DTUDP		/USER L.B.
	DAC*	DTHPT		/TO DTA BUF
	JMS	DTUPTR		/ADD TO CKSUM, INDEX CTS, ETC
	ISZ	DTDATC		/DATA WORD COUNT
	ISZ	DTHPT
	ISZ	DTUWC		/DONE
	JMP	DTWT2
	JMP*	DTRWT
/.WRITE ROUTINE
DTWRIT	JMS	DBEXAC		/BUFFERSWAP CHECK NO AUTO .INIT
	JMS	DRLXEK		/CHECK IF .REALW AND SET SW.
	LAC	DTFILE		/IF .MTAPE,
	SNA
	JMP	DTWRET
	LAC	(1		/SET I/O SWITCH FOR
	DAC	DTIOSW		/OUTPUT (WRITE) AND
	JMS	DTBUFC		/CLEAR BUFFER.
DTWRET	LAC	(15000		/RETURN POINT FOR INTERRUPTED BACK CAL
	DAC	DTWREX
	JMS	DTMCK		/READ/WRITE COMMON SETUP
	LAC	DLIVE+5		/LINE BUFF POINTER
	JMP	DTWDUM		/DUMP MODE WRITE ROUT.
/RETURN HERE FOR IMAGE OR IOPS MODES
DTWRT1	CLC
	TAD	DTWPC		/REMAINING BUF. AREA SIZE
	TAD	DTBFCT		/REMAINING BUF. AREA SIZE
	SMA!CLA
	JMP	DTCOUT		/NO ROOM FOR THIS LINE
	LAC	DTEOF	 	/IF EOF SW SET, LEAVE DTWRWT ALONE
	SZA
	LAC	(JMP DTCLS3
	DAC	DTWRWT
	LAC*	DTUHP
	AND	(7
	SAD	(5
	JMP	DTWRT4
	LAC*	DTUHP		/USER LBH., WD0
	AND	(377000
	XOR	DTDMOD		/DATA MODE
	DAC*	DTUHP
DTWRT4	ISZ	DTUHP		/CLEAR USER CKSM
	DZM*	DTUHP
	DZM	DTCKSM		/INIT CHECKSUM
	CLC			/EXCLUDE L.B.H.; WD0
	TAD	DTWPC		/FROM COUNT
	CMA
	DAC	DTUWC		/ACTUAL WC (2'S COMP)
DTWT1	LAC	DTHPT		/SET UP CKSM POINTER
	DAC	DTUCKP		/FOR .WRITE
	ISZ	DTUCKP
	JMS	DTRWT
	LAC	DTDMOD
	SAD	(4
	JMP	DTDUMK		/DUMP MODE, CHECK FULL BOFF
	.EJECT
	CLC
	TAD	DTCKSM
	CMA
	DAC*	DTUCKP		/STORE 2'S COMP CKSUM IN DTABUF
DTWT5	LAC	DTFILE		/IF NON-FILE-ORIENTED, ALWAYS
	SNA			/OUTPUT BLK FOR EVERY .WRITE.
	LAC	DTEOF
	SZA			/NO EOF
	JMP	DTCOUZ		/TRANSFER EOF
	JMP	DTEMPT		/DATA TRANSFER FROM USER AREA TO
				/DT CORE BUFFER IS DONE.
DTWRCL	JMS	DTBUFC		/CLEAR DTA BUF
	LAC	DTEOF
	SNA!CLC
	JMP	DTWRET		/PUT LINE IN DTA BUF
	JMP	DTCLS2		/THIS WAS A .CLOSE
DTER17	TAD	(1		/TOO MANY (4 OR MORE) FILES REFERENCED
DTER16	TAD	(2		/OUTPUT BUFFER OVERFLOW
				/DECTAPE FULL (DTER15)
DTER14	TAD	(2		/DTA DIRECTORY FULL
DTER12	TAD	(2		/IRREC. DTA ERR. MK. TK., EOT DURING TRANSFER
				/.SEEK, .ENTER NOT EXECUTED (DTER11)
DTER10	TAD	(2		/FILE STILL ACTIVE
	TAD	DTER06		/ILL HANDLER FUNCTION
	JMP	DTEROR-1
/CLEAR OUTPUT BUF. SUBR.
/ALSO NEEDED FOR INPUT BECAUSE OF POINTER INITIALIZATION
DTBUFC	0
	LAC	(377		/INIT DUMP MODE
	DAC	DTROOM		/BUFF SIZE
	LAC	DTIOSW
	RAR
	LAC	DLTBUF		/BUF. (WD0) POINTER (DTBUF
	SZL!STL			/DO NOT MODIFY DTHPT ON INPUT
	DAC	DTHPT		/DTA BUF HEADER POINTER
	DAC	DTRHPT		/FOR READ
	JMS	DTBFC2		/CLEAR BUF, LINK=1
	JMP*	DTBUFC
/CLEAR SPECIFIED AREA SUBR.
DTBFC2	0
	DAC	DTBFC3
	LAW	-40		/CLEAR 40
	SZL
	AND	DTUMSK		/CLEAR 400, DTUMSK=777400
	DAC	DTBFCT		/INIT OUTPUT BUFF SIZE FOR WRITE
	IDX	DTBFCT		/777401
	JMS	DDZM		/AC=COUNT TO CLEAR (40 OR 400)
DTBFC3	XX			/CLEAR POINTER
	JMP*	DTBFC2
	.EJECT
/OUTPUT CURR. IOPS BUFFER
DTCOUT	LAC	(JMP DTWRCL	/SET RETURN FROM INT.
	DAC	DTWRWT		/SET OUTPUT WAIT SWITCH
DTCOUZ	LAC	DTCNBK		/CURR. BL# TO WRITE
	DAC	DTNXBK
	SPA!CLC
	JMP	DTER16		/DECTAPE FULL (DTER15)
	LAC	DTFILE		/IF .MTAPE .WRITE, GET NEXT BLK.
	DAC	WSW		/SET LAST WRITE SW IF .MTAPE WRITE
	SZA!CLA			/EVEN FOR EOF.
	JMP	DTCOUG
	LAC	DTWRWT
	SAD	(JMP DTCLS3
	JMP	DTCOUF
	SNA!CLA			/IF DTWRWT IS NON 0 AND NOT JMP DTCLS3,
				/ALWAYS GET NEXT BLK #.
DTCOUF	LAC	DTEOF		/EOF SWITCH SET?
DTCOUG	JMS	DTMAP		/FIND NEXT FREE BLOCK
	DAC*	DTLINK		/DATA LINK POINTER
DTCOUB	LAC	DLTBUF		/(DTBUF
	JMS	DTWCS		/SETUP WC,CA AND BEGIN TRAN.
	LAC	DLCOUB		/SET UP CAL RETURN
	JMS	DCALST		/SET CAL RETURN
	JMP	DTNOR		/EXIT FOR I/O BEGUN
	.EJECT
/DUMP MODE OUTPUT
DTWDUM	JMS	DTDUMB
	XCT	DTXXX		/JMS DTBUFC OR NOP
	JMP	DTWT1
DTDUMB	0
	XCT*	DTDUMB		/JMS DTBUFC (WRITE) OR NOP (READ)
	ISZ	DTDUMB
	LAC	DTWRCL		/SET SWITCH TO CLEAR
	DAC	DTXXX		/OUTPUT BUFF (JMS DTBUFC)
	LAC	DTROOM
	TAD	DTWCSV
	SMA			/MORE THAN 3 7 TO TRANSFER
	JMP	DTDUMZ		/LAST ELEMENT OF TRANSFER
	DAC	DTWCSV		/SAVE REMAINDER
	LAW	-2
	TAD	DTDUMB		/RET. ADDR. FOR TRANS. COMP
	AND	(17777		/13 BIT ADDR.
	TAD	(JMP
	DAC	DTWRWT		/=I/O WAIT SWITCH
	CLC
	TAD	DTROOM		/FILL IN BUFF
	CMA
DTDUMY	DAC	DTUWC		/SET WORD COUNT
	XCT*	DTDUMB		/JMP DTWT1(WRITE) OR JMP DTNSH1
DTDUMZ	DZM	DTWRWT		/CLEAR I/O WAIT SWITCH
	DAC	DTROOM		/SPACE LEFT FOR NEXT DUMP
	SNA
	JMP	.+3		/FULL BUFF, DO NOT NOP CLEAR BUFF
	LAC	DTLNOP		/SET SWITCH NOT TO CLEAR OUTPUT BUFF
	DAC	DTXXX
	LAC	DTWCSV		/REMAINDER
	JMP	DTDUMY
DTDUMK	LAC	DTROOM		/IF DTROOM=0, BUFF FULL
	SZA!CMA
	LAC	DTWRWT		/IF DTWRWT=0, BUFF NOT FULL
	SZA			/NO
	JMP	DTCOUZ		/YES-OUTPUT
	JMP	DTWT5		/CHECK EOF
	.EJECT
/DTA .READ ROUTINE
DTREAD	JMS	DBEXAC		/BUFFERSWAP CHECK NO AUTO .INIT
	JMS	DRLXEK		/CHECK IF .REALR AND SET SW.
	LAC	DTEOF		/EOF SWITCH SET?
	SZA!CLC
	JMP	DTRNOR		/YES - IGNORE CALL
	LAC	DLIVE+5		/USER L.B. POINTER
	DAC	DTHPT
	DAC	DTHPTS
	DZM	DTIOSW		/SET I/O SWITCH TO INPUT (READ).
	LAC	(13000
	JMS	DTMCK		/READ/WRITE COMMON SETUP, RETURN TO .+2
	LAC	DTRHPT		/DTA BUF HEADER POINTER
	JMP	DTRDUM		/DUMP MODE INPUT
/RETURN HERE FOR IOPS OR IMAGE MODES
	CLC
	TAD	DTWPC		/IOPS ASCII OR BIN (AC=777777 ON RETURN)
	TAD	DTUWC
	DZM	DTDVS		/CLEAR SHORT LINE FLAG
	SMA!CLC
	DAC	DTDVS		/SET SHORT LINE FLAG
	TAD	DTWPC
	CMA
	DAC	DTWPC		/2'S COMP HEADER W.C.
DTRD2	DZM	DTDATC		/DATA COUNT
	DZM	DTCKSM		/CLEAR CHECKSUM
	JMS	DTRWT		/TRANSFER LINE TO USER L.B.
/RETURN HERE ONLY IF SHORT LINE OR DUMP MODE
	LAC	DTDMOD
	SAD	(4
	JMP	DTRDM1		/DUMP
	LAC*	DTUDP		/SHORT LINE BYPASS
	JMS	DTUPTR		/EXCESS DATA
	JMP	.-2
DTRDM1	LAC	DTROOM		/DUMP MODE BUFF SIZE
	SZA!CMA			/IF DTROOM=0 OR
	LAC	DTWRWT		/DTWRWT=NON 0,
	SZA!CLC
	JMP	DTRNEX		/GET NEXT DUMP BLOCK
	JMP	DTEMPT		/I/O REQ. DONE
	.EJECT
/END INPUT LINE ROUTINE
DTRDE	LAC*	DTHPTS		/HEADER WD 0-IOPS
	AND	(7
	XOR	DTFILE		/IF .MTAPE, DON'T GO TO DTREOF.
	SAD	(5		/EOF?
	JMP	DTREOF		/YES
	ISZ	DTDVS		/SHORT LINE FLAG SET
	JMP	DTRDE1		/NO
	LAC	(60
	JMS	DTDVS		/SET D.V. BITS FOR SHORT LINE
DTRDE1	LAC	DTERCT		/PARITY RETRY COUNT
	SMA!CLA
	JMP	DTRDP		/SET D.V. BITS=PARITY
	LAC*	DTHPTS		/HEADER, WD 0
	SPA
	JMP	DTRDN		/IGNORE CKSUM ALREADY SET
	LAC	DTCKSM
	SNA			/SET D.V. BITS=CKSUM ERROR
	JMP	DTRDN
DTRDC	LAC	(20		/CHECKSUM ERR. IN LINE, 12,13=10
DTRDP	TAD	(20		/PARITY ERROR IN DTA BLOCK 12,13=01
	JMS	DTDVS		/SET DATA VALIDITY BITS
DTRDN	LAC*	DTUDP
	SNA!CLC
	JMP	DTRNEX		/NO MORE DATA-GET NEXT BL.
	LAC	DTFILE		/IF .MTAPE,
	SZA!CLC
	JMP	DTRNEX		/GET NEXT BLK.
	ISZ	DTBFCT		/DATA BUF. CT = GET NEXT BL.
	JMP	DTRNOR		/NORM EXIT
DTRNEX	SAD*	DTLINK		/DATA LINK=-0
	JMP	DTREOF		/LAST BLOCK -SET EOF SWITCH
	LAC	DTNXBK		/LAST BL# (READ)
	CMA
	TAD*	DTLINK		/DATA LINK (NEXT BLOCK)
	SPA!CLA			/READ FORW
	CLC			/READ REV.
	SAD	DTDTR		/IF TURNAROUND,
	SKP
	JMS	DTMFLP		/INDEX .MTAPE PASS COUNT.
	DAC	DTDTR		/TRANSF. DIRECTION SWITCH
	LAC*	DTLINK
	DAC	DTNXBK		/DATA LINK INTO NEXT BLOCK
	DAC	DTCNBK		/SET UP FOR .WRITE AFTER BACKSPACE.
DTRNX1	JMS	DTBUFC		/INIT. BUFFER
	LAC	DTDMOD		/DUMP MODE?
	XOR	(4
	SZA			/YES
	JMP	DTCOUB		/NO
	LAC	DTRHPT		/RESET BUFF POINTER
	DAC	DTUDP
	JMP	DTCOUB		/TRANSFER
	.EJECT
/SUBR. TO SET DATA VALIDITY BITS
DTDVS	0
	DAC	DTDVSM		/SAVE MASK
	LAW	17717		/MASK ALL BUT BITS 0, 12,13
	AND*	DTHPTS
	XOR	DTDVSM
	DAC*	DTHPTS		/HEADER, WD0
	JMP*	DTDVS
DTREOF	DAC	DTEOF		/SET EOF SWITCH+DROP THRU TO EXIT
DTRNOR	TAD	DTBFCT		/DECR. (BY 1) DTFCT
	DAC	DTBFCT		/BUF COUNT
	JMP	DTEMPT		/I/O REQ. DONE
/DUMP MODE INPUT
DTRDUM	JMS	DTDUMB		/SET UP FOR DUMP INPUT
DTLNOP	NOP
	JMP	DTRD2		/INPUT DUMP AREA
/DTA ENTER FILE ROUTINE
DTENTR	JMS	DBEXAB		/BUFFERSWAP CHECK - AUTO .INIT IF NOT DONE
	LAC	(1		/SET I/O SW. TO 1 (OUTPUT)
	DAC	DTIOSW
	JMS	DTCKCL		/CHECK DIRECTORY FOR THIS FILE
	DAC	DESAME		/NON 0 = SAME NAME FOUND,
				/WILL NOT BE CHANGED IF IOPS15
	SZA
	JMP	DTNTR6		/FOUND-WILL BE MODIFIED ON .CLOSE
	LAC	DLFAKE		/INIT GOR EMPTY SLOT SEARCH (DTFAKE
	JMS	DTSK1		/D SEARCH FOR EMPTY FILE ENTRY
	DAC	DTCLSS		/CLEAR OR SET CLOSE SWITCH
	SNA
	JMP	DTER14		/DIRECTORY FULL
DTNTR6	LAW	-40		/INIT BIT MAP SEARCH
	DAC	DTWMCT		/BIT MAP WORD COUNT
	LAC	DLMBIT		/FILE BIT MAP POINTER (DT1BIT) OR (DT2BIT)
	DAC	DTPONT		/CURR. FILE BIT MAP WD. POINTER
	LAC	DLTDIR		/BIT MAP ADDR. POINTER (DTDIR
	DAC	DTMTRX
	DAC	DTBMPT		/SET BIT MAP POINTER
	DZM	DTRELB		/BL. #
	LAW	-1100		/INIT DT BLOCK COUNT
	DAC	DTBLOK
	LAW	-1		/INIT BIT MAP
	DAC	DTREM		/SEARCH TO
	DAC	DTSKNT		/PICK UP
	DAC	DTNCOR		/1ST BLOCK FREE
	LAC	(1		/(1
	DAC	DTDIRA		/SET BIT MAP DIRECTION SWITCH
	DAC	DTDIRL		/TO FORWARD (+1)
	JMS	DTMPS		/SETUP TO EXAM. MAP, WD0
	.EJECT
	LAW	-3		/CORRECT FILE NAME POINTER
	TAD	DTFIN
	DAC	DTFIN
	JMS	DTMAP		/GET NEXT FREE BL#
	XOR	(400000
	XCT	DTNTR3		/STORE BL#+COMPLETION BIT IN DTESAV+3
	SMA!CLC
	JMP	DTER16		/DECTAPE FULL (DTER15)
	JMS	DTBUFC
	LAC	DTLNOP
	DAC	DTXXX		/SET OUTPUT DUMP SWITCH
	JMP	DTEMPT		/I/O REQ. DONE
/SUBR. TO SAVE USER D.E.
/DTUDRP SET UP BEFORE ENTRY
DTNTRZ	0
	LAC	DLSAV		/(DT1SAV
	DAC	DTFIN
	LAW	-6		/SET DTA D.E.
	DAC	DTCLCT		/TRANSFER COUNTER
DTNTR2	LAC*	DTUDRP		/SAVE USER D.E.
DTNTR3	DAC*	DTFIN
	ISZ	DTFIN
	ISZ	DTUDRP
	ISZ	DTCLCT
	JMP	DTNTR2
	JMP*	DTNTRZ
/EMPTY SLOT FOR ENTER SEARCH (LAST WD. UNUSED)
DTFAKE	0
	0
	0
DTEOFH	1005			/EOF HEADER FOR CLOSE
/SUBR TO SET UP FOR EXAM OF NEXT BIT MAP WORD
DTMPS	0
	LAW	-22
	DAC	DTRBIT		/18 BIT COUNT
	LAC*	DTMTRX		/NEXT BIT MAP WD
	CMA!STL
	DAC	DTSBIT
	LAC	DTDIRA		/BIT MAP DIRECTION SWITCH
	SMA!CLA!RAL		/REVERSE-SEARCH BIT 18-0
	RTR			/FORWARD-SEARCH BIT 0-18
	DAC	DTTBIT		/FORWARD(0=1); REVERSE (18=1)
	JMP*	DTMPS
	.EJECT
/END OF CURRENT BIT MAP WORD SUBR.
DTMPP	0
DTMPP1	LAC	DTDIRA		/INCR. (IF FORWARD) OR
	TAD	DTMTRX		/DECR. (IF REV) BY 1
	DAC	DTMTRX		/DT. BIT MAP POINTER
	LAC	DTDIRA
	TAD	DTPONT		/FILE BIT MAP POINTER
	DAC	DTPONT
	JMS	DTMPS		/SET FOR NEXT WD
	ISZ	DTWMCT		/BIT MAP WORD CT
	JMP*	DTMPP		/EXIT
	LAW	-1100
	DAC	DTBLOK		/RESET BLK COUNT
	DZM	DTBMCT		/CLEAR BIT MAP SEARCH COUNT
	JMS	DDIRAL
	TAD	DTRELB		/REINIT
	DAC	DTRELB
/ROUTINE TO SET DTREM FOR TURN AROUND CASE
	LAC	DTDIRA
	RAL			/L=1=REV.,L=0=FORW.
	LAC	DTNXBK		/LAST BL # RECORDED FOR THIS FILE
	CMA!SNL			/REV
	JMP	.+3
	TAD	(1100
	CMA
	DAC	DTREM		/LAW TO CHECK ENOUGH SPACE BETW BL
	LAW	-41
	DAC	DTWMCT		/MATRIX COUNT
	JMP	DTMPP1		/START REV. SEARCH
 
/SUBR TO FLIP DTDIRA AT DECTAPE TURNAROUND.
 
DDIRAL	0
	CLA
	ISZ	DTDIRA		/1 0R -1
	LAW	-2		/REV
	TAD	(1		/FWD
	DAC	DTDIRA
	JMP*	DDIRAL
 
	.EJECT
/BLOCK AVAILABILITY BIT MAP SEARCH
DTMAP	0
	DAC	DTMAPT		/SAVE AC, IF -1, IT WILL BE BLK# ON EXIT
	LAC	DTFILE		/.MTAPE .WRITE?
	SZA!CLC
	JMP	DTNFB		/YES.
	DZM	DTBMCT		/BIT MAP SEARCH COUNT
DTMAP1	LAC	DTTBIT		/TEST BIT
DTMAP2	AND	DTSBIT		/MATRIX WORD
	SZA!CLC
	JMP	DTREM		/BLOCK AVAILABLE
	ISZ	DTBLOK		/INCR. DT BLOCK COUNT
	JMP	DTMAP4
	DAC	DTBLOK
	JMP	DTREM5
DTMAP4	ISZ	DTBMCT
	LAC	DTDIRA		/IF FORW, INCR. BL#
	TAD	DTRELB		/IF REV., DECR. BL.# BY1
	DAC	DTRELB
	LAC	DTDIRA
	RAL			/L=0=FORW; L=1=REV.
	LAC	DTTBIT		/SHIFT TEST BIT RIGHT IF FORW,
	SNL!CLL!RAL		/LEFT IF REV.
	RTR
	DAC	DTTBIT
	ISZ	DTRBIT		/INDEX-18 BIT COUNT
	JMP	DTMAP2		/NEXT BIT
	JMS	DTMPP		/END OF MATRIX WD. SUBR.
	JMP	DTMAP1		/NEXT WORD
DTREM	XX			/DELTA BLOCKS IN BETWEEN
	TAD	DTBMCT
	SPA!CLC			/OK-4 BLOCKS IN BETWEEN
	JMP	DTMAP4		/CHECK BIT MAP AGAIN
	SAD	DTMAPT		/IF ENTRY AC = -1, NO DTCBIT
	JMP	DTREM6
	JMS	DTCBIT		/SET BIT IN MAPS
	CMA
	DAC	DTSBIT
DTREM6	LAW	-DELTA		/RESET BLOCK
	DAC	DTREM		/DISTANCE CHECK TO -DELTA
DTREMM	LAC	DTDIRL		/SET TRANSF DIRECTION  SWITCH
	SPA!CLA
	CMA
	DAC	DTDTR
	LAC	DTDIRA		/UPDATE DTDIRL
	DAC	DTDIRL
	LAC	DTRELB		/T. STORE BL# TO BE  USED
DTREM5	DAC	DTCNBK		/EXIT
	LAW	-1		/WAS AC ON ENTRY = -1?
	SAD	DTMAPT
DLSKP	SKP			/YES, EXIT WITH AC= -1
	LAC	DTCNBK		/NEW BLK #
	JMP*	DTMAP		/EXIT -BL ! FOUND(777777=DTA FULL)
DTMAPT	0			/TEMP
	.EJECT
/.MTAPE FREE BLOCK DETERMINATION. AC=-1 ON ENTRY.
 
DTNFB	TAD	DTDECR		/NEXT BLK MUST BE +5(FWD) OR -5(REV).
	CMA
	TAD	DTCNBK		/CURRENT BLK #
	SPA
	JMP	DTNFBT		/TURN AROUND CORNER
	DAC	DTRELB		/TEMP STORE
	TAD	(-1100
	SPA			/TURN AROUND
	JMP	DTREMM		/PICK UP NEW BLK # AND EXIT
DTNFBT	LAC	DTMPAS
	TAD	(LAC DTMBAC
	DAC	.+2
	JMS	DTMFLP		/FLIP SWITCHES
	XX			/LAC DTMBAC+PASS COUNT
	DAC	DTRELB		/NEW BLK #
	JMP	DTREMM		/AC=1ST BLK # OF NEXT PASS
 
	.EJECT
/CHANGE BIT IN MAPS SUBR.
DTCBIT	0
	LAC	DTTBIT		/SET BIT IN FILE BIT MAP
	XOR*	DTPONT
	DAC*	DTPONT
	LAC	DTTBIT		/SET BIT IN MAP
	XOR*	DTMTRX
	DAC*	DTMTRX
	JMP*	DTCBIT		/C(*DTMTRX) MUST BE IN AC ON EXIT
/CLEAR DIRECTORY ROUTINE
DTCLR2	LAC	DTCLRZ		/BLOCK POINTER (71-100)
	DZM	DTRWAY
	IDX	DTRWAY		/WRITE FORW. (DLIVE+4=DTRWAY)
	JMS	DTSET		/SET BLK #, ETC.
	LAC	DLTBUF		/DTBUF
	JMS	DTWCS		/SET UP CA, WC+BEGIN TRANSFER
	JMP	DTNOR		/EXIT FOR CONTINUED I/O
DTCLER	JMS	DBEXAB		/BUFFERSWAP CHECK - AUTO .INIT IF NOT DONE
	LAC	DTCLSS		/CLOSE SWITCH CLEAR
	SZA!CLA			/YES
	JMP	DTER10		/FILE STILL ACTIVE
	LAC	(JMP DTCLR1	/SET RETURN AND
	DAC	DTWRWT		/I/O WAIT SWITCH
	LAC	DLCLR2		/SET UP CAL RETURN
	JMS	DCALST		/SET UP CAL RETURN
	LAC	DLIT70
	DAC	DTCLRZ		/INIT TABLE REF
	JMS	DTBUFC		/CLEAR BUFF
	LAW	-10		/COUNT FOR
	DAC	DTCLR3		/FILE BIT MAP BLOCKS
	LAW	-11
	DAC	DTCLR4		/COUNT OF BLOCKS TO CLEAR+1
DTCLR1	DAC	DTNCOR		/CLEAR DIR. IN CORE SW.
	IDX	DTCLRZ		/INDEX BLOCK #
	ISZ	DTCLR3		/FILE BIT MAP BLOCKS CLEARED?
	JMP	.+4
	LAC	(77600		/INIT DIR TO 10(OCT) SYSTEM BLKS OCCUPE
	DAC*	DLB003
	DAC*	DLB203
	ISZ	DTCLR4		/DONE - FALL THRU TO DTEMPT
DLCLR2	JMP	DTCLR2
	.EJECT
/CONTROL COMES TO DTEMPT
/WHEN I/O REQUEST IS COMPLETED
/SET UP SWITCH IN EXIT ROUTINE TO
/CLEAR FOREGROUND OR BACKGROUND BUSY REGISTER AS
/A FUNCTION OF WORD11 (DLIVE+1), AND PLACE IOF IN DTA
/IOT REGISTER SO THAT NO NEW I/O WILL BE STARTED.
DTEMPT	DZM	DTWRWT		/CLEAR I/O RETURN SW.
	LAW	-1		/CLEAR SAVED STATUS A
	DAC	DTRASV
DTEMPZ	JMS	DFLAG
/IS THIS DEVICE INVOLVED IN I/O BUSY SITUATION.
DTT31	LAC*	(.SCOM+52		/ADDR. OF
	DAC	DTTMP1		/I/O BUSY TESTER
	.IFDEF DT.API
	LAC	(400200		/API LEVEL 0
	ISA
	.ENDC
	.IFDEF DT.PI
	IOF
	.ENDC
	LAC	(DTA.
	JMS*	DTTMP1		/I/O BUSY TEST
	.IFDEF DT.API
	DBK
	.ENDC
	.IFDEF DT.PI
	ION
	.ENDC
	JMS	DTREAL		/CHECK FOR REAL-TIME REQUEST
	JMP	DTNORS		/NOT REAL TIME REQUEST.
	LAC*	(.SCOM+51		/ADDR. OF
	DAC	DTTMP1		/REAL-TIME PROCESSOR
	.IFDEF DT.API
	LAC	(400200
	ISA
	.ENDC
	.IFDEF DT.PI
	IOF
	.ENDC
	LAC	DTWD17		/REAL-TIME RETURN ADDRESS
	JMS*	DTTMP1		/REAL-TIME PROCESSOR
	.IFDEF DT.API
	DBK
	.ENDC
	.IFDEF DT.PI
	ION
	.ENDC
	JMP	DTNORS
	.EJECT
/SUBROUTINE TO DETERMINE IF THIS I/O
/WAS A REAL TIME REQUEST OR NOT.
/CALLING SEQUENCE:	JMS	DTREAL
/		(NOT REAL)
/		(REAL)
DTREAL	0
	LAC DLIVE+1	/0=F;1=B
	TAD (DRELR
	DAC DRELT
	LAC* DRELT
	SNA		/REAL TIME? (YES IF SW. NON-0)
	JMP* DTREAL
	IDX DTREAL	/INDEX EXIT FOR REAL TIME
	DZM* DRELT	/CLEAR REAL TIME SW
	JMP* DTREAL
DRELR	0		/F REAL TIME SW.
	0		/B REAL TIME SW
DRELT	0		/TEMP
	.EJECT
/SUBROUTINE TO SET UP CLEARING OF THE
/APPROPRIATE BUSY FLAG (AT PROTECTED EXIT TIME)
/AND NULLIFY (IOF) THE IOT REGISTER.
DFLAG	0
	LAC	DTIOF		/IOF
	DAC	DTIOT
	LAC	DLIVE+1		/WORD 1 OF LIVE REGS.
	SZA			/0=FGRD, 1=BGRD
	JMP	.+4
	LAC	DTLNOP		/FOREGROUND
	DAC	DTFCLR
	JMP*	DFLAG
	LAC	DTLNOP		/BACKGROUND
	DAC	DTBCLR
	JMP*	DFLAG
/DTERR	JMS	DFLAG		/CLEAR BUSY FLAG.
/MULTI UNIT HANDLERS ONLY:
/FLOW CHART: BOX 33 (DTNORS)
/IGNORED FUNCTIONS
/DTIGN	JMS	DFLAG		/CLEAR BUSY FLAG
/MULTI UNIT HANDLERS ONLY:
/FLOW CHART: BOX 33 (DTNORS)
/THIS SUBROUTINE IS EXECUTED (XCT) BY THE
/CAL HANDLER VIA WORD 0 OF THIS I/O
/HANDLER JUST PRIOR TO GIVING CONTROL
/TO THE HANDLER AT THE APPROPRIATE
/ENTRY IN THE FUNCTION DISPATCH TABLE.
DTSWAP	0
/MULTI-UNIT DEVICES ONLY:
/	STOP  I/O IN PROGRESS ONLY IF BACKUP AND LIVE CELLS ARE BOTH
/	BGRD OR BOTH FGRD (TO ALLOW .INITS)
	LAC	DLIVE+1		/USER (0=F;1=B)
	XOR	DBACK+1
	SNA			/DIFFER
	JMS	DTSTOP		/SAME USERS; STOP I/O
	CLA
	.EJECT
/IF BOTH FGRD AND BGRD BUSY FLAGS ARE ON,FGRD TAKING OVER.
/BGRD DATA TRANSFER IS ALLOWED TO CONTINUE UNLESS AND UNTIL
/FGRD MUST ISSUE AN IOT VIA ROUTINE DTWCS. IN THE MEANTIME,
/BGRD I/O GOING SW.(DTIGNR) IS SET IN CASE OF INTERRUPT.
	SAD DTA.+1	/FGRD BUSY SW.
	SKP		/NOT ON
	SAD DTA.+2	/BGRD BUSY SW.
	SKP		/NOT ON (AC STILL 0)
	CLC		/BOTH ARE ON, SET DTIGNR
	DAC DTIGNR
	LAC DUSER		/FGRD BUFFER ACTIVE?
	SNA!CLC
	DAC DTRASV	/YES,CLEAR
	XCT DTA.+5	/ION OR IOF
	.IFDEF DT.API
	DBK		/FROM LEVEL 0
	.ENDC
	JMS DSWON		/SWAP LIVE AND BACKUP CELLS
	JMP* DTSWAP
	.EJECT
/MULTI-UNIT DEVICES ONLY:
/	SWAP BACKUP AND
/	LIVE DATA REGISTERS.
DSWON	0
	LAW	DSWCT	/COUNT OF CELLS IN LIVE OR BACK-UP
	DAC	DTEMP
	LAC	(DBACK	/BACK-UP CELL POINTER
	DAC	DTEMP1
	LAC	(DLIVE	/LIVE CELL POINTER
	DAC	DTEMP2
DTSWP	LAC*	DTEMP1
	DAC	DTEMP3
	LAC*	DTEMP2
	DAC*	DTEMP1
	LAC	DTEMP3
	DAC*	DTEMP2
	ISZ	DTEMP1
	ISZ	DTEMP2
	ISZ	DTEMP
	JMP	DTSWP
	LAC	DLIVE+3	/SET UP UNIT #, CAL ADDR. IN ERROR POINTER
	DAC	DERPNT
	JMP*	DSWON
DTEMP	0
DTEMP1	0
DTEMP2	0
DTEMP3	0
DTEMP4	0
	.EJECT
/SUBR TO STOP I/O AND SAVE STATUS A IN DTRASV
/THE LINK MUST NOT CHANGE DURING DTSTOP
DTSTOP	0
	DZM DTIGNR	/CLEAR BGRD I/O GOING SW.
	CLC
	DAC DNOIO		/SET IGNORE INTERR. SW.
	DTRA
	AND DTUMSK	/(777400
	DAC DTRASV	/SAVE STATUS A FOR POSSIBLE RE-USE
	AND (20000	/CHECK GO BIT
	SNA!CLL		/CLEAR LINK FOR GO BIT OFF CASE
	JMP DTST1		/OFF, GO CLEAR DTRASV
	STL		/ON, SET LINK FOR LATER USE
	DTXA		/CLEAR IF ON
	LAC DTRASV	/STATUS A=SEARCH, GO BIT SET UP 
	AND (7000
DTST1	XOR (1000
	SNA!CLC		/SEARCH, DO NOT CLEAR DTRASV
	JMP* DTSTOP	/SEARCH, LEAVE DTRASV FOR RE-USE
	DAC DTRASV	/READ OR WRITE, CLEAR (-1) TO START FROM SCRATCH
	SNL		/GO BIT WAS ON, CHECK FOR .TRAN
	JMP* DTSTOP	/OFF, GET OUT
	LAC* (30		/CHECK REMAINING WORD COUNT
	AND DTUMSK	/(777400
	DAC DLIVE+6	/NEW WC(BACK OFF TO LAST WHOLE BLK)
	LAC DTWC		/ORIGINAL WC
	CMA!STL		/SET LINK SO IT WILL BE CLEARED ON TAD
	TAD (1
	TAD DLIVE+6	/OLD WC - NEW WC
	SNA		/.TRAN (WC GREATER THAN 1 BLK)
	JMP* DTSTOP	/1 BLK ONLY; MUST BACK OFF TO IT
	DAC DTWC		/TEMP
	RTR
	RTR
	RTR
	RTR
	TAD DLIVE+7
	DAC DLIVE+7	/NEW BLK #
	LAC DLIVE+5
	TAD DTWC
	DAC DLIVE+5	/REMAINING WC
	JMP* DTSTOP
/DBPT=BUFFER POINTER TABLE
/	WD0=-DN WHERE DN = TOTAL FILE CAPACITY
/	WD 1-N CONTAIN BUFFER ADDRESSES
/ENTRY ESTABLISHED AT .INIT
/	CLEARED AT .CLOSE
DBPT		-DN
	.BLOCK	DN
	.EJECT
/DTCLER BLOCK TABLE
DLIT70	70		/FILE BIT MAPS IN BLK 71-77
DLIT77	77
DLT100	100		/BLOCK 100=DIRECTORY
/ACTIVE FILE CELLS AND BUFFER POINTERS
DBUFF=.
/NOTE: DSLOT, DUSER, AND D.BFTP MUST REMAIN AS 1ST 3 WORDS IN BUFFER.
DSLOT	0		/.DAT SLOT (DLIVE+2)
DUSER	0		/USER: 0=F; 1=B (DLIVE+1)
D.BFTP	0		/.BFTAB ENTRY ADDR.
DTMPAS	0		/.MTAPE PASS COUNT (0-4)
DTDECR	0		/BACKSPACE DECREMENT: -5 (FWD); +5 (REV)
WSW	0		/"LAST COMMAND = WRITE" SWITCH (IF -)
DLTBUF	0		/DTBUF
DBUFAD	0		/EXT. BUFF. ADDR.
DLTDIR	0		/DIRECTORY POINTER(DTDIR)
DLTSYS	0		/WD3 0F SYS BIT MAP(DTDIR+203)
DLB003	0		/SYSTEM BLOCK BITS POINTER(DTBUF+3)
DLB203	0		/BASIC SYSTEM BLOCK BITS POINTER(DTBUF+203)
DTLB40	0		/DIR. ENTRY POINTER (.CLOSE)(DTBUF+40)
DTLINK	0		/FILE1 DATA LINK POINTER(DTBUF+377)
DLMBIT	0		/FILE1 BIT MAP POINTER
DTROOM	0		/DUMP MODE BUFF SIZE (MODIFIED-INITAILLY 377
DTXXX	0		/DUMP MODE OUT SWITCH(JMS DTBUFC OR NOP)
DTNXBK	0		/BL.# TO BE TRANSFERRED
DTCNBK	0		/DATA LINK (NEXT BL.#)
DTCURE	0		/DIR. POINTER TTO CURR. FILE ENTRY EXAMINED
DTEOF	0		/EOF SWITCH, -0=EOF
DTHPT	0		/DTA BUF. LINE HEADER POINTER (INDEXED)
DTIOSW	0		/I/O SWITCH, 0=INPUT, 1=OUTPUT
DTRHPT	0		/DTA BUF. LINE HEADER POINTER (.READ)
DTSKNT	0		/.SEEK,.ENTER EXECUTED SWITCH (NON 0=EXECUTED)
DTPONT	0		/CURR. FILE BIT MAP WD POINTER
DTCLSS	0		/FILE OPEN, CLOSE SWITCH(NON-0=OPEN,0=CLOSED)
DTBFCT	0		/BUFFER COUNT (INIT=-377)
DTDTR	0		/TRANSF. DIRECT. SW.,0=F,-1=R
DTWREX	0		/WRITE EXECUTED SWITCH (0=NOT, NON 0=EXECUTED)
DTFPCT	0		/FILE ENTRY COUNT
DBLKLC	0		/24-56 FILE ENTRY SWITCH(50=24;10=70)
DTTR	0		/SEARCH-READ(13000) OR SEARCH-WRITE(15000)
DTWRWT	0		/INTERRUPT RETURN FOR CONT. I/O (0=CLEAR)
DRENSW	0		/RENAME SWITCH (NON0=SET)
DESAME	0		/NON 0 = SAME NAME FOUND ON .ENTER
DT1SAV	0		/FILE NAME
DTCLR4=.
	0
DTCLR3=.
	0
DTCLRZ=.
	0
	0		/RENAME FILE NAME
	0
	0
	.EJECT
DTFILE	0		/FILE ORIENT. SWITCH,0=FILE,-0=NON-FILE
DTNCOR	0		/DIRECT. IN CORE SWITCH
DTDIRA	0		/BIT MAP DIRECTION SWITCH (CURR. BL.)+1=F,-1=R
DTDIRL	0		/BIT MAP DIRECTION SWITCH (LAST.BL.),+1=F,-1=R
DTMTRX	0		/CURRENT BIT MAP WD. POINTER
DTRBIT	0		/18  BIT (2'S COMP)COUNTER FOR BIT MAP SEARCH
DTRELB	0		/FREE BL.#AFTER BIT MAP SEARCH
DTSBIT	0		/-(MATRIX WORD)
DTTBIT	0		/TEST BIT FOR BIT MAP SEARCH
DTWMCT	0		/BIT MAP WORD COUNT
DTBMPT	0		/DIR. BIT MAP 1 POINTER
DTBLOK	0		/BLOCK EXAMINED COUNT
DTEOTS	0		/END ZONE ENTERED SW.
DTEOTZ	0		/DOUBLE END ZONE SW.(0=SET;-1=CLEAR)
DTRASV	0		/SAVED STATUS A OR -1=CLEAR
DTBLNC	0
DCHKCX	0		/SMA!CLA OR SPA!CLA
DTBLC	0
DTDRGT	LAW -1		/DIR. SEARCH SW. (0=SEARCHING)
BLBND=.
DBUFSZ=BLBND-DBUFF
/FOLLOWING =CELLS USED IN COMMON BY BOTH FILES
DLFAKE	DTFAKE		/POINTER TO EMPTY FILE NAME
DTCCA	0		/CURRENT ADDR. (C.A.) POINTER FOR TRANSFER
DTDATC	0		/LINE DATA COUNT
DTDMOD	0		/DATA MODE (15-17)
DTHPTS	0		/DTA BUF. LINE HEADER POINTER
DTUCKP	0		/USER LINE BUF. CHECKSUM POINTER
DTUDP	0		/USER LINE BUF DATA POINTER (MODIFIED)
DTUHP	0		/USER LINE BUF. HEADER POINTER
DTWC	0		/2'S COMP TRANSFER WORD COUNT
DLEOFH	DTEOFH		/EOF HEADER POINTER (FOR .CLOSE)
DTCKSM	0		/LINE CHECKSUM
DTWPC	0		/WORD PAIR COUNT
DNOIO	0		/IGNORE PHONY INTERR. SW. (-1=IGNORE)
DTIGNR	0		/BGRD I/O GOING SW. (-1=GOING)
DBDONE	0		/BGRD I/O DONE SW. (NON 0= DONE)
DTDVSM	0		/DATA VALIDITY BIT MASK
	.EJECT
DTBMCT	0
DTCLCT	0
DTCLRP	0
DTCTS	0
DTCT1S	0
DTDES	0
DTFIN	0
DTOLBM	0
DTUDRP	0
DTUDRR	0
DTUWC	0
DTWCSV	0
DTXRNW	0
DTXROL	0
	.END
