	.TITLE	SPLOAD DISK IMAGE BUILDER
/
/COPYRIGHT (C) 1975
/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 INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS
/SOFTWARE, OR ANY OTHER COPIES THEREOF, MAY NOT BE PRO-
/VIDED 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 DOCUMENT IS SUBJECT TO CHANGE
/WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED AS A COM-
/MITMENT BY DIGITAL EQUIPMENT CORPORATION.
/
/DEC ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY
/OF ITS SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DEC.
	.EJECT
/ 
/ 
/
/SPOOLER DISK IMAGE BUILDER
/
/ THIS PROGRAM READS IN AN OBJECT PAPER TAPE OF SPOOL-11 AND BUILDS
/ A DISK IMAGE OF IT ON DISK UNDER THE SYSTEM FILE NAME OF SPOOL.
/THIS IMAGE MAY BE BUILT ON ANY SYSTEM DISK (RK0,DP0,DF0).
/	THE IMAGE IS LOADED AT START OF SPOOL+20 (8) BLOCKS.
/THE FIRST 20 (8) BLOCKS ARE USED TO HOLD SPOL15 - THE SPOOLER INITIATOR/
/TERMINATOR THAT EXECUTES ON THE PDP-15 SIDE OF THE SYSTEM.
/
/
/	THIS PROGRAM IS INSTALLED IN THE SYSTEM AS "SPLOAD"
/
/
/
/ COPYRIGHT: DIGITAL EQUIPMENT CORPORATION, 1972,73 MAYNARD, MASS.
/EDIT  #000	APR. 13, 73
/	001	SK
/	002	SK	10-DEC-73	IMAGE WC BUG FIX
/	003	GAR	19-SEP-74	FIX .TRAN SO THAT IT WILL WORK
/					PROPERLY ON A 16K CONFIGURATION.
/	004	BLR	12-DEC-74	AUTOMATE SPOLSZ LOCATION
/	005	BLR	22-DEC-74	AUTOMATE API BACK ON AT END PROCESS
/	006	BLR	29-DEC-74	ADD COMMENTS AND HELLO MESSAGE
/	007	BLR	29-DEC-74	FIX NO-TAPE ERROR
/	008	BLR	20-JAN-75	FIXED BAD ERROR MESSAGE
/	009	BLR	18-JUN-75	XVM UPGRADE
/	010	BLR	19-JUN-75	ALLOW API SYSTEM
/	011	MJH	20-AUG-75	DISCLAIMER
/	012	BLR	09-NOV-75	FIX NOT SYSTEM DISK BUG
/
/	FATHER:	SK
/
.SCOM=100		/DEFINE .SCOM START (BR-05)
	.EJECT
/
BUF	.BLOCK	400	/EDIT 003 GAR
	.IODEV -14	/LOAD RK HANDLER
SPO000=.		/START (BR-010)
SPO006	.WRITE	-3,2,HELLO,34	/SAY HELLO AND VERSION (BR-006)
SPO004	.INIT	-14,0,0	/INITIALIZE "TRAN" PROCESSOR (BR-05)
DEV=.-1
	LAC	DEV	/GET BUFFER SIZE (BR-012)
	SAD	(376	/IS IT A DISK BUFFER (BR-012)
	SKP		/SKIP IF DISK BUFFER (BR-012)
	JMP	NOTDSK	/NOT A DISK BUFFER - FATAL ERROR (BR-012)
	.TRAN	-14,0,34,BUF,256	/READ IN SYSBLK FROM SYSTEM DEV-GAR
	.WAIT	-14
	LAC	PARAM	/LOOK THROUGH SYSBLK FOR "SPO11"
	TAD	(1
	DAC	TEMP1
	DAC	TEMP2
	LAC*	TEMP1	/GET WORD 1 OF SYSBLK (BR-012)
	SAD	(220523		/IS IT "RES" (BR-012)
	SKP			/YES ITS "RES" - SKIP (BR-012)
	JMP	NOTDSK		/NO - FATAL ERROR NOT SYSBLK (BR-012)
SPO001	LAC*	TEMP1	/NAMES MATCH?
	SAD	SPOP1	/NO:  LOOK AT NEXT THEN
	SKP		/LOOK AT 2ND HALF OF NAME NOW
	JMP	SPO002
	ISZ	TEMP1
	LAC*	TEMP1	/DOES 2ND HALF MATCH?
	SAD	SPOP2	/NO:  LOOK AT NEXT ENTRY
	JMP	SPO003	/A MATCH WAS FOUND
SPO002	LAC	TEMP2	/LOOK AT NEXT ENTRY
	TAD	(7
	DAC	TEMP1
	DAC	TEMP2
	CMA		/END OF NAMES IN SYSBLK?
	TAD*	PARAM
	TAD	PARAM
	SMA		/YES:  TELL USER AND EXIT
	JMP	SPO001	/LOOK AT THIS ENTRY
/
	.WRITE	-3,2,ERR2,34
	JMP	EXIT
/
SPO003	ISZ TEMP1	/BUMP TO FIRST BLOCK #
	LAC* TEMP1	/SAVE IT FOR OUTPUT
	TAD (20		/RELOCATE BEYOND SPOL15 (BR-04)
	DAC BLOCK
	.EJECT
/
/ LOOK FOR BEGINNING OF A BLOCK
/
LD2	DZM	CKSUM	/INITIALIZE CHECKSUM
	JMS	READ	/READ A FRAME
	LAC	BYTE
	SAD	(1	/CHECK FOR +1 (START OF A BLOCK)
	SKP
	JMP	LD2	/LOOK UNTIL +1 IS FOUND
	JMS	READ	/READ ANOTHER FRAME
/
/ INPUT AND SAVE BYTE COUNT. IF BYTE COUNT = 6, GO TO PROCESS
/ JUMP BLOCK.
/
	JMS	GETWRD	/GET FULL BYTE COUNT
	TAD	(-4	/SUBTRACT 4 TO MAKE BYTE COUNT CORRECT
	DAC	BYTECT
	SAD	(2	/WAS BYTE COUNT = 6?
	JMP	LJMP	/JUMP IF NO DATA (I.E. - JMP BLOCK)
	JMS	GETWRD	/GET LOAD ADDRESS
	DAC ODD
	RCR		/15'S MEMORY ADDRESS = 11'S / 2
	DAC LADD
	LAC LADD
	TAD BASE
	DAC LADD
	.EJECT
/
/
/ READ IN REMAINDER OF DATA.  IF LOADER HALTS WITH AC= -1, A CHECKSUM
/ ERROR HAS OCCURRED.
/
LD3	JMS	READ	/READ A FRAME
	SMA		/SKIP IF NO MORE DATA REMAINS
	JMP	LD4
	LAC	CKSUM	/IF CHECKSUM IS CORRECT, THEN CONTINUE
	SNA
	JMP	LD2	/CORRECT:  CONTINUE
LBAD	.WRITE	-3,2,ERR1,34	/TELL USER A CHECKSUM ERROR (BR-010)
EXIT	.WAIT	-3		/    OCCURRED.
	.EXIT		/RETURN TO DOS
/
LD4	LAC	ODD	/STORE 8 BITS AT A TIME, THEN RE-LOOP
	RAR
	SNL
	JMS EC		/CLEAR THE EVEN BYTE
	SZL
	JMS OC		/CLEAR THE ODD BYTE
	LAC	BYTE	/ODD BYTE GETS PUT IN BITS 3-9
	SZL!CLL
	ALS+10		/ODD BYTE
	XOR*	LADD	/COMBINE BYTE WITH PREVIOUS ONE (IF ANY)
	DAC*	LADD
	LAC	ODD	/NOW ADJUST ADDRESS
	RAR		/ODD BYTE FORCES BUMP OF ADDRESS
	SZL
	ISZ	LADD
	ISZ	ODD	/(FOR NEXT TIME)
	JMP	LD3	/DO NEXT BYTE
EC	0		/ROUTINE TO CLEAR THE EVEN BYTE. ODD BYTE LEFT UNTOUCHED
	LAC (177400
	AND* LADD
	DAC* LADD
	JMP* EC
OC	0		/ROUTINE TO CLEAR THE ODD BYTE. EVEN BYTE LEFT UNTOUCHED
	LAC (377
	AND* LADD
	DAC* LADD
	JMP* OC
	.EJECT
/
/ INPUT A FRAME, DECREMENT BYTE COUNT, AND ACCUMULATE CHECKSUM.
/
RSF=700101
RCF=700102		/CLEAR READER FLAG (BR-007)
RSA=700104
RRB=700112
EBI=705521		/ENABLE BREAKS (BR-010)
DBI=705522		/DISABLE BREAKS (BR-010)
READ	0
	DBI		/DISABLE API (BR-010)
	IOF		/TURN OFF INTERRUPTS FOR A SECOND
	RSA		/READ IN ALPHANUMERIC MODE
SPO005	IORS		/CHECK FOR EOT ERROR (BR-05)
	AND	(1000	/DITTO (BR-05)
	SNA		/SKIP IF EOT (BR-010)
	JMP	SPO007	/NOT EOT - CONTINUE (BR-010)
	RCF		/CLEAR READER FLAG (BR-010)
	ION		/ENABLE INTERUPTS (BR-010)
	EBI		/ENABLE API BREAKS (BR-010)
	JMP	LBAD	/SAY SO AND EXIT (BR-05)
SPO007	RSF		/WAIT FOR IT (BR-05)
	JMP	SPO005	/NO FLAG - STAY IN LOOP (BR-05)
	RRB		/READ IN BYTE
	AND	(377	/MASK OFF JUNK BITS
	DAC	BYTE	/SAVE BYTE
	TAD	CKSUM	/ADD TO CHECKSUM
	AND	(377	/USE ONLY 8 BITS OF CHECKSUM
	DAC	CKSUM
	ION		/TURN INTERRUPTS BACK ON
	EBI		/ENABLE API BREAKS (BR-010)
	LAW	-1	/DECREMENT BYTE COUNT BY ONE
	TAD	BYTECT
	DAC	BYTECT
	JMP*	READ	/RETURN
	.EJECT
/
/ ASSEMBLE ONE FULL WORD OF DATA
/
GETWRD	0
	JMS	READ	/GET ONE CHARACTER
	LAC	BYTE	/SAVE BYTE TEMPORARILY
	DAC	TEMP
	JMS	READ	/GET ANOTHER FRAME
	LAC	BYTE	/PLACE THIS FRAME IN THE HIGHER ORDER BYTE
	CLL
	ALS+10
	XOR	TEMP	/ASSEMBLE BOTH FRAMES INTO A COMPLETE WORD
	JMP*	GETWRD	/RETURN
	.EJECT
/
/ PROCESS JUMP BLOCK
/
LJMP	LAC*	BASE	/GET SIZE OF SPLOAD
	SNA		/MUST BE NON 0 - ELSE WRONG VERSION OF SPLOAD (BR-04)
	JMP	SPER	/WRONG VERSION - SAY SO (BR-04)
	CMA
	DAC	IMAGSZ
	.TRAN	-14,1,0,20000,XX	/.TRAN OUT NEW IMAGE NOW
BLOCK=.-3
IMAGSZ=.-1
	.WAIT	-14		/WAIT FOR IT
	.WRITE	-3,2,DONE,34	/TELL USER THE OPERATION IS COMPLETE
	JMP	EXIT
SPER	.WRITE	-3,2,ERR3,34	/NOT DOS V3B000 SPOOLER (BR-04)
	JMP	EXIT		/LEAVE (BR-04)
NOTDSK	.WRITE	-3,2,ERR4,34	/NOT A SYSTEM DISK (BR-012)
	JMP	EXIT		/LEAVE (BR-012)
	.EJECT
/
ODD	0
BYTECT	0
CKSUM	0
TEMP	0
TEMP1	0
TEMP2	0
TEMP3	0
LOW	400000
BYTE	0
LADD	0
SPOP1	.SIXBT	/SPO/
SPOP2	.SIXBT	/OL@/
BASE	20000
PARAM	BUF	/EDIT 003 9/19/74  GAR
/
/ MESSAGES
/
ERR1	404002
	000000
	.ASCII	/CHECKSUM ERROR/<15><12>
/
ERR2	406002
	000000
	.ASCII	/SPOOL NOT ON SYS DEV/<15><12>
ERR3	413002		/(BR-04)
	000000
	.ASCII	/SPOL11 VERSION NOT AT LEAST DOS-15 V3B LEVEL/<15><12>
ERR4	411002		/(BR-012)
	000000
	.ASCII	/.DAT-14 NOT ASSIGNED TO SYSTEM DISK/<15><12>
HELLO	405002		/HELLO MESSAGE (BR-006)
	000000		/DITTO (BR-006)
	.ASCII	/SPLOAD XVM V1A000 /<15><12>	/DITTO (BR-009)
/
DONE	404002
	000000
	.ASCII	/DONE/<15><12>
/
	.END	SPO000
