	.TITLE DSKSAV
/COPYRIGHT 1970, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
	.ABS
	.LOC 1000
BUFFER	0		/6K BUFFER AREA
	.LOC 16000
/
/ V2A   5-28-70	(EDIT1)
/M. SIFNAS 7-1-68
/RB09 DISK SAVE AND RESTORE UTILITY PGM.
/FROM DISK TO DECTAPE (UNIT 0,1,2,4,5,6)
/TO DISK FROM DECTAPE
/DTA UNIT 0=DISK TK0, SEC 0 TO TK28, SEC 64
/	1=DSK TK30,SEC 0 TO TK58, SEC 64
/	2=	60	0	88,	64
/	4=	100,	0	128,	64
/	5=	130,	0	158,	64
/	6=	160,	0	188,	64
/
/
/OPERATING PROCEDURES
	/ACS0 = 1 = DISK TO DECTAPE
	/ACS0 = 0 = DECTAPE TO DISK
	/ACS15-17 = UNIT# (3,7,=ILLEGAL)
/AFTER LOADING, DSKSAV ISSUES CR TO TELETYPE
/AND STOPS TO ALLOW SWITCH SETTINGS
/TO OPERATE, SET AC SWITCHES AND HIT CONTINUE
/AT OCCURRENCE OF EITHER DISK
/OR DECTAPE ERROR PRINTOUT
/1) HIT CONTINUE TO RESTART OR
/2) SET ACS0-17 = 0 TO RETRY
CLOF=700004
KRB=700312
KSF=700301
TCF=700402
TLS=700406
TSF=700401
/
DSKBEG	CLOF
	CAF
	IOF
	JMS ERMSG
	.DSA TITLE	/PRINT DSKSAV
DPRACS	JMS ERMSG	/OUTPUT DIRECTIONS ONCE ONLY
	.DSA ACS00
	JMS ERMSG
	.DSA ACS01
	JMS ERMSG
	.DSA ACS15
	LAC (JMP DHALT
	DAC DPRACS
DHALT	HLT
	LAC .DT2	/(JMS .IOCLR
	DAC .DT1
DSKBGB	CLA!OAS		/READ ACS
	DAC SAVACS#
	SMA		/DISK TO DECTAPE
	JMP DTDSK		/DECTAPE TO DISK
	LAC (JMP .KTBEG
	DAC INJMP
	DAC .KSTOP+1	/ERROR RESTART
	LAC (JMP .DTOUT
	DAC .DSTOP+1
	JMP DTDSK2
/
DTDSK	LAC (JMP .DTBEG
	DAC INJMP
	DAC .DSTOP+1
	LAC (JMP .KTOUT
	DAC .KSTOP+1
DTDSK2	DAC OUTJMP
	LAC SAVACS	/GET UNIT#
	RTR
	RTR
	AND (700000
	SAD (700000
	JMP DTDSK3	/UNIT 7 ILLEGAL
	SAD (300000
	SKP		/UNIT 3 ILLEGAL
	JMP DTDSK4
DTDSK3	JMS ERMSG
	.DSA BUNIT
	JMP DSKBEG
DTDSK4	DAC DUNIT
	XOR (21000
	DAC .DTSRC
	DAC .KTSRC
	DZM .DTBLK	/INIT B2# TO 0
	DZM .KTBLK
	LAW -14000	/6K TRANSFER
	DAC .DTWC		/WC
	DAC .KTWC
	LAC (BUFFER-1
	DAC .DTCA		/CA-1
	DAC .KTCA
	LAW -30		/24 SETS OF 24 256WD BLOCKS
	DAC BCOUNT#
TRAN	LAC (INJMP+1
	DAC 105
	LAW -4
	DAC DTERCT#	/ERROR TRY COUNTS
	DAC DKERCT#
INJMP	XX		/JMP .DTBEG OR JMP .KTBEG
	LAC (OUTJMP+1
	DAC 105
OUTJMP	XX		/JMP .DTOUT OR JMP ,KTOUT
	ISZ BCOUNT
	SKP
	JMP DSKBEG	/DONE - LOOK FOR NEXT UNIT
	LAC .DTBLK
	TAD (30
	DAC .DTBLK
	DAC .KTBLK
	JMP TRAN		/NEXT TRANSFER
	.EJECT

/CR,LF SUBR
CRLF	0
	LAW 15		/CR
	TLS
	TSF
	JMP .-1
	TCF
	LAW 12		/LF
	TLS
	TSF
	JMP .-1
	JMP* CRLF
/DECTAPE ERROR
DTERR	0
	ISZ DTERCT	/ERROR TRY COUNT
	JMP* DTERR
	DAC DTSTAT#
	JMS ERMSG
	.DSA DTERM
	LAC DTSTAT#
	HLT		/AC=DECTAPE STATUS B
	CLA!OAS
	SZA!CLC		/IF ACS=0, TRY ONCE MORE
	JMP DSKBGB	/BEGIN AGAIN
	DAC DTERCT	/SET COUNT TO HALT NEXT TIME
	JMP* DTERR
/DISK ERROR
DSKERR	0
	ISZ DKERCT
	JMP* DSKERR
	DAC DKSTAT#
	JMS ERMSG
	.DSA DKERM
	LAC DKSTAT
	HLT
	CLA!OAS
	SZA!CLC		/IF ACS=0, TRY ONCE MORE
	JMP DSKBGB	/BEGIN AGAIN
	DAC DKERCT	/SET COUNT TO HALT NEXT TIME
	JMP* DSKERR
	.EJECT
/ERROR MESSAGE PRINTOUT
ERMSG	0
	LAC* ERMSG	/PICK UP MSG POINTER
	ISZ ERMSG
	DAC ERMSGP#
	LAC* ERMSGP
	ISZ ERMSGP
	DAC ERMWC#

ERMSGB	LAC* ERMSGP
	ISZ ERMSGP
	TLS
	TSF
	JMP .-1
	TCF
	ISZ ERMWC
	JMP ERMSGB
	JMS CRLF
	JMP* ERMSG
TITLE=.
	TITLE-TITLND+1	/-WC
	104		/D
	123		/S
	113		/K
	123		/S
	101		/A
	126		/V
	40		/SPACE
	126		/V
	62		/2
	101		/A
TITLND=.
	.EJECT
ACS00=.
	ACS00-ACS00N+1	/-WC
	101		/A
	103		/C
	123		/S
	60		/0
	75		/=
	60		/0
	75		/=
	104		/D
	105		/E
	103		/C
	124		/T
	101		/A
	120		/P
	105		/E
	40		/SPACE
	124		/T
	117		/O
	40		/SPACE
	104		/D
	111		/I
	123		/S
	113		/K
ACS00N=.
ACS01=.
	ACS01-ACS01N+1	/-WC
	101		/A
	103		/C
	123		/S
	60		/0
	75		/=
	61		/1
	75		/=
	104		/D
	111		/I
	123		/S
	113		/K
	40		/SPACE
	124		/T
	117		/O
	40		/SPACE
	104		/D
	105		/E
	103		/C
	124		/T
	101		/A
	120		/P
	105		/E
ACS01N=.
ACS15=.
	ACS15-ACS15N+1	/-WC
	101		/A
	103		/C
	123		/S
	61		/1
	65		/5
	55		/-
	61		/1
	67		/7
	75		/=
	125		/U
	116		/N
	111		/I
	124		/T
	40		/SPACE
	60		/0
	54		/,
	61		/1
	54		/,
	62		/2
	54		/,
	64		/4
	54		/,
	65		/5
	54		/,
	66		/6
ACS15N=.
	.EJECT
DTERM=.
	DTERM-DTRMND+1		/-WC
	104		/D
	105		/E
	103		/C
	124		/T
	101		/A
	120		/P
	105		/E
	40		/SPACE
	105		/E
	122		/R
	122		/R
	117		/O
	122		/R
DTRMND=.
DKERM=.
	DKERM-DKRMND+1	/-WC
	104		/D
	111		/I
	123		/S
	113		/K
	40		/SPACE
	105		/E
	122		/R
	122		/R
	117		/O
	122		/R
DKRMND=.
BUNIT=.
	BUNIT-UNITND+1	/-WC
	125		/U
	116		/N
	111		/I
	124		/T
	40		/SPACE
	105		/E
	122		/R
	122		/R
	117		/O
	122		/R
UNITND=.
	.EJECT
/M. SIFNAS 1-5-68
/PDP-9 ADVANCED SOFTWARE DISK BOOTSTRAP
/SPECIAL VERSION TO CONVERT DECTAPE
/UNITS 0-2 AND 4-6 TO TRACK AND SECTOR ADDRESSES
/DTA0 = TK0, SECT. 0 (SIDE 1)
/DTA1 = TK30, SECT. 0 (SIDE 1)
/DTA2 = TK60, SECT. 0 (SIDE 1)
/DTA3 IS MAPPED INTO DTA1
/DTA4 = TK0, SECT 0 (SIDE 2)
/DTA5 = TK30, SECT 0 (SIDE 2)
/DTA6 = TK60, SECT 0 (SIDE 2)
/DTA7 IS MAPPED INTO DTA5
/
/IF ENTERED VIA .DTBEG OR .DTOUT, 5 CELLS MUST BE SET:
	/.DTBLK = LOGICAL DISK BL# (0-1077) WHERE 1 BL. = 256 WDS
	/.DTCA = CORE ADDRESS -1
	/.DTWC = -WC (2'S COMP) TO BE TRANSFERED
	/.SCOM+5 = START ADDR. WHEN LOAD COMPLETE
	/.DTSRC = UNIT #(0-2)
/
.SCOM=100
DSLW=707124
DSLM=707142
DSLD=707104
DSCS=707141
DSLS=707144
DSSF=707121
DSRS=707132
/
/
/NON RESIDENT CELLS
/
TRACK	0		/TEMP
SECTOR	0		/TEMP
.KUNIT	0		/CONVERTED UNIT #
.KTBLK	0		/LOGICAL BL# (0-3777)
.KTCA	0		/CORE ADDR -1
.KTWC	0		/2'S COMP WC
OCTN	0		/TEMP.
HOD	0		/TEMP
.KTSRC	0		/VESTGIAL REG. (FROM DTA BOOTSTRAP)
.KTTR	0		/READ OR WRITE STATUS BITS
/
	.EJECT
/RESIDENT DISK BOOTSTRAP
.L3000	30000
.L002	2000
.L003	3000
.LM24	777754
.L12	12
.L24	24
.L1	1
/
/FOR NON-KM9 LOAD, START AT .DTBEG
.KTBEG	LAC .L002		/(2000 = READ, GO
	SKP!STL		/SET LINK FOR DISK SIDE INIT
/FOR OUTPUT, START AT .DTOUT
.KTOUT	LAC .L003		/(3000 = WRITE, GO
	DAC .KTTR
	STL
	EEM+10		/ENTER EXT. MEM. + CLEAR AC
	RTR		/AC = 0, L = 1
	DAC .KUNIT		/200000
	LAC .KTSRC		/UNIT 3 MAPPED INTO 1,7 INTO 5
	SMA!RTL		/UNIT 4-6
	DZM .KUNIT	/UNIT 0-2
	SNL!RAL		/UNIT 2 OR 6
	SZL!CLA!STL	/UNIT 0 OR 4
	LAC .L3000	/2,6
	SNL		/0,4
	TAD .L3000	/1,5
	JMP .+3
/
	.EJECT
.KSTOP	JMS DSKERR
	XX
	TAD .KUNIT
	DAC .KUNIT
	LAC .KTWC
	DSLW		/LOAD WC
	LAC .KTCA
	TAD .L1		/LOAD CA
	DSLM
/
/DAVE LENEY 2-17-67
/DISK TRACK AND SECTOR ENCODER
/CONVERTS LOGICAL BLOCK # (OCTAL)
/FROM 0-3777 TO BCD TRACK AND SECTOR ADDRESS
/WHERE 1 BLOCK = 256 WDS OR 4 DISK SECTORS
/
	LAC .KTBLK	/LOGICAL BL#
	DZM TRACK		/COMPUTE BCD TRACK AND SECTOR ADDR.
FINDT	TAD .LM24		/-20 (20 256 WD BLOCK PER TRACK)
	SPA!STL
	JMP FINDS		/TRACK FOUND
	ISZ TRACK
	JMP FINDT		/STILL LOOKING
FINDS	TAD .L24		/20 (GO BACK 1)
	RTL
	JMS .TOBCD	/CONVERT SECTOR TO BCD
	DAC SECTOR	/TEMP
	LAC TRACK
	JMS .TOBCD	/CONVERT TRACK TO BCD
	RTL
	RTL
	RTL
	RTL
	XOR SECTOR
	TAD .KUNIT
	DSLD		/LOAD SECTOR AND TRACK ADDR.
	LAC .KTTR		/LOAD STATUD (READ OR WRITE)
	DSCS!DSLS
	DSSF!DSRS		/SKIP ON FLAGS AND READ STATUS
	JMP .-1
	SPA
	JMP .KSTOP	/ERROR FLAG UP
	LAC* .L105	/DONE EXIT THROUGH BANK0, 105
	DAC .TOBCD
	CAF
	JMP* .TOBCD
/
	.EJECT
/DAVE LENEY 2-17-67
/ROUTINE TO CONVERT OCTAL NUMBER IN
/AC TO A BCD NUMBER IN AC
/OCTAL NUMBER MUST BE LESS THAN 144
/CALLING SEQUENCE
/	JMS .TOBCD
/	(RETURN)
/
.TOBCD	0		/COMPLEMENT FOR COUNTER
	CMA
	DAC OCTN
	DZM HOD		/-1 TO HIGH ORDER DIGIT
	SKP
	ISZ HOD		/INCREMENT HIGH ORDER DIGIT
	CLA!CLL
/
NXT	ISZ OCTN
	JMP .+2
	JMP PACK		/ALL DONE
	TAD .L1
	SAD .L12		/OVERFLOW
	JMP NXT-2
	JMP NXT
PACK	RTR		/E TIMES
	RTR
	XOR HOD		/COMBINE DIGITS
	RTL		/4 TIMES
	RTL
	JMP* .TOBCD		/EXIT
	.EJECT
/M. SIFNAS 7-26-67
/PDP-9 ADV. S. S. DECTAPE BOOTSTRAP .UNIT 0
/IF ENTERED VIA .DTBEG OR.DTOUT, 5 CELLS MUST BE SET--
/.DTBLK=STARTING BLOCK# OF AREA TO BE LOADED
/.DTCA=CA-1 OF CORE AREA TO BE LOADED
/.DTWC=-WC (2'S COMP) OF CORE AREA TO BE LOADED
/.DTSRC=UNIT(0-2)+21000
/.SCOM+5=START ADDR. WHEN LOAD COMPLETE
/NON-RESIDENT CELLS
DTCA=707541
DTDF=707601
DTEF=707561
DTRB=707572
DTXA=707544
.DTBLK	0		/REQUESTED BLOCK#
.DTCA	0		/CORE ADDR.-1
.DTWC	0		/2'S COMP. W.C.
.DTDIR	0		/SEARCH DIRECTION SWITCH
			/+=FORWARD,-=REVERSE
.DTBLC	0		/BLOCK # BEING SEARCHED FOR
.SCOM=100
.DTSRC	21000		/UNIT (0-2)+21000
.DTTR	0		/READ OR WRITE STATUS A BITS
/RESIDENT DTA BOOTSTRAP
.DTBEG	LAC	.L013	/READ
	SKP
.DTOUT	LAC	.L015	/WRITE
	DAC	.DTTR
.DT1	JMS	.IOCLR	/CLEAR I/O
	LAC .L06	/MOVE REVERSE TO BOT.
	XOR DUNIT
	JMS .DRUN	/XCT DTA IOT AND FLAG WAIT.
	RTL
	SMA!RTR	/EOT -- OK, START SEARCH.
	JMP .DSTOP	/OTHER DECTAPE ERROR.
	LAC (JMP .DT2
	DAC .DT1
.DT2	JMS .IOCLR
	LAC	.DTCA	/SET CA-1
	DAC*	.DK931
	DZM*	.DK930	/CLEAR WC FOR SEARCH
	DZM	.DTDIR	/DIREC. SWITCH=FORWARD(+)
	LAC	.DSMA	/SMA!CLA FOR FORW. SEARCH
	DAC	.DCHKC
	LAC	.DTBLK
	DAC	.DTBLC	/SET SEARCH BLOCK
	.EJECT
/FOR .SAVE NEXT INSTR. SHOULD BE LAC .DTSRC
	LAC	.DTSRC	/SEARCH FORW., N.M.
.DTBGA	JMS	.DRUN
	SMA		/DTA ERR. DURING SEARCH
	JMP	.DCHKB	/CHECK BL#
.DSTOP	JMS DTERR
	XX
/IF ERROR OCCURRED WHEN ENTERED VIA .DTBEG
/CONT. SWITCH SHOULD NOT BE USED
/INSTEAD, .DTBEG IN ADDR. SWITCHES, I/O RESET, START
/BLOCK #CHECK
.DCHKB	LAC*	.DTCA	/BLK. # JUST READ
	SAD	.DTBLC	/" " " SEARCHED FOR
	JMP	.DCHKF	/MAYBE-CHECK DIRECTION
	SNA!CMA
	JMP	.DSTOP	/BLK.#0 REQUESTED AND NOT FOUND
	TAD	.DTBLC	/BLK.# SEARCHED FOR-BLK#READ
.DCHKC	SMA!CLA		/OVERSHOOT-FORW.,SPA!CLA-REVERSE
	JMP	.DTBGA	/CONT. SEARCH, SAME DIRECTION
	LAC	.DTDIR	/FORWARD?
.DSMA	SMA!CLA		/NO-REV
	LAW	17776	/-2
	DAC	.DTDIR	/FLIP DIRECT. SWITCH
.DCHKD	TAD	.DTBLK	/REQUESTED BLK#-2 IF REVERSE
	DAC	.DTBLC	/INTO BLOCK# TO SEARCH FOR
	LAC	.DCHKC	/SWITCH SKIP SENSE
	XOR	.L001	/SMA!CLA OR SPA!CLA (REVERSE)
	DAC	.DCHKC
	LAC	.L04	/REVERSE SEARCH DIRECTION
	JMP	.DTBGA
/BLOCK # FOUND
.DCHKF	LAC	.DTDIR	/FORWARD SEARCH?
	SPA!CLA
	JMP	.DSMA+2	/NO-REVERSE AGAIN
/LOAD CORE
.DRED	LAC	.DTWC	/SET WC(CELL 30) FOR LOAD
	DAC*	.DK930
/FOR .SAVE NEXT INSTR. SHOULD B LAC .DTTR
	LAC	.DTTR	/READ OR WRITE  FORW., CM
	JMS	.DRUN
	SPA		/DATA OK
	JMP	.DSTOP
	CAF		/CLEAR GO BIT
	LAC*	.L105
	DAC	.DRUN
	JMP*	.DRUN	/EXIT (KM-9 OR USER START ADDR)
	.EJECT
/I/O CLEAR SUBR.
.IOCLR	0
	EEM		/ENTER EXTEND MODE
	CAF		/CLEAR ALL FLAGS
	IOF+10		/PI OFF
	ISA		/API OFF
	DTCA		/CLEAR DTA STATUS A
	JMP*	.IOCLR
/XCT DTA IOT AND FLAG CHECK
/.DRUN ALSO USED DO TEMP. STORE STATUS B
.DRUN	0
	DTXA		/AC XOR STATUS A
	DTEF!DTRB		/ERR. FLAG
	SKP!CLA
	JMP*	.DRUN	/EXIT-ERR., AC=TATUS B
	DTDF		/DONE FLAG
	JMP	.-4
	JMP*	.DRUN	/OK EXIT
.LITCA	77		/FIRST KM-9 CELL TO LOAD-1
.LITWC	761000		/WC (KM-9): 100-17100
.DK930	30		/ABS. LOC 30=DTA WC
.DK931	31		/ABS. LOC 31=DTA CA
.L06	060000
.L021	021000
.L001	001000
.L04	040000
.L013	013000
.L015	015000
.L105	105
DUNIT	0
	.END	DSKBEG
