/2 TD8E INITIALIZER PROGRAM, V7A
/
/
/
/
/
/
//
/
/
/
/
/COPYRIGHT (C) 1975, 1977
/DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
/
/
/
/THIS SOFTWARE IS FURNISHED UNDER A LICENSE FOR USE ONLY ON A
/SINGLE COMPUTER SYSTEM AND MAY BE COPIED ONLY WITH THE INCLU-
/SION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE, OR ANT OTHER
/COPIES THEREOF, MAY NOT BR PROVIDED OR OTHERWISE MADE AVAILABLE
/TO ANY OTHER PERSON EXCEPT FOR USE ON SUCH SYSTEM AND TO ONE WHO
/AGREES TO THESE LICENSE TERMS.  TITLE TO AND OWNERSHIP OF THE
/SOFTWARE SHALL AT ALL TIMES REMAIN IN DEC.
/
/
/THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT
/NOTICE AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL
/EQUIPMRNT COROPATION.
/
/DEC ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF ITS
/SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DEC.
/
/
/
/
/
/

/DECEMBER 21, 1973		GB/RL/EF/SR

/ABSTRACT--
/	THE ROUTINE DESCRIBED AND LISTED HERE IS A GENERAL
/DATA HANDLER FOR THE TD8E DECTAPE SYSTEM. THE ROUTINE
/CONTAINS SEARCH, READ, AND WRITE FUNCTIONS IN A FORMAT
/WHICH IS COMPATIBLE WITH OS/8 DEVICE HANDLER CALLING
/SEQUENCES.

/	EXPLANATION:

/THIS IS A SAVE FILE, WHICH MUST BE PLACED AS FILE # 1
/ON THE OS/8 BINARIES TAPE.  (I.E. BLOCK 7)
/FOLLOWING IT MUST BE THE FOLLOWING FILES, EACH 50 (DEC) BLKS LONG:
/TDROM.SY
/TD12K.SY
/
/TO CREATE SPECIAL BLOCK 0 FOR THAT TAPE, START THIS PROGRAM AT
/LOCATION 200 AND FOLLOW INSTRUCTIONS.

/TO THEN PERFORM THE INITIALIZATION FROM THE LIBRARY TAPES,
/MERELY PLACE THE BINARY TAPE ON UNIT 0 AND BOOTSTRAP INTO IT.
/THEN FOLLOW INSTRUCTIONS.

/FILES TDROM.SY AND TD12K.SY ARE MERELY SYSTEM HEADS OF THE
/APPROPRIATE SYSTEMS, THEY MAY CONTAIN ANY HANDLERS.

/THE BLOCK 0 SPECIAL SECONDARY BOOTSTRAP READS IN THE FIRST
/3 PAGES OF TDINIT (WORDS 200-777) AND BRANCHES TO 'STARTUP'.
/THIS THEN READS IN THE REMAINDER OF TDINIT WITH ERROR CHECKING.

/CODE LOC	BLOCK ON BINARY TAPE

/CCB		16,17		(THESE ARE DECTAPE BLOCK NUMBERS, NOT OS/8 RECORDS)
/0		20		SKIPPED BY BLOCK 0
/200		21
/400		22
/600		23
/1000		24
/1200		25
/1400		26
/1600		27
/2000		30
/2200		31	TDINIT MUST HAVE USEFUL PART END AT OS/8 RECORD  75
/7400		32,33	RECORD 15 CONTAINS IMAGE OF BLOCK 0

/FIXES SINCE FIELD-TEST RELEASE:

/1.	FIXED BUG RE CLA ON RETRY AFTER ERROR
/2.	ALLOWED FINAL BOOTSTRAP TO BE INTO A WRITE-LOCKED DEVICE

/OS/8 V3D CHANGES:

/3.	FIXED BUG RE TD8E BUILD (V6B PATCH)

/THIS ROUTINE CAN BE RE-EDITED AND ASSEMBLED TO PRODUCE
/VARIATIONS ON THE BASIC TD8E SYSTEM. ASSEMBLY PARAMETERS
/CONTROL:
/A) WHAT DRIVES (UNITS 0-7) WILL BE USED
/B) THE ORIGIN OF THE TWO PAGE ROUTINE
/C) WHAT MEMORY FIELD THE ROUTINE WILL RUN IN
/D) THE SIZE OF THE DECTAPE BLOCK TO BE READ/WRITTEN

/FOLLOWING ARE THE PARAMETERS SET UP FOR THE STANDARD
/DEC VERSION OF THIS ROUTINE:

	DRIVE=10	/UNITS 0 AND 1 SELECTED
	ORIGIN=400	/ENTER AT ORIGIN, ORIGIN+4
	AFIELD=0	/INITIAL FIELD SETTING
	MFIELD=00	/AFIELD*10=MFIELD
	WDSBLK=201	/129 WORDS PER BLOCK

/THE USE OF THE PARAMETERS IS AS FOLLOWS:

/ DRIVE: DRIVE DETERMINES WHICH UNITS WILL BE SELECTED
/	DRIVE=10 IMPLIES UNITS 0 &1
/	DRIVE=20 IMPLIES UNITS 2&3
/	DRIVE=30 IMPLIES UNITS 4&5
/	DRIVE=40 IMPLIES UNITS 6&7

/ORIGIN: ALTERING ORIGIN CAUSES ASSEMBLY IN A DIFFERENT
/	MEMORY LOCATION. WHEN CHANGING ORIGIN KEEP IN MIND
/THAT THIS IS A TWO PAGE ROUTINE.

/AFIELD: AFIELD DETERMINES THE INITIAL FIELD SETTING FOR THE
/	LOADER. PERMISSIBLE VALUES FOR AFIELD ARE 0 TO 7.

/MFIELD: MFIELD IS USED IN A CIF CDF MFIELD INSTRUCTION.
/	THE VALUE INSERTED FOR MFIELD SHOULD BE 10(8) TIMES
/	THE VALUE FOR AFIELD. THE PERMISSIBLE VALUES ARE 00-70.

/WDSBLK: WDSBLK GOVERNS HOW MANY WORDS THE ROUTINE THINKS ARE 
/	IN A DECTAPE BLOCK. THE STANDARD VALUE IS 201(8) OR
/	128 DECIMAL. NOTE THAT THE FUNCTION WORD BIT 10 CAN
/	BE USED TO SUBTRACT ONE FROM WDSBLK. THE VALUE USED
/	FOR WDSBLK SHOULD BE THE NUMBER OF WORDS THE TAPE WAS
/	FORMATTED TO CONTAIN.

/IF WE WANT A HANDLER FOR UNITS 2&3 TO RESIDE IN
/FIELD 2 AT LOCATION 3000 AND READ/WRITE 256(10) WORDS
/PER BLOCK, THE PARAMETERS WOULD BE:
/	DRIVE=20
/	ORIGIN=3000
/	AFIELD=2
/	MFIELD=20
/	WDSBLK=400
/THE CALL TO THE SUBROUTINE FOLLOWS BASICALLY THE
/CALLING SEQUENCE FOR OS/8 DEVICE HANDLERS.
/THE CALLING SEQUENCE IS:

/	CDF CURRENT
/	CIF MFIELD	/MFIELD=FIELD ASSEMBLED IN
/	JMS ENTRY	/ENTRY=ORIGIN (EVEN NUMBERED DRIVE
			/AND ORIGIN+4 FOR ODD NUMBERED DRIVE.
/	ARG1
/	ARG2
/	ARG3
/	ERROR RETURN
/	NORMAL RETURN

/THE ARGUMENTS ARE:

/ARG1: FUNCTION WORD	BIT0: 0=READ, 1=WRITE
/			BITS 1-5: # BLOCKS IN OPERATION
/			BITS 6-8: FIELD OF BUFFER AREA
/			BIT 9: UNUSED
/			BIT 10: # OF WORDS/BLOCK.
/			0= WDSBLK, 1=WDSBLK-1
/			BIT 11: 1=START FORWARD, 0=REVERSE

/ARG2: BUFFER ADDRESS FOR OPERATION
/ARG3: STARTING BLOCK FOR OPERATION

/ERRORS: THE HANDLER DETECTS TWO TYPES OF ERRORS:
/A) FATAL ERRORS- PARITY ERROR, TIMING ERROR,
/		TOO GREAT A BLOCK NUMBER
/	FATAL ERRORS TAKE ERROR RETURN WITH THE
/	AC=4000.
/B) NON-FATAL- SELECT ERROR.
/	IF NO PROPER UNIT IS SELECTED, THE ERROR
/	RETURN IS TAKEN WITH CLEAR AC.
/FATAL ERRORS TRY THREE TIMES BEFORE TAKING ERROR RETURN.
/THE NORMAL RETURN IS TAKEN AFTER ALL INDICATED
/BLOCKS HAVE BEEN TRANSFERRED. THE AC IS CLEAR.

/THE TD8E IOT'S ARE:
	SDSS=7001-DRIVE	/SKIP ON SINGLE LINE FLAG
	SDST=7002-DRIVE	/SKIP ON TIMING ERROR
	SDSQ=7003-DRIVE	/SKIP ON QUAD LINE FLAG
	SDLC=7004-DRIVE	/LOAD COMMAND REGISTER
	SDLD=7005-DRIVE	/LOAD DATA REGISTER
	SDRC=7006-DRIVE	/READ COMMAND REGISTER
	SDRD=7007-DRIVE	/READ DATA REGISTER

/THE IOT'S IN GENERAL ARE 677X,676X,675X,AND 674X.
/THE OTHERS CONTROL UNITS 2-7.
	INITLN=7	/LENGTH OF TDINIT INCLUDING BLOCK 0 IMAGE (IN BLOCKS)
	CTRLO=20
	INCHAR=21
	TEMPA=22

ST,	CLA		/IN CASE CHAINED TO
	JMP I (CREATE	/CREATE BLOCK 0  -IN HOUSE ONLY -
STARTUP,JMS I (DTA0	/TD8E S.R. IS IN 200 NOW
	603		/READ 3 BLOCKS INTO 1000-2377
	1000
	24		/GET REST OF INIT
	JMP FERR	/REALLY BAD!
	TAD (SKP CLA
	DCA ST		/ALLOWS HIM TO RESTART AT 200
RE,	JMS MSG
	VNO
	JMS I (CHKCOR	/USE ROM OR 12K SYSTEM
	JMS MSG
	INIT
	JMS I (MOVSYS
	JMS MSG
	SWTCH
	JMS TTY		/PAUSE
	TAD INCHAR
	TAD (-32
	SNA CLA
	JMP I (ZERO	/HE TYPED ^Z
CPY,	JMS MSG
	COPY
	TAD (160
	DCA B1
	TAD (160
	DCA B2
RD,	JMS I (DTA0
	3612
	0
B1,	0
	JMS I (ER1
	JMS I (DTA1
	7612
	0
B2,	0
	JMS I (ER1
	TAD B1
	TAD (36
	DCA B1
	TAD B1
	DCA B2
	TAD B1		/COPY OVER ABOVE 2700
	TAD (-2600	/***
	SPA CLA
	JMP RD		/KEEP GOING
	JMS I (DTA0	/COPY DIRECTORY
	1412
	0
	2
	JMS I (ER1
	JMS I (DTA1
	5412
	0
	2
	JMS I (ER1
RESTRT,	JMS MSG
	DISMNT		/SETUP TAPES FOR INIT
	JMS TTY
	JMP I (BOOT
TTY,	0
	JMS MSG
	STRIKE
	KCC
	KSF
	JMP .-1
	KRB
	AND (177
	DCA INCHAR
	JMP I TTY

MSG,	0		/MESSAGE TYPER
	DCA CTRLO
	JMS I (CRLF
	TAD I MSG
	DCA TEMPA
	ISZ MSG
WTMSG,	TAD I TEMPA
	CLL RTR;RTR;RTR
	JMS PNCH
	TAD I TEMPA
	JMS PNCH
	ISZ TEMPA
	JMP WTMSG

PNCH,	0
	AND (77
	SNA		/IGNORE NULL. _ MEANS CR/LF
	JMP I PNCH	/? MEANS TERMINATE
	TAD (-37	/IS IT _?
	SNA
	JMS I (CRLF	/YES
	TAD (-40	/MAYBE ?
	SNA
	JMP I MSG
	TAD (40
	SPA
	TAD (100
	TAD (237
	JMS I (TTYOUT
	JMP I PNCH
FERR,	HLT
	CLA
	JMP STARTUP
	PAGE
/	THIS HANDLER USES DECTAPE BLOCKS NOT OS/8 BLOCKS !

	*ORIGIN

DTA0,	0		/ENTRY POINT FROM UNIT 0
	CLA CLL		/0 TO LINK
	JMP DTA1X
C1000,	1000
BLOCK,
DTA1,	0		/UNIT 2 ENTRY
	CLA CLL CML	/1 TO LINK
	TAD DTA1
	DCA DTA0	/PICK UP ARGS AT DTA0
DTA1X,	RAR
	DCA UNIT	/LINK TO UNIT POSITION
	RDF
	TAD C6203	/GET DATA FIELD AND SETUP RETURN
	DCA LEAVE
	TAD I DTA0	/GET FUNCTION WORD
	SDLD		/PUT FUNCTION INTO DATA REGISTER
	CLL RTR		/AC STILL HAS FUNCTION. PUT # WORDS PER
			/BLOCK INTO LINK
	SZL CLA		/KNOCK ONE OFF WDSBLK?
	IAC 		/YES
	TAD MWORDS
	DCA WCOUNT	/STORE MASTER WORD COUNT
	ISZ DTA0	/TO BUFFER
	TAD I DTA0
	DCA BUFF
	ISZ DTA0	/TO BLOCK NUMBER
	TAD I DTA0
	DCA BLOCK
	ISZ DTA0	/POINT TO ERROR EXIT
	CIF CDF MFIELD	/TO ROUTINES DATA FIELD
	SDRD		/GET FUNCTION INTO AC
	CLL RAL
	AND CM200	/GET # PAGES TO XFER
	DCA PGCT
	SDRD
C374,	AND C70		/GET FIELD FOR XFER
	TAD C6203	/FORM CDF N
	DCA XFIELD	/IF=0 AND DF=N AT XFER.
	CLA CLL CMA RTL
	DCA TRYCNT	/3 ERROR TRIES
	TAD UNIT	/TEST FOR SELECT ERROR
	SDLC
	SDRC
	AND C100
	SZA CLA
	JMP FATAL-1
	SDRD		/PUT FUNCT INTO XFUNCT IN SECOND PG.
	DCA I CXFUN
	TAD WCOUNT
	DCA I CXWCT
	SDRD		/GET MOTION BIT TO LINK
	CLL RAR
	JMP GO		/AND START THE MOTION.
RWCOM,	SDST		/ANY CHECKSUM ERRORS?
	SZA CLA		/OR CHECKSUM ERRORS?
	JMP TRY3	/PLEASE NOTE THAT THE LINK IS ALWAYS
			/SET AT RWCOM. GETCHK SETS IT.
	TAD PGCT	/NO ERROR..FINISHED XFER?
	TAD CM200
	SNA
	JMP EXIT	/ALL DONE. GET OUT
	DCA PGCT	/NEW PAGE COUNT
	ISZ BLOCK	/NEXT BLOCK TO XFER
	TAD WCOUNT	/FORM NEXT BUFFER ADDRESS
	CIA
	TAD BUFF
	DCA BUFF
	CLL CML		/FORCES MOTION FORWARD
GO,	CLA CML RTR	/LINK BECOMES MOTION BIT
	TAD C1000
	TAD UNIT	/PUT IN 'GO' AND UNIT #
	SDLC		/LOOK FOR BLOCK NO.
	JMS I CRDQUD	/WAIT AT LEAST 6 LINES TO LOOK
	JMS I CRDQUD
CM200,	7600		/COULD HAVE SAVED A LOC. HERE
SRCH,	SDSS
	JMP .-1		/WAIT FOR SINGLE LINE FLAG
	SDRC
	CLL RTL		/DIRECTION TO LINK. INFO BITS 
			/ARE SHIFTED.
	AND C374	/ISOLATE MARK TRACK BITS
	TAD M110	/IS IT END ZONE?
	SNA		/THE LINK STAYS SAME THRU THIS
	JMP ENDZ
	TAD M20		/CHECK FOR BLOCK MARK
	SZA CLA
	JMP SRCH
	SDRD		/GET THE BLOCK NUMBER
	SZL		/IF WE ARE IN REVERSE, LOOK FOR 3
			/BLOCKS BEFORE TARGET BLOCK. THIS
			/ALLOWS TURNAROUND AND UP TO SPEED.
	TAD C3		/REVERSE
	CMA
	TAD BLOCK
	CMA		/IS IT RIGHT BLOCK?
	SNA
	JMP FOUND	/YES..HOORAY!
M110,	SZL SNA CLA	/NO, BUT ARE WE HEADED FOR IT?
			/ABOVE SNA IS SUPERFLUOUS.
	JMP SRCH	/YES
ENDZ,	SDRC		/WE ARE IN THE END ZONE
	CLL RTL		/DIRECTION TO LINK
	CLA		/ARE WE IN REVERSE?
	JMP GO		/YES..TURN US AROUND
/IF WE ARE IN THE END ZONE GOING FORWARD, IT IS AN ERROR
TRY3,	CLA
	ISZ TRYCNT
	JMP GO		/TRY 3 TIMES
	JMP FATAL		/LINK OFF MEANS AC=4000 ON RETURN
EXIT,	ISZ DTA0
	CLL CML		/AC=0 ON NORMAL RETURN
FATAL,	TAD UNIT
	SDLC		/STOP THE UNIT
	CLA CML RAR
LEAVE,	HLT
	JMP I DTA0

C6203,	6203
CRDQUD,	RDQUAD
WCOUNT,	0
BUFF,	0
MWORDS,	-WDSBLK
UNIT,	0
CXFUN,	XFUNCT
M20,	-20
PGCT,	0
CXWCT,	XWCT
C100,	100
TRYCNT,	-3


	*ORIGIN+170
FOUND,	SZL CLA		/RIGHT BLOCK. HOW ABOUT DIRECTION?
	JMP GO		/WRONG..TURN AROUND
	TAD UNIT	/PUT UNIT INTO LINK
	CLL RAL		/AC IS NOW 0
C70,	70		/********DON'T MOVE THIS!!!!******
C3,	3
	TAD BUFF	/GET BUFFER ADDRESS
XFIELD,	HLT		/INTO NEXT PAGE
	*ORIGIN+200
	CIF MFIELD
	DCA XBUFF	/SAVE ADDRESS
	RAR		/NOW GET UNIT #
	DCA XUNIT
	SDRC
	SDLC
REVGRD,	SDSS
	JMP .-1		/LOOK FOR REVERSE GUARD
	SDRC
	AND K77
	TAD CM32	/IS IT REVERSE GUARD?
	SZA CLA
	JMP REVGRD	/NO.KEEP LOOKING
	TAD XWCT
	DCA WORDS	/WORD COUNTER
	TAD XFUNCT	/GET FUNCTION  READ OR WRITE
K7700,	SMA CLA
	JMP READ	/NEG. IS WRITE
WRITE,	SDRC
	AND C300	/CHECK FOR WRITE LOCK AND SELECT ERROR
	CLL CML		/LOCK OUT AND SELECT ARE AC 0 ERRORS
	SZA CLA
	JMP I CFATAL	/FATAL ERROR. LINK MUST BE ON
	JMS RDQUAD	/NO ONE EVER USES THIS WORD!
C7600,	7600
	TAD C1400
	TAD XUNIT	/INITIATE WRITE MODE
	SDLC
	CLA CMA
	JMS WRQUAD	/PUT 77 IN REVERSE CHECKSUM
	CLA CMA
	DCA CHKSUM
WRLP,	TAD I XBUFF	/GLORY BE! THE ACTUAL WRITE!
	JMS WRQUAD
	ISZ XBUFF	/BUMP CORE POINTER
K77,	77		/ABOVE MAY SKIP
	ISZ WORDS	/DONE THIS BLOCK?
	JMP WRLP	/NOT YET..LOOP A WHILE
	TAD XFUNCT	/IS THE OPERATION FOR WDSBLK PER BLOCK?
	CLL RTR		/IF NO, WRITE A 0 WORD
	SZL CLA
	JMS WRQUAD	/WRITE A WORD OF 0
	JMS GETCHK	/DO THE CHECK SUM
	JMS WRQUAD	/WRITE FORWARD CHECKSUM
	JMS WRQUAD	/ALLOW CHECKSUM TO BE WRITTEN
	JMP I CRWCOM
READ,	JMS RDQUAD
	JMS RDQUAD
	JMS RDQUAD	/SKIP CONTROL WORDS
	AND K77
	TAD K7700	/TACK 7700 ONTO CHECKSUM.
	DCA CHKSUM	/CHECKSUM ONLY LOW 6 BITS ANYWAY
RDLP,	JMS RDQUAD
	JMS EQUFUN	/COMPUT CHECKSUM AS WE GO
	DCA I XBUFF	/IT GETS CONDENSED LATER
	ISZ XBUFF
C300,	300		/PROTECTION
	ISZ WORDS	/DONE THIS OP?
	JMP RDLP	/NO SUCH LUCK
	TAD XFUNCT	/IF OP WAS FOR WDSBLK-1, READ AND
	CLL RTR		/CHECKSUM THE LAST TAPE WORD
	SNL CLA
	JMP RDLP2
	JMS RDQUAD	/NOT NEEDED FOR WDSBLK/BLOCK
	JMS EQUFUN	/CHECKSUM IT
RDLP2,	JMS RDQUAD	/READ CHECKSUM
	AND K7700
	JMS EQUFUN
	JMS GETCHK	/GET SIX BIT CHECKSUM
	JMP I CRWCOM

WRQUAD,	0		/WRITE OUT A 12 BIT WORD
	JMS EQUFUN	/ADD THIS TO CHECKSUM
	SDSQ		/SKIP ON QUADLINE FLAG
	JMP .-1
	SDLD		/LOAD DATA  ONTO BUS
	CLA		/SDLD DOESN'T CLEAR AC
	JMP I WRQUAD

RDQUAD,	0		/READ A 12 BIT WORD
	SDSQ
	JMP .-1
	SDRD		/READ DATA
	JMP I RDQUAD

XUNIT,
EQUFUN,	0		/COMPUTE EQUIVALENCE CHECKSUM
	CMA
	DCA EQUTMP	/ACTUALLY CHECKSUMS ON DECTAPE ARE
	TAD EQUTMP	/EQUIVALENCE OF ALL WORDS IN A RECORD
	AND CHKSUM	/SIX BITS AT A TIME. BUT SINCE EQUIVALENCE
	CIA		/IS ASSOCIATIVE, WE CAN DO IT 12
	CLL RAL		/BITS AT A TIME AND CONDENSE LATER.
	TAD EQUTMP	/THIS ROUTINE USES THESE IDENTITIES:
	TAD CHKSUM	/A+B=(A.XOR.B)+2*(A.AND.B)
	DCA CHKSUM	/A.EQU.B=.NOT.(A.XOR.B)=A.XOR.(.NOT.B)
	TAD EQUTMP	/A.EQU.B=(A+(.NOT.B))-2*(A.AND.(.NOT.B))
	CMA
	JMP I EQUFUN

GETCHK,	0		/FORM 6 BIT CHECKSUM
	CLA
	TAD CHKSUM	
	CMA
	CLL RTL
	RTL
	RTL
	JMS EQUFUN
	CLA CLL CML	/FORCES LINK ON AT RWCOM
	TAD CHKSUM
	AND K7700
	JMP I GETCHK

CFATAL,	FATAL
CRWCOM,	RWCOM
XFUNCT,	0
CM32,	-32
C1400,	1400
CHKSUM,	0
WORDS,	0
XBUFF,	0
XWCT,	0
EQUTMP,	0
TBL,	CPY
	ZER
	LVAL
	PAGE
CREATE,	JMS I (MSG
	WRITOUT
	JMS I (TTY
	JMS I (DTA1
	4202
	7400
	0
	JMS ER1
	JMS I (MSG
	OK
	HLT
	JMP I (7605
	ROMSW=17

/THIS ROUTINE COPIES THE SYSTEM ONTO UNIT 1.
/IT COPIES FROM A SYSTEM HEAD FILE ON TAPE ON UNIT 0.
/UNIT 0 MUST BE THE OS/8 BINARIES TAPE
/1ST FILE: TDINIT.PA
/2ND FILE: TDROM.SY
/3RD FILE: TD12K.SY

MOVSYS,	0
	JMS I (TTY
	TAD ROMSW	/GET ADDRESS OF START OF SYSTEM HEAD
	SNA CLA
	TAD (62^2	/12 K
	TAD (7+INITLN^2	/ROM
	DCA HEAD
	JMS I (DTA0	/READ PAGE 0
	212
	0
HEAD,	HLT
	JMS ER1
	CDF 10
	TAD I (200
	CDF 0
	TAD (-4207	/CHECK FOR GOOD SYSTEM HEAD
	SZA CLA
	JMP WRGSYS
	JMS I (DTA1
	4212
	0
	0
	JMS ER1
	STL CLA RTL	/2
	TAD HEAD
	DCA KBM
	JMS I (DTA0
	0012		/READ 40 SYSTEM BLOCKS 7-26 (PAGES 16-55)
	0
KBM,	HLT
	JMS ER1
	JMS I (DTA1
	4012
	0
	7^2		/WRITE KBM ETC
	JMS ER1
	TAD HEAD
	TAD (43^2
	DCA CD
	JMS I (DTA0
	3613		/READ 51-67 (PAGES 122-157)
	0
CD,	HLT
	JMS ER1
	JMS I (DTA1
	7613
	0
	43+6^2
	JMS ER1
	JMP I MOVSYS
WRGSYS,	JMS I (MSG
	WRONG
	JMS I (TTY
	JMP I (CPY

ER1,	0
	CLA
	JMS I (MSG
	IOERR
	JMS I (TTY
	TAD I (INCHAR
	TAD (-101
	SNA CLA		/A?
	JMP I (RE	/YES, ABORT
	TAD ER1
	TAD (-5
	DCA ER1		/BACK UP, POINT TO CALL
	JMP I ER1	/RETRY

CRLF,	0
	TAD (215
	JMS TTYOUT
	TAD (212
	JMS TTYOUT
	JMP I CRLF

TTYOUT,	0
	DCA TM
	JMS I (TSTKBD
	TAD CTRLO
	SZA CLA
	JMP I TTYOUT
	TAD TM
	TLS
	TSF
	JMP .-1
	CLA
	JMP I TTYOUT
TM,	0
	PAGE
CHKCOR,	0		/DETERMINE CONFIGURATION
	CDF 70		/CHECK FOR ROM
	TAD I (7503
	TAD (-SDSS
	SZA CLA
	JMP TRY12K
	CDF 0
	JMS I (MSG
	ROM8K
	CLA IAC
ENTR12,	DCA ROMSW	/SET INDICATOR
	CDF 0
	JMP I CHKCOR
TRY12K,	CDF 20
	TAD ENTR12
	DCA I (7600
	TAD I (7600
	CIA
	TAD ENTR12
	CDF 0
	SNA CLA
	JMP OK12
	JMS I (MSG
	HRDWR		/NO HARDWARE AROUND!
	HLT
	JMP .-1
OK12,	JMS I (MSG
	TD8E12
	JMP ENTR12
IN,	0

ZERO,	JMS I (MSG
	SPECIAL
	JMS I (TTY
	TAD INCHAR
	TAD (-62
	DCA IN
	TAD IN
	SPA
	CIA
	CLL RAR		/ALLOW ONLY -1, 0, 1
	SZA CLA
	JMP ZERO+1
	TAD IN
	TAD (TBL+1
	DCA IN
	TAD I IN
	DCA IN
	JMP I IN	/JUMP TO APPROPRIATE ROUTINE

ZER,	JMS I (MSG
	ZERY
	JMS I (DTA1
	4202
	MTDIR
	2
	JMS I (ER1
	JMP I (RESTRT

LVAL,	JMS I (MSG
	PRES
	JMP I (RESTRT
MTDIR,	-1
	70		/SYSTEM TAPE
	0
	0
	-1		/1 EMPTY FILE
	0
	6437+70		/-LENGTH OF DECTAPE

BOOT,	TAD ROMSW
	SNA CLA
	JMP TDBOOT
	JMS I (DTA0	/ROM BOOT
	202
	7400
	0		/READ IN BLOCK 0
	JMS I (ER1
	TAD (CDF 10
	JMS MOVE
	7400
	JMP I (7605

TDBOOT,	JMS I (DTA0
	202
	7400
	0
	JMS I (ER1
	JMS I (DTA0
	202
	7000
	66^2
	JMS I (ER1
	TAD (CDF 10
	JMS MOVE
	7000
	TAD (CDF 20
	JMS MOVE
	7200
	JMP I (7605
	XRIN=11
	XROUT=12

MOVE,	0
	DCA MOVCDF
	STA
	TAD I MOVE
	DCA XRIN
	TAD (-200	/MOVE 200 WORDS TO LOCATION 7600
	DCA MVCNT
	ISZ MOVE
	TAD (7577
	DCA XROUT
MOVLUP,	TAD I XRIN
MOVCDF,	HLT
	DCA I XROUT
	CDF 0
	ISZ MVCNT
	JMP MOVLUP
	JMP I MOVE

MVCNT,	-200
	PAGE
VNO,	TEXT	/TD8E INITIALIZER PROGRAM VERSION 7A ?/
INIT,	TEXT /MOUNT A CERTIFIED DECTAPE ON UNIT 1 WRITE-ENABLED_/
	TEXT	/ALWAYS KEEP ORIGINAL SYSTEM DECTAPES WRITE-LOCKED?/
STRIKE,	TEXT /STRIKE A CHARACTER TO CONTINUE?/
DISMNT,	TEXT /REMOVE AND SAVE TAPE ON UNIT 0_/
	TEXT	/TAKE NEW TAPE (ON UNIT 1) WHICH WAS JUST CREATED_/
	TEXT	/AND PLACE IT ON UNIT 0_/
	TEXT	\IT IS YOUR NEW OS/8 SYSTEM TAPE?\
SWTCH,	TEXT	/DISMOUNT SYSTEM TAPE #2 FROM UNIT 0 AND SAVE IT_/
	TEXT	/MOUNT ORIGINAL SYSTEM TAPE #1 ON UNIT 0_/
	TEXT	/PREPARE TO COPY FILES OVER?/
OK,	TEXT	/OK?/
WRITOUT,TEXT	/READY TO CREATE BLOCK 0 OF UNIT 1?/
COPY,	TEXT	/COPYING FILES FROM UNIT 0 TO UNIT 1?/
ZERY,	TEXT	/ZEROING DIRECTORY ON TAPE UNIT 1?/
PRES,	TEXT	/DIRECTORY ON UNIT 1 PRESERVED?/
WRONG,	TEXT /NOT ORIGINAL OS8 SYSTEM TAPE #2_/
	TEXT	/MOUNT CORRECT TAPE ON UNIT 0?/
ROM8K,	TEXT /8K ROM SYSTEM?/
TD8E12,	TEXT /12K SYSTEM?/
HRDWR,	TEXT /NEED ROM OR 12K?/
IOERR,	TEXT /FATAL IO ERR_/
	TEXT	/TYPE A TO ABORT AND START OVER AGAIN_/
	TEXT	\TYPE ANY OTHER CHARACTER TO RETRY THIS I/O OPERATION?\
SPECIAL,TEXT	/TYPE 1 TO COPY FILES FROM UNIT 0 TO UNIT 1_/
	TEXT	/TYPE 2 TO ZERO THE DIRECTORY OF UNIT 1_/
	TEXT	/TYPE 3 TO LEAVE THE DIRECTORY OF UNIT 1 ALONE?/
TSTKBD,	0
	KSF
	JMP I TSTKBD
	KRS
	AND (177
	TAD (-3
	SNA
	JMP I (RE	/^C
	TAD (3-17
	SZA CLA
	JMP NO
	CLA IAC
	DCA CTRLO
NO,	KCC
	JMP I TSTKBD
	PAGE
/TD8E SYSTEM INITIALIZER
/THIS CODE IS PLACED ON THE BINARY TAPE
/IN RECORD 0. WHEN THE 7470 OR STANDARD TD8E BOOTSTRAP
/IS EXECUTED, THIS PROGRAM READS THE REST OF THE INIT
/SYSTEM FROM THE FIRST FILE ON THE TAPE, AND
/STARTR EXECUTION OF IT. A SHORT PROGRAM IS HERE
/INCLUDED TO WRITE RECORD 0 ON THE TAPE. THE START ADDRESS
/OF THAT CODE IS 200.

SDSS=6771
SDST=6772
SDSQ=6773
SDLC=6774
SDLD=6775
SDRC=6776
SDRD=6777
	*7420
	NOPUNCH
	*7400
	ENPUNCH
	TAD K177	/INIT FOR TAPE READ
	DCA 10
NUBLK,	TAD KM200	/SET BLOCK WORD COUNT
	DCA WCNT
NOT,	JMS GET		/GET BLOCK # FORWARD
	-26
	SDRD		/THE RIGHT ONE?
	AND KK77
	TAD BLOCKK
	SZA CLA
	JMP NOT		/I GUESS NOT
	JMS GET		/RIGHT. NOW GET REV. GUARD
	-32
	JMS RQD
	JMS RQD
	JMS RQD
LP,	JMS RQD
	DCA I 10	/READ THE INIT PROGRAM
	ISZ WCNT
	JMP LP
	ISZ BCNT	/DONE ALL BLOCKS?
	JMP CONT
	SDLC
	JMP I .+1
	STARTUP
CONT,	CLA CMA		/SET FOR NEXT BLOCK
	TAD BLOCKK
	DCA BLOCKK
	JMP NUBLK

RQD,	0
	SDSQ
	JMP .-1
	SDRD
	JMP I RQD
GET,	0		/PICK UP A SPECIFIED TAPE FRAME
	TAD I GET	/HOLDS 6 BIT MARK TRACK I.D.
	DCA RQD
GTIT,	SDSS
	JMP .-1
	SDRC		/FLAG IS UP. READ MARK TRACK
	AND KK77
	TAD RQD		/A MATCH?
	SZA CLA
	JMP GTIT
	ISZ GET
	JMP I GET

KK77,	77
KM200,	-200
BLOCKK,	-21		/SKIP CORE CONTROL BLOCK AND PAGE 0
WCNT,	-200
K177,	177
BCNT,	-3
	*200
	$
