/
/  BOOT                 Adapted by   :  Vincent Hayward
/                                       School of Electrical Engineering
/                                       Purdue University
/                       from unknown origin
/       Dir     : boot
/       File    : boot.s
/       Remarks : This little bootstrap reads chars through the serial line
/                 build words and path them into memory.
/                 First word is word count, last is checksum
/       Usage   : make install
/
/
	.=077000^.
start:  mov     $start,sp       / stack
	mov     $177560,r1      / rcsr of 11 dl connection
	mov     $177562,r3      / rbuf of 11 dl connection

	clr     r2              / chks = 0
	clr     r5              / address = 0
	jsr     pc,getw         / read WORD count into loc 0.
	mov     -(r5),r4        / get word count, reset loc
boot1:  jsr     pc,getw         / read word into mem.
	add     -(r5),r2        / add chks
	cmp     (r5),(r5)+      / advance loc
	dec     r4              / can't use sob here...
	bgt     boot1           / cdp doesn't have it
	jsr     pc,getw         / get chks
	sub     -(r5),r2         / is chks
	bit     $77777,r2
	beq     1f              / ok
	0                       / halt
1:      mov     $7,6(r1)        / tell it's finished, ring a bell
	jsr     pc,nap
	mov     $76,6(r1)       / >
	jsr     pc,nap
	mov     $157,6(r1)      / o
	jsr     pc,nap
	mov     $153,6(r1)      / k
	mov     $2000,pc        / goto loc 2000

getw:   tstb    (r1)            / read two bytes from host to mem
	bpl	getw
	movb    (r3),(r5)+      / low byte, directly to mem
1:      tstb    (r1)            / get second byte
	bpl     1b
	movb    (r3),(r5)+      / high byte
	rts	pc

nap:    mov     $1000,r4        / time count
1:      dec     r4              / count down
	bgt     1b
	rts     pc
