; BootBase.asm - Sets up the BCPL world.
; Copyright Xerox Corporation 1979
; Last modified December 27, 1978  2:02 PM by Boggs

; Incoming procedures
.bext BasicBootInit, FullBootInit

; Outgoing statics
.bext BootBLV, RunBLV

	.srel

RunBLV:	.RunBLV
BootBLV:.BootBLV
UPE:	.UPE

	.nrel

	0			; sacrifical word for BLDR

	mkzero 0 0
	sta 0 @lvDisplay	; turn off display
	sta 0 @lvActive		; paranoia...loader does this too
	mkminusone 0 0
	sta 0 @lvKAddress	; invalidate disk arm position
	eir

; set up BCPL stack
	lda 3 @lvRunBLV		; layout vector for main program
	lda 1 29. 3		; endcode+1
	lda 2 @lvBootBLV	; layout vector for BootBase
	lda 0 29. 2		; endcode+1
	subz# 1 0 szc		; use the bigger of the two (unsigned)
	 mov 0 1
	sta 1 335		; stack limit
	mov 3 0
	mov 2 1
	lda 2 firstFrame
	sta 2 0 2		; loop to self

; call OS Initialization with layout vectors as arguments
	jsrii .BasicBootInit
	 2
	lda 0 @.FullBootInit	; call only if loaded
	snz 0 0			; assumes UNDEFS contain 0!!!
	 jmp boot1		; a hack of the first water
	lda 0 @lvRunBLV
	lda 1 @lvBootBLV
	jsrii .FullBootInit
	 2

; start the user program
boot1:	lda 3 @lvRunBLV		; layout vector
	mov 3 0			; for passing to user
	lda 1 @lvUPE		; dummy user parameters
	jsr @28. 3		; first procedure
	 2
	jsr @353		; finish

.RunBLV:	.blk 32.	; Copy of run file's BLV
.BootBLV:	.blk 32.	; BootBase's BLV
.UPE:		0

lvUPE:		UPE
lvRunBLV:	RunBLV
lvBootBLV:	BootBLV

firstFrame:	176774

lvDisplay:	420
lvActive:	453
lvKAddress:	523

.BasicBootInit:	BasicBootInit
.FullBootInit:	FullBootInit

	.end