	.TITLE	DPF.
/	6-2-70	(EDIT20)
/COPYRIGHT 1969,1970, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/RP09/15 ADAPTATION W.A. DESIMONE 9-1-70
/W. A. DESIMONE - (RP EDIT 7 11-3-70)
/9-16-69 (TIMING BUG)
/	4/30/69
/DPF. = IOPS DECTAPE/DISK HANDLER FOR NON-FILE ORIENTED I/O
/LIMITED FUNCTIONS
/NO INTERNAL BUFFERS
/CALLING SEQUENCE
/CAL+.DAT SLOT(9-17) + I(7-8)/.INIT
/UNIT (0-2) +1(=FUNCTION)
/RESTART ADDR. (ONLY MEANINGFUL FOR TTY HANDLER)
/MAXIMUM BUFFER SIZE (255)
/CAL + .DAT SLOT (9-17)/.CLOSE - PERFORMS EOF
/UNIT (0-2) +6(=FUNCTION)
/CAL + SUBFUNCTION(5-8) + .DAT SLOT /.MTAPE	(00=REWIND
/UNIT (0-2) +7(=FUNCTION)			(02=BACKSPACE RECORD
/						(05=FORWARD SPACE RECORD
/CAL + DATA MODE(6-8) + .DAT SLOT(9-17)/.READ
/UNIT(0-2) + 10(=FUNCTION) (IOPS ASCII AND IOPS BINARY
/LINE BUF ADDR   DATA MODES ONLY)
/-WC OF L.B. (2'S COMP)
/SAME AS .READ (FUNCTION = 11)/.WRITE
/CAL + .DAT SLOT (9-17)/.WAIT
/UNIT 0-2) + 12(=FUNCTION)
/CAL + 1000 + .DAT SLOT(9-17)/.WAITR
/UNIT(0-2) + 12(=FUNCTION)
/15BIT BUSY ADDRESS
	.EJECT
	.GLOBL DPF.
IDX=ISZ
/IOT ASSIGNMENTS
DPCS=706324			/CLEAR STATUS  (BITS 13,17,18 OF ST.A)
				/(BITS 9-15 OF ST.B)
DPSJ=706341			/SKIP ON JOB DONE FLAG
DPSE=706361			/SKIP ON ERROR FLAG
DPLF=706464			/LOAD ST.A (BITS 0-8)
DPLA=706304			/LOAD CYA,HA,SA FROM AC.
DPCA=706344			/LOAD CA REGISTER FROM AC (3-17)
DPWC=706364			/LOAD WC REGISTER FROM AC
DPRSA=706312			/READ ST. A INTO AC
DPRU=706412			/READ CA INTO AC (10-17)
DPCN=706454			/EXECUTE FUNC. REG.-AC CLEARED
DPRA=706432			/READ CYA,HA,SA INTO AC
DPRC=706452			/READ CA REGISTER INTO AC (3-17)
DPRW=706472			/READ WC REGISTER INTO AC
DPRSB=706332			/READ STATUS B INTO AC
DPLO=706444			/LOAD AC ONES INTO ST. A (BITS 0-8)
DPSA=706321			/SKIP ON ATTENTION FLAG
/
DPF.	DAC DTCALP		/STORE CAL POINTER
	DAC DTARGP		/SET UP ARG. POINTER
	LAW 7000
	AND* DTCALP		/MASK (6-8)
	RAR!CLL			/SHIFT TO (15-17)
	RTR			/ROTATE 8 RIGHT
	RTR
	RTR
	RTR
	DAC DTCT			/TEMP. STORE DATA MODE OR SUBFUNCTION
	IDX DTARGP		/INDEX TO FUNCTION AND UNIT #
	LAC* DTARGP		/MASK UNIT #
	AND DTUMSK		/DTUMSK=LAW -400
/LINK=0 - GET STATUS OF THIS DT UNIT
	RTL
	RTL			/RIGHT JUSTIFY UNIT #
	DAC DTUNIT		/SAVE UNIT NUMBER (BITS 15-17).
	TAD (LAC DTMULP		/CONSTR. FOR DT STATE LAC
	DAC DTPVOT
	XOR (240000		/CONSTR. A DAC FOR DTUPDT
	DAC DTLOAD
DTPVOT	XX
	DAC DTSTAT		/STORE DT STATE
	RAR			/DTIOSW BIT TO 17
	AND DLIT1
	DAC DTIOSW		/SWITCH SET TO CURRENT STATUS
	LAC DTSTAT
	RTR			/BITS 4-15 TO 6-17
	AND (7777			/MASK OFF DTNXBK
	SAD (7777
DLITM1	LAW -1
	DAC DTNXBK
	CLL
	LAC DTSTAT		/MASK OFF UNITNO (BITS0-2).
	AND (700000
	RTL
	RTL
	DAC UNITNO
	SNA
	JMP DTPVO1		/NO ADDED UNITS - USE UNIT # FROM CAL.
	CMA			/MUST UPDATE UNIT # PASSED BY CAL TO THE
	TAD DLIT1		/ONE ACTUALLY BEING USED.
	DAC DTWCS		/TEMP STORAGE.
	IDX DTUNIT
	ISZ DTWCS
	JMP .-2
DTPVO1	LAC* DTARGP		/INDEX TO ARG. 3
	IDX DTARGP
	AND (77
	TAD (JMP DTTABL
	DAC DTTABL
	LAC ENDSW			/IF WRITING AN EOF BECAUSE OUT OF DISK,
	SPA!CLL			/GO TO THE CLOSE ROUTINE.
	JMP DTCLOS
DTTABL	XX
	JMP DTINIT		/1=.INIT
	JMP DIGNR			/2=.OPER IGNORE
	JMP DIGNR			/3=.SEEK IGNORE
	JMP DIGNR			/4=.ENTER IGNORE
	JMP DTER6			/5=.CLEAR ILLEG.
	JMP DTCLOS		/6=.CLOSE
	JMP DTMTAP		/7=.MTAPE
	JMP DTREAD		/10=.READ
	JMP DTWRIT		/11=.WRITE
	JMP DTWAIT		/12=.WAIT, .WAITR
DTER6	LAC DLIT6			/13=.TRAN ILLEGAL
	JMP DTM4		/ILL FUNCTION; IOPS 6
DIGNR	IDX DTARGP	/INDEX TO CORRECT RETURN ADDRESS
	CLA		/AC=0 FOR FAKE BLK. NOT FOUND FOR .SEEK ETC.
	JMP DTFBK
/
/I/O UNDERWAY CHECK SUBROUTINE DTUND = 0 IMPLIES I/O NOT UNDERWAY
DTIOU	0
	LAC DTUND
	SZA!CLL!CMA		/I/O UNDERWAY? LINK CLEARED FOR USE IN DTMCK
	JMP DTBUSY		/YES
	JMP* DTIOU		/NO. EXIT
/
DTBUSY	LAC DTCALP		/CAUSE HANG ON USER CAL
	DAC DTARGP
	JMP DTFBK			/EXIT ON HANG.
	.EJECT
/
/DTF. INTERRUPT SERVICE
/
DTIN	JMP DTPIC			/JMP FOR PI ENTRY
	DAC DTAC			/STORE AC FOR API ENTRY
	LAC DTFVSW-1		/DTFVSW-1 = LAC DTAC
	DAC DTFVSW		/LEAVE PIC ALONE ON EXIT
	LAC DTIN			/FOR API. CONTAINS PC,L,EM,MP
	JMP DTCOM			/COMMON EXIT
DTPIC	DAC DTAC			/SAVE AC ON PI ENTRY
	LAC DTSVTM		/ALLOW FOR PIC TO BE TURNED ON DTSUTM = ION
	DAC DTFVSW		/AGAIN AT EXIT IN PI ENVIRONMENT
	LAC* DTMBAK		/DTMBAK = 0. GET PC,L,EM,MP FOR PI
DTCOM	DAC DTOUT
/RP15 DISK STATUS REGISTER "A" BIT ASSIGNMENTS
/	0-2=SELECTED UNIT
/	3-5=FUNCTION
/	0=IDLE,1=READ,2=WRITE,3=RECALIBRATE
/	4=SEEK,5=READ ALL,6=WRITE ALL, 7=READ COMPARA
/	6=DONE AND ERROR FLAG INTERRUPT ENABLED
/	7=ATTENTION FLAG INTERRUPT ENABLED
/	8=GO
/	9=WRITE PROTECT ERROR
/	10=NON-EXISTENT CYLINDER ADDRESS
/	11=NON-EXISTENT SURFACE ADDRESS
/	12=NON-EXISTENT SECTOR ADDRESS
/	13=HEADER NOT FOUND
/	14=SELECTED UNIT IS WRITE PROTECTED
/	15=SELECTED UNIT IS SEEK INCOMPLETE
/	16=JOB DONE FLAG
/	17=ERROR FLAG
/RP15 DISK STATUS REGISTER "B" BIT ASSIGNMENTS
/	0-7=ATTENTION UNITS 0-7
/	8=SELECTED UNIT IS UNSAFE
/	9=PROGRAM ERROR
/	10=END OF PACK
/	11=TIMING ERROR
/	12=FORMAT ERROR
/	13=WRITE CHECK ERROR
/	14=WORD PARITY ERROR
/	15=LONGITUDINAL PARITY ERROR
/	16=SELECTED UNIT SEEK UNDERWAY
/	17=SLECTED UNIT NOT READY
/
	DPRSA			/READ DISK STATUS.
	DAC DKSET			/TEMP STORAGE OF STATUS WORD.
	CLL!RAR
	SZL
	JMP DTERT			/ERROR FLAG ON.
RFRDWT	DPCS			/CLEAR DISK STATUS.
	LAC DKSET	/GET ST A FOR RP UNIT#
	AND (700000)		/MASK AND ISSUE AN IDLE TO CLEAR
	DPLF	/JOB DONE AND ERR INTERR. ENABLE
DTION	ION			/ION TO ALLOW OTHER INTERRUPTS.
	DZM DTUND			/CLEAR I/O UNDERWAY SWITCH.
	JMP DTXIOT
DTERT	LAC	DKSET		/RELOAD ST A.
	AND	(24)
	SZA			/AC70 IF SEEK INCOMP. OR HEADER
	JMP	RPRCL		/NOT FOUND-RECALIBRATE + RETRY
	LAC	DKSET
	AND	(340)		/AC70 IF NON-EXISTENT DISK ADDR.
	SZA
	JMP	DTER21
	LAC DKSET	/CHK. FOR WP. ERR
	AND (400)
	SZA		/AC>0 MEANS WRITE PROT. ERR
	JMP DKIPS4	/IOPS 4
	DPRSB			/LOAD STATUS B
	DAC	RPSTB		/STORE
/CHECK STATUS B.
/
	AND	(34)		/AC>0 IF LONG., WORD PARITY, WRITE CHK.,
	SZA			/WRITE CHECK SHOULD NEVER HAPPEN
	JMP	DPARIT		/RETRY AND PASS DATA ANYWAY
	LAC	RPSTB
	AND	(140)		/AC>0 IF FORMAT ERR OR TIMING ERR.
	SZA			/RETRY.IF FAILS, IOPS 12 PLUS
	JMP	RP12RT		/STATUS B
	LAC	RPSTB
	AND	(200)		/END OF PACK
	SZA			/IF AC>0-IOPS-21
	JMP	DTER21
RPER12	LAC	RPSTB		/FALLS THROUGH HERE
	DAC*	DLIT3		/ON PROGRAM ERROR OR
	CLA			/SELECTED UNIT UNSAFE
	JMP	DTER12		/IOPS 12
RPRCL	LAC	(30000		/LOAD RECALIBRATE FUNCT.
	XOR	RPUNIT		/AND RETRY.
	DPLF
	DPRSB		/2 INSTRS. FOR 4 MICROSECOND DELAY
	DPRSB
	DPSA			/TEST ATTENTION FLAG
	JMP	.-1
	ISZ	DTERCT
	JMP	DRETRY		/GO RETRY
	JMP	DKER20		/DISK FAILURE
DKIPS4	LAC (DRETRY
	DAC* DLIT3
	LAC DLIT4
	JMP DTM4
RP12RT	ISZ	DTERCT		/RETRY ROUTINE FOR FORMAT
	JMP	DRETRY		/OR TIMING ERROR
	JMP	RPER12
DKER20	LAC DKSET			/DISK STATUS.
	DAC* DLIT3		/(.MED
	LAW 20
	JMP DTM4		/DISK FAILURE.
DTER21	LAC DKSET
DTR21A	DAC* DLIT3
	LAW 21			/ILLEGAL DISK ADDRESS.
	JMP DTM4
DPARIT	ISZ DTERCT		/IF OVERFLOW, TAKE DATA ANYWAY
	SKP
	JMP RFRDWT		/TAKE DATA ANYWAY.
DRETRY	JMS DKSET			/REISSUE DISK READ (TRY 10 TIMES).
	LAC DTERCT		/0 IF RETRY COUNT OVERFLOWS
	DAC DTUND			/I/O UNDERWAY SW.
	JMP DTXIOT
DTPRGO	DZM DTUND		/REINIT I/O UNDERWAY SWITCH
DTXIOT	LAC (JMP DTPIC	/RESTORE PIC INTERRUPT ENTRY
	DAC DTIN
	LAC DTAC		/RESTORE AC
DTFVSW	XX		/ION IF UNDER PI - LAC DTAC IS UNDER API
	DBR
	XCT .+1		/PRESERVE IOT CHAIN
	XCT .+1
	JMP* DTOUT	/DTOUT = 0 IF PI DTOUT = DTIN IF API
	LAC DTTR		/RETURNING FROM READ OR WRITE
	SAD (15000	/A WRITE?
	JMP DTPRGO	/DON'T CALCULATE CHECKSUM ON WRITE
/INTERRUPT TURNED ON TO ALLOW EXIT
DTSVTM	ION		/ALLOW INTERRUPT
	LAC* DTUFP
	JMS DTWGPC	/CALC. WC FROM USER HEADER 0
	LAC DTWPC		/LOAD CALC. WC
	TAD DTUWC		/ADD 2'S COMP. OF WC FROM .READ
	SMA!CLA		/> OR = 0 IF SHORT LINE
	JMP DTSHRT	/GO SET VALIDITY BITS
	LAC DTUFP		/LOAD PTR. TO USER W0
	DZM DTCKSM	/CLEAR CHECKSUM COUNT
	JMS CALCKS	/GO CALC. CHK SUM.  RETRN IN AC
	SNA!CLA		/SKP IF CHK SUM NOT 0
	JMP DTPRGO	/NO CHK SUM OR SHRT LINE PROBLEM
	SKP
DTSHRT	TAD (20
	TAD (40
	XOR* DTUFP	/SET VALIDITY BITS
	DAC* DTUFP	/REDEFINE
	JMP DTPRGO
/
/ .INIT FUNCTION.
/
DTINIT	ISZ DTARGP	/INDEX TO BUFFER SIZE ARG.
	LAC (377		/MAX BUFFER SIZE - 
	DAC* DTARGP
	LAC DTCT		/USED DATA MODE OR SUBFUNCTION A SWITCH SET
	DAC DTIOSW	/LOAD SWITCH TO 0 IF INPUT
	IDX DTARGP	/FOR NORMAL EXIT
DTONCE	CAL 64		/ONCE ONLY CODE FROM HERE TO DTSTOP
/
/CODE FROM HERE TO DTSTOP ONCE ONLY CODE.
/
/DTTR = IOT SETUP -
/DTOUT = EXIT ADDRESS
/DTUCKP = CHECKSUM POINTER
/CKSCNT = COUNTER IN CHECKSUM CALCULATOR
/DTERCT - PARITY RETRY COUNT
/DTAC - SAVE AC REGISTER
/RPCABS=STORAGE FOR BASE SUPERUNIT ADDRESS
/RPUNIT=PHYSICAL DISK PACK DRIVE #
/RPSTB=STORAGE FOR STATUS B
/RPCACK=TEMP STORAGE FOR CHECK BLK# 100 ROUTINE
/DTBCA-BLOCK JUST READ.
/DTFCA-STORAGE FOR DATA MODE
/DTBLC-STORAGE FOR BLOCK LOOKED FOR.
/DTUWC-STORAGE FOR USER WORD COUNT.
/DTWPC-DT WC IN 2'S COMP
/DTHPT-DT WORD 0 WORKING PTR.
/DTCKSM-CHECKSUM STORAGE
/DTBUIL-T - DTSTAT.
	16		/SKIP ON JOB DONE FLAG
DTTR	DPSJ
DTOUT	DTIN
RPCABS	CAL 64
RPUNIT	16
RPSTB	DPSE		/SKIP ON ERROR FLAG
RPCACK	DTIN
DTERCT	LAC (JMP DTSTOP	/RESET FOR JUMP OVER ONCE ONLY CODE
DTAC	DAC DTONCE
DTUCKP	LAS		/READ AC SWITCHES
CKSCNT	AND (770)		/DRIVE #(9-11) SUPER UNIT# (12-14)
DKUNIT	DAC DTUCKP	/MASK BITS 9-14 AND STORE
DKNUM	AND (700)		/MASK BITS 9-11
DTBCA	JMS RPTEMP	/AND SET UP RP UNIT#
DTUWC	DAC RPUNIT	/TOTAL ROT LEFT 9 AND STORE
DTBLC	LAC DTUCKP
DTFCA	AND (70)		/MASK BITS 12-14
DTWPC	DAC DTUCKP	/STR SUPUNT# TIMES 10(8)
DTHPT	RAL!CLL		/NOW TIMES 20(8)
DTCKSM	TAD DTUCKP	/NOW TIMES 30(8) - THAT IS
DTBUIL	JMS RPTEMP	/30(8)*SUPUNT#=20(8)*SUPUNT#+10(8)*SUPUNT#
	RAL		/TOTAL OF 10 SHFTS
	DAC RPCABS	/STORE BASE CIL. ADDR.
	JMP DTSTOP
RPTEMP	0
	RAL!CLL
	RTL
	RTL
	RTL
	RTL
	JMP* RPTEMP
DTSTOP	JMS DTIOU		/ALLOW FOR I/O BUSY TEST?
	JMP DTREXT
/
/ .MTAPE FUNCTION.
/
DTMTAP	JMS DTIOU		/I/O UNDERWAY?
	LAC DTCT		/LOAD .MTAPE FUNCTION
	SNA
	JMP DTMREW	/REWIND
	SAD DLIT2		/A 2?
	JMP DTBKSP	/BACKSPACE
	SAD DLIT5		/A 5?
	JMP DTFORS	/YES, FOREWARD SPACE.
	JMP DTREXT	/IGNORE FUNCTIONS NOT = 00,02,05.
DTMREW	LAW -1		/REWIND
	DAC DTNXBK	/SET SP BUMP OF BOLCK ON TRANSFER GIVES 0.
	DZM UNITNO	/RESET TO ORIGINAL UNIT NUMBER.
	JMP DTREXT
DTBKSP	LAC DTNXBK	/ BACKSPACE.
	SAD DLITM1	/IS IT -1?
	JMP DTREXT	/YES. IGNORE BACKSPACE.
	SAD (0
	JMP DTBKS1
DTBSK2	LAC DTNXBK
	TAD DLITM1	/DECREMENT BLOCK # BY 1.
	DAC DTNXBK	/STORE
	JMP DTREXT	/EXIT.
DTBKS1	LAC UNITNO	/IF UNIT HAS BEEN BUMPED, MUST GO BACK
	SNA		/TO NEXT SEQUENTIAL UNIT.
	JMP DTBSK2	/ONLY 1 UNIT INVOLVED .
	TAD DLITM1
	DAC UNITNO	/SUBTRACT 1 FROM UNIT NUMBER.
			/LAST BLOCK = 1077
	LAC (1077)
	DAC DTNXBK
	LAC (DTREXT	/SET UP FOR RETURN ON IOPS4.
	DAC* DLIT3
	LAC DLIT4
	JMP DTM4
DTFORS	LAC DTNXBK	/PROCESS FORWARD SPACE.
	TAD DLIT1
	DAC DTNXBK
	LAC DTNXBK
	TAD (-1100)
	SMA!CLL		/CLEAR LINK FOR DTUPDT.
	JMP DTFULL	/DECTAPE FULL.  
DTREXT	JMS DTUPDT	/COMMON EXIT
	JMP DTFBK
/
/ CURRENT DISK UNIT FULL.
/ ALLOW USER TO USE MORE THAN 1 SEQUENTIAL DISK UNIT.
/WARNING*** USER MUST BE CAREFUL OF .DAT SLOT ASSIGNMENTS
/SO THAT HE DOESN'T ALLOW CLOBBERING OF GOOD DATA ON THE NEXT UNIT!!!!!
/
DTFULL	LAC (DTREXT	/SET FOR REENTRY.
	SKP
DTFULA	DZM DTUND	/IN CASE .CLOSE REQUIRED
	DAC* DLIT3
	IDX DTUNIT		/BUMP TO NEXT UNIT NUMBER.
	LAC DTUNIT		/IF OFF THE END OF THE LAST UNIT,
	TAD (-10)			/AND TERMINATE.
	SMA
	JMP DTWCS7	/OFF END OF DISK?
	LAW -1
	DAC DTNXBK	/SET SO BUMP OF BLOCK ON TRANSFER GIVES 0.
	JMS DTUPDT	/UPDATE DT STATUS REGISTERS
	IDX UNITNO
	JMS DTUPDT
	LAC DLIT4
	JMP DTM4	/GO OUTPUT IOPS 4
/
/ CONSTANTS, STORAGE, ETC.
/
DTEOFH	2005		/EOF HEADER WORD 0
	775773		/EOF HEADER WORD 1.
DTMBAK	0		/MUST REMAIN ZERO
DLIT4	4
DLIT3	3
DTMBAC	1076
DLIT6	6
DLIT7	7
DLIT1	1
DLIT2	2
DTFMOD	0		/STORAGE FOR DATA MODE
DTUFP	0		/FIXED PTR. TO WORD 0 OF USER BUFFER.
DTARGP	0		/DTF CAL ARGPOINTER
DTCALP	0		/DTF CAL POINTER
DTIOSW	0		/DT I/O SWITCH
DTLMK	LAC DTMBAK
DTLMC	LAC DTMBAC
DTCT	0		/TEMP STORAGE FOR DM OR FUNCT.
DLIT5	5
DTUNIT	0		/DT UNIT # STORAGE (BITS 15-17).
DKU	0	/LOG. UNIT# BITS 0-2
UNITNO	0		/ACTUAL UNIT NUMBER.
DTUND	0		/ I/O UNDERWAY SWIT. 0 IF NOT
DTCLSW	777777		/.CLOSE DONE SWITCH
DTSTAT	0		/DT STATE
DTNXBK	-1		/ALLOW FOR BUMP BEFORE SEARCH.
DTUMSK	LAW -400		/MASK FOR CAL PROCESSOR
ENDSW	0		/TERMINATE W/ IOPS 15 AFTER OUTPUTTING EOF.
DLM677	777100		/(-677
	.EJECT
/
/SUBROUTINE TO CALCULATE CHECKSUM.
/
CALCKS	0		/ROUT. TO CALCULATE CHKSUM
	DAC DTUCKP
	LAC DTUWC
	DAC CKSCNT
CKAGAN	LAC* DTUCKP	/LOAD WORD 0
	TAD DTCKSM
	DAC DTCKSM	/STORE CUMULATIVE TOTAL
	ISZ DTUCKP	/BUMP PTR.
	ISZ CKSCNT	/BUMP COUNTER
	JMP CKAGAN	/REPEAT
	JMP* CALCKS
/
/
DTWGPC	0
	RTR
	RTR
	RTR
	RTR
	AND (776
	DAC DTWPC		/NOW WORD COUNT
	SNA
	JMP DTER23
	AND (400
	SNA!CLA
	JMP* DTWGPC
/
/
DTER23	TAD DLIT5		/IOPS 23
	JMP DTER16
/
/.READ FUNCTION.
/
DTREAD	JMS DTIOU		/I/O UNDERWAY
	LAC DLIT3		/FOR READ SET UP
	JMS DTMCK		/COMMON READ - WRITE SETUP - RETURNS WITH AC=777777
	DZM DTCKSM	/CLEAR CHKSUM
	LAC DTHPT		/ENTER WITH CA 
	JMS DTWCS
DTAPE1	IDX DTARGP	/BUMP TO NORMAL
	JMP DTFBK		/EXIT
/
/
DTMCK	0		/COMMON READ - WRITE SETUP
	DAC DTTR
	LAC* DTARGP	/GET USER BUFFER POINTER
	DAC DTHPT		/WORKING POINTER IN USER BUFFER
	DAC DTUFP		/FIXED PTR.
	IDX DTARGP	/BUMP POINTER
	LAC* DTARGP	/GET USER WC - 2'S COMP. - FROM PSEUDO OP
	DAC DTUWC		/USER WC
	LAC DTCT		/DATA MODE
	DAC DTFMOD	/STORE DATA MODE
/LINK SHOULD BE CLEARED IN DTIOU ROUTINE
	RTR		/0 OR 2 DATA MODE TEST ONLY!
	SNA!CLC		/COMPL. AC IN CASE OF ERROR
	JMP* DTMCK	/DATA MODE O.K. EXIT
	JMP DTER10	/IOPS7 - ILLEGAL DATA MODE
/
/SUBROUTINE TO SET UP CA,WA
/
DTWCS	0
	DAC DTFCA		/CURRENT ADDRESS REGISTER
DTWCS6	LAW -5		/PARITY ERROR RETRY COUNT
	DAC DTERCT	/REINIT
	DAC DTUND		/SET I/O *NDER WAY
	LAC DTUNIT	/UNIT# IN BITS 15-17
	CLL			/
	RTR
	RTR
	AND	(700000		/MASK BITS 0-2
	RTR; RTR
	DAC	RPTEMP		/STORE 2* UNIT# IN BITS 0-7
	RAR
	TAD	RPTEMP		/NOW 3* UNIT# IN BITS 0-7
	TAD	RPCABS		/BASE CYL. ADDR FROM .INIT
	DAC	DTBLC		/ABSOLUTE CYLA IN (0-7)
	IDX DTNXBK	/BUMP TO NEXT SEQ. BLOCK
DLM177	777600		/(-177)--ALLOW FOR ISZ OF 777777
	JMS DTUPDT	/UPDATE UNIT STATUS WORD
	LAC DTNXBK
	SAD (1100)	/UNIT FULL?
	JMP DKFUL
	DAC	RPTEMP		/ABSOLUTE PACK ADDR.
DTWCS2	TAD	(-310
	SPA			/BLK# < 310(8)?
	JMP	DTWCS3		/GO GET HEAD ADDR
	DAC	RPTEMP		/STORE REMAINDER
	LAC	DTBLC
	TAD	(2000)		/ADD ONE TO CA
	DAC	DTBLC
	LAC	RPTEMP
	JMP	DTWCS2
DTWCS3	LAC	RPTEMP
DTWCS4	TAD	(-12
	SPA
	JMP	DTWCS5
	DAC	RPTEMP
	LAC	DTBLC
	TAD	(40)		/BUMP HEAD ADDRESS
	DAC	DTBLC
	LAC	RPTEMP
	JMP	DTWCS4		/RECYCLE
DTWCS5	LAC	DTBLC
	TAD	RPTEMP		/INCLUDE SECTOR ADDRESS
	DAC	DTBLC
	JMS	DKSET
	JMP*	DTWCS
DKFUL	LAC (DTWCS6	/SET UP FOR REENTRY ON IOPS 4.
	JMP DTFULA
DTWCS7	LAC DTUNIT		/CHECK TO SEE IF HAVE RUN OFF END OF DISK.
	TAD DLITM1
	DAC DTUNIT
	LAC DLITM1	/NOW, PUT EOF ON LAST BLOCK OF LAST UNIT.
	DAC ENDSW
	LAC DTNXBK
	TAD (-2		/BUMP BACK 2 SO OK FOR DTWCS ROUTINE.
	DAC DTNXBK
	JMP DTCLOS	/CLOSE ROUTINE OUTPUTS EOF.
/
/SUBROUTINE TO SET UP DISK I/O AND EXECUTE IOT'S.
/
DKSET	0
DKSET2	LAC	DTFCA
	DPCA			/LOAD CA
	LAC DTUWC	/LOAD WC
	DPWC			/LOAD WC
	LAC	DTBLC
	DPLA			/LOAD C-1L. ADDR,HA,SA
	LAC	RPUNIT		/DESELECT CURRENTLY ACTIVE DRIVE
	TAD	(400000		/TO ALLOW READ ONLY SWITCHES
	DPLF			/TO ACTIVATE
	LAC	DTTR
	XOR	DLIT3
	SZA			/ZERO IF INPUT
	LAC	(10000		/OUTPUT
	TAD	(10000
	XOR	RPUNIT		/LOAD PACK PHYS. UNIT#
	DPCS			/CLEAR STATUS
	DPLF			/LOAD FUNCTION LESS GO BIT TO TEST UNIT
	DPRSB			/READY.
	NOP			/ADDED INSTR. FOR 4 MICRS. DELAY
	DPRSB			/ADDED INSTR. FOR 4 MICRS. DELAY
	RAR
	AND	(400)
	SZL			/L=1 IF SELECTED UNIT NOT READY
	JMP	RPUOFL		/AC=0 IF WRITE PROT. ERR. -IOPS4
	LAC	(5000		/JAM GO BIT, JB. DONE AND ERR INTERP.
	DPCS			/ENABLE-CLEAR STATUS
	DPLO			/LOAD GO BIT+INTERRUPT ENABLES
	ION			/ALLOW OTHER INTERRUPTS
	JMP*	DKSET
RPUOFL	LAC	(DKSET1		/IOPS4 ON UNIT OFF LINE
	DAC* DLIT3
	LAC DLIT4
	JMP DTM4
DKSET1	LAC DTERCT
	DAC DTUND		/RESET I/O UNDERWAY SWITCH
	JMP DKSET2
/
/ .WRITE FUNCTION.
/
DTWRIT	JMS DTIOU		/I/O UNDERWAY?
	LAC DLIT5		/NO
	JMS DTMCK		/COMMON READ - WRITE SETUP ROUTINE - 1
	LAC* DTUFP	/LOAD WORD 0
	JMS DTWGPC	/GO CALCULATE WC FROM USER WORD 0
	LAC* DTUFP	/LOAD WORD 0 OF USER BUFFER
	AND DLIT7		/MASK BITS
	SAD DLIT5		/EOF?
	JMP DTPASM-1	/FORGET LOADING DATA MODEP DTPASM
	SAD DLIT6		/EOT?
	DAC DTFMOD	/OVERRIDE DATA MODE FOR EOT  OR EOF INDICATOR.
DTPASM	LAC* DTUFP	/IT IS O.K. SINCE DATA MODE CHECKED IN DTMCK
	AND (377000	/SAVE UP COUNT
	XOR DTFMOD
	DAC* DTUFP	/RESTORE MODIFIED WORD 0
	DZM DTCKSM	/INIT CHECKSUM COUNT
	IDX DTHPT		/BUMP TO WORD 1
	DZM* DTHPT	/ZERO WORD 1 FOR CHECKSUM CALCULATION
	LAW -377
	JMS DTOBCK	/CHECK USER BUFFER SIZE
	CLC		/GET TWO'S COMPL. OF WC
	TAD DTWPC
	CMA
	DAC DTUWC		/2'S COMPL OF WC-FOR DEFINING CHKSUM COUNTER
	LAC DTUFP		/WORD 0
	JMS CALCKS	/CALCULATE CHKSUM
	CMA
	TAD DLIT1		/2'S COMP OF CHKSUM
	DAC* DTHPT	/LOAD CHKSUM
	LAC DTUFP		/CA
	JMS DTWCS		/SUBROTINE TO SET UP WC,CA & SEARCH
	JMP DTAPE1	/NORMAL EXIT
/
/
DTOBCK	0
	TAD DTWPC		/LBWC
	SPA!CLA
	JMP* DTOBCK	/NO BUFFER OVERFLOW
/
/ ERROR ROUTINES.
/
DTER15	DZM ENDSW
	LAC DLIT1		/DECTAPE FULL.
	SKP
DTER16	TAD DLIT2		/BUFFER OVERFLOW
			/DECTAPE FULL
DTER14	TAD DLIT2		/DTA DIRECTORY FULL-NOT USED **
			/FILE NOT FOUND-NOT USED **
DTER12	TAD DLIT2		/IRREC. DTFERR.MK.TIK,EOT DURING TRANSFER
			/.SEEK OR .ENTER NOT EXECUTED-NOT USED **
DTER10	TAD DLIT2		/FILE STILL ACTIVE-NOT USED
			/ILLEG. DATA MODE
	TAD DLIT6		/ILLEG.  HANDLER FUNCTION
DTM4	DZM DTUND
	JMP* DLIT4
/
/ .CLOSE FUNCTION.
/
DTCLOS	JMS DTIOU		/I/O UNDERWAY
	ISZ DTCLSW	/INIT. 777777
	JMP DTCLDN	/.CLOSE FINISHED--AC=777777
	LAC DTIOSW	/I OR O
	SNA!CLC
	JMP DTCLDN	/INPUT-RESET SWITCHES AND EXIT.
	LAC (-3		/OUTPUT - 2'S COMPL. OF WORD COUNT FOR EOF
	DAC DTUWC
	LAC DLIT5
	DAC DTTR
	LAC (DTEOFH	/LOAD PTR. TO EOF HEADERS MINUS ONE
	JMS DTWCS
	JMP DTBUSY	/GO HANG ON .CLOSE
DTCLDN	DAC DTCLSW	/RESET TO 777777
	LAC ENDSW	/IF DOING A CLOSE BECAUSE OUT OF AVAILABLE
	SZA		/DISK AREA, OUTPUT TERMINAL ERROR.
	JMP DTER15
	JMP DTFBK		/NORMAL EXIT
/
/ .WAIT FUNCTION.
/
DTWAIT	LAC DTCT		/WAIT DTF ROUTINE
	SNA		/1 IF .WAITR
	JMP DTFBK-1	/NO. HANG ON .WAIT
	LAC (700000	/LINK ETC.
	AND DTCALP
	DAC DTCALP
	LAC* DTARGP	/15 BIT BUSY ADDR.
	AND (77777
	XOR DTCALP
	ISZ DTARGP
	DAC DTCALP
	JMS DTIOU
DTFBK	DBR
	XCT .+1
	XCT .+1
	JMP* DTARGP	/NORMAL EXIT
/
/ UPDATE DISK UNIT STATUS WORD.
/
DTUPDT	0
	LAC DTIOSW
	RAL!CLL		/SAVE BIT 16 - DTIOSW
	DAC DTBUIL
	LAC DTNXBK
	SPA		/SKIP IF NOT SPEC. CASE -1.
	CLC		/777777 IN AC IF LESS THAN 0
	AND (7777		/MASK OFF 12 BITS
	RTL
	XOR DTBUIL	/LOAD BITS 4-15 WITH DTNXBK
	DAC DTBUIL
	LAC UNITNO	/LOAD BITS 0-2 WITH UNITNO.
	RTR; RTR
	XOR DTBUIL
DTLOAD	XX		/WILL BE A DAC DTMULP+DT UNIT #
	JMP* DTUPDT	/EXIT
 
/MULTIUNIT DECTAPE STATUS TABLE
/UNITNO, DTNXBK, DTIOSW INFORMATION STORED IN ONE WORD FOR EACH UNIT.
/BIT ASSIGNMENT FOR DT UNIT STATUS WORD:
/BITS 0-2 = ACTUAL UNIT BEING USED (UNITNO).
/BIT3=0 ALWAYS, BITS 4-15=DTNXBK(=7777 IF DTNXBK=-1),
/BIT16=DTIOSW(0=INPUT, 1=OUTPUT).
/INITIALLY BITS 4-15=1 ALL OTHERS=0
DTMULP=.
	.REPT 10
	37774
	.END
