; KBoot.asm -- disk boot loader for Maxc2

.ent MaxcBootLoader
.ent lenMaxcBootLoader

.srel

MaxcBootLoader: .MaxcBootLoader
lenMaxcBootLoader: numAltoWords/3

.nrel

.MaxcBootLoader:


;		TITLE	KBOOT
;		SEARCH STENEX
;	; This program is booted into MAXC memory and is used to start up
;	; Micro-Exec.  The program is self-relocating and may be loaded anywhere.
;	; The first location of the program is a parameter specifying the
;	; starting disk address to be loaded.  This word should be setup with
;	; a physical disk unit number in bits 11-13 and a starting disk address
;	; in bits 18-35.  The starting disk address for save area N is
;	; 6221-40*N (octal).  The program is then started at its second location.
;	; The pack number is not required in the parameter because the
;	; program ignores header errors.
;		.HWFRM
;		RIM10
;		NOSYM
;		LOC 0
;		P=17
;		R=16
000000 ;PARAM:	6161			; Default parameter (save area 1 on unit 0)
000307
010000
177760 ;START:	WABS R,16		; Save AC's temporarily
007200
160000
177770 ;	WABS P,17
007200
170000
041370 ;	MOVSI P,(JUMPA (R))	; Self-relocate
015200
160000
055360 ;	JSP R,P
000000
170000
057360 ;	SUBI R,.		; Compute real address of start of program
000000
050000
040373 ;	MOVEI P,ACSAVE(R)	; Save away all the AC's
100010
010000
052373 ;	BLT P,ACSAVE+R-1(R)
100010
160000
177610 ;	RABS 1,16
007400
160000
040413 ;	MOVEM 1,ACSAVE+R(R)
100010
170000
177610 ;	RABS 1,17
007400
170000
040413 ;	MOVEM 1,ACSAVE+P(R)
100011
000000
177600 ;START1:	PRES 0			; Reset processor
003400
000000
040203 ;	MOVEI MAXLOC(R)
100012
010000
177600 ;	WABS 3
007200
030000
040203 ;	MOVEI DLSLOC(R)
100032
010000
177600 ;	WABS 4
007200
040000
100403 ;	SETZM MAXLOC(R)		; Clear out communication region
100012
010000
041213 ;	MOVSI 1,MAXLOC(R)
100012
010000
130213 ;	HRRI 1,MAXLOC+1(R)
100012
020000
052213 ;	BLT 1,DLSLOC+103(R)
100036
040000
160040 ;	CONO 634440
031622
000000
041370 ;	MOVSI P,-20		; Setup pushdown pointer
037777
000000
130373 ;	HRRI P,PDL-1(R)
100011
000000
040073 ;	MOVE 7,[XWD 770000,350000](R)	; First mma and word count 1000
100007
020000
040260 ;	MOVEI 6,30		; No. pages booted
000001
100000
133043 ;	HLRZ 4,PARAM(R)		; Unit no. * 20
100000
000000
040203 ;	MOVEI KBLK(R)		; Address of 3-word disk int. block
100007
050000
177601 ;	SLOC 413(4)		; Set it
004020
130000
040003 ;	MOVE [44030620700](R)	; Disk record format control
100007
030000
177601 ;	SLOC 414(4)		; Set it
004020
140000
050440 ;	LSH 4,-4		; Get unit no.
037777
140000
040003 ;	MOVE 0,KSTADR(R)	; Largest legal disk address
100006
170000
177601 ;	KON 0,(4)
006000
000000
053043 ;	  HALT START1(R)
100000
140000
104200 ;	ANDCMI 7770
000377
100000
177600 ;	KSEEK 0,0		; Dummy first seek to clear cobwebs
006400
000000
065003 ;	  JUMPA SERRS(R)	; Shouldn't ever fail
100004
140000
130003 ;	HRR 0,PARAM(R)		; Starting disk address
100000
000000
040403 ;LOOP:	MOVEM 0,KCOM(R)
100007
100000
040473 ;	MOVEM 7,KCOM+10(R)	; Save main memory address in command block
100010
000000
040240 ;	MOVEI 4,40		; Setup retry count
000002
000000
177600 ;SRTRY:	KSEEK 0,0
006400
000000
065003 ;	  JUMPA SREJ(R)		; Seek reject, go see why
100005
050000
100403 ;WAIT:	SETZM KBLK+1(R)		; Clear command completion word
100007
060000
040203 ;	MOVEI KCOM(R)		; Get command address
100007
100000
177600 ;	KGO 0,0			; Give command
007000
000000
065003 ;	  JUMPA WAIT(R)		; Assume wrong sector
100002
140000
040200 ;	MOVEI 100000		; Init timeout
004000
000000
066413 ;	SKIPE 1,KBLK+1(R)	; Wait for completion
100007
060000
065003 ;	JUMPA KDON(R)
100003
050000
075603 ;	SOJG .-2(R)
100003
010000
065003 ;	JUMPA WAIT(R)		; Try again
100002
140000
060413 ;KDON:	CAIE 1,KCOM(R)		; Make sure it completed correctly
100007
100000
053043 ;	HALT START1(R)
100000
140000
040003 ;	MOVE KBLK(R)		; Ok, get status
100007
050000
142403 ;	TDNE EMASK(R)		; Any errors?
100007
000000
065003 ;	JUMPA ERRS(R)		; Yes, check
100004
120000
040023 ;	MOVE 2,KCOM(R)		; Right disk address?
100007
100000
106023 ;	XOR 2,KCOM+1(R)
100007
110000
140420 ;	TRNE 2,-1
037777
170000
053043 ;	HALT START1(R)		; No
100000
140000
040003 ;	MOVE KCOM(R)		; No errors, increment address
100007
100000
141400 ;	TRNN 0,6		; Sector 2?
000000
060000
071003 ;	AOJA SNEXT(R)		; No, increment sector and finished
100004
020000
056200 ;	ADDI 0,7776		; Increment head, clear sector
000377
160000
056270 ;SNEXT:	ADDI 7,1000		; Increment core page
000040
000000
075663 ;	SOJG 6,LOOP(R)		; Loop until done
100002
070000
040010 ;	MOVE 1,350000		; Check fingerprint
016400
000000
062413 ;	CAME 1,[ASCII/MEXEC/](R)
100007
040000
053043 ;	HALT START1(R)
100000
140000
041373 ;	MOVSI P,ACSAVE(R)	; Restore all the AC's
100010
010000
052370 ;	BLT P,P
000000
170000
065000 ;	JUMPA 350001		; Start MEXEC
016400
010000
143403 ;ERRS:	TDNN FATERR(R)		; Hard error or bug?
100007
010000
075643 ;	SOJG 4,WAIT(R)		; No, soft error countout?
100002
140000
040210 ;SERRS:	MOVEI 1,15
000000
150000
054173 ;	PUSHJ P,TCO(R)
100005
120000
040023 ;	MOVE 2,KCOM(R)		; Print disk address of irr. error
100007
100000
054173 ;	PUSHJ P,TOCT(R)
100006
040000
040210 ;	MOVEI 1," "
000002
000000
054173 ;	PUSHJ P,TCO(R)
100005
120000
040020 ;	MOVE 2,0		; Print error status
000000
000000
054173 ;	PUSHJ P,TOCT(R)
100006
040000
053043 ;	HALT START1(R)
100000
140000
;	; Check seek reject
141600 ;SREJ:	TLNN 0,320000		; Unsafe, offline, seek fail, deselected?
015000
000000
141600 ;	TLNN 0,40000		; Not ready?
002000
000000
065003 ;	JUMPA SERRS(R)		; Bad ones, quit
100004
140000
040003 ;	MOVE 0,KCOM(R)		; Just not ready, retry
100007
100000
065003 ;	JUMPA SRTRY(R)
100002
120000
;	; Typeout ASCIZ char in 1
162460 ;TCO:	CONSZ TTY,20
000001
000000
065003 ;	JUMPA .-1(R)
100005
120000
162430 ;	DATAO TTY,1
000000
010000
060410 ;	CAIE 1,15		; Carriage return?
000000
150000
054770 ;	POPJ P,			; No, done
000000
000000
040210 ;	MOVEI 1,12		; Follow by linefeed
000000
120000
054173 ;	PUSHJ P,TCO(R)
100005
120000
040210 ;	MOVEI 1,400000
020000
000000
075613 ;	SOJG 1,.(R)		; Wait a while
100006
020000
054770 ;	POPJ P,
000000
000000
;	; Print octal no. in 2 suppressing leading 0's
040210 ;TOCT:	MOVEI 1,0
000000
000000
123340 ;	HRLZI 14,-14
037777
040000
051410 ;TOCT0:	LSHC 1,3
000000
030000
065413 ;	JUMPN 1,TOCT1(R)
100006
110000
052743 ;	AOBJN 14,TOCT0(R)
100006
060000
056210 ;TOCT1:	ADDI 1,60
000003
000000
054173 ;	PUSHJ P,TCO(R)
100005
120000
040210 ;	MOVEI 1,0
000000
000000
051410 ;	LSHC 1,3
000000
030000
052743 ;	AOBJN 14,TOCT1(R)
100006
110000
054770 ;	POPJ P,
000000
000000
001023 ;KSTADR:	4114236252		; Disk command and largest legal address
011712
120000
074360 ;EMASK:	361700077776		; Errors except HDNE
003777
160000
064040 ;FATERR:	320200007500		; Fatal errors = unsafe, offline,
000364
000000
;					; seek failure, deselected, illegal address,
;					; seek already in progress
;		LIT
176000
016400
000000
011006
031034
000000
115426
142130
060000
;	KBLK:	BLOCK 3
;	KCOM:	BLOCK 11
;	ACSAVE:	BLOCK 20
;	PDL:	BLOCK 20
;	MAXLOC:	BLOCK 400
;	DLSLOC:	BLOCK 104
;	IFG .-777,<PRINTX ?BOOT PROGRAM TOO BIG>
;		END START


numAltoWords = .-.MaxcBootLoader

.end