;
; 2SIO Loader for 8K BASIC Version 3.2
;
;  ** Set sense switches A11, A10 ON **
;
	org	0

	mvi	a,03h		;reset then init ACIA
	out	10h
	mvi	a,15h		;15h for 8N1, 11h for 8N2
	out	10h

; H = msb of load address
; L = lsb of load address = length of loader = leader byte

;	lxi	h,0FAEh		;4K BASIC V3.2
	lxi	h,1FAEh		;8K BASIC V3.2
;	lxi	h,0FC2h		;4K BASIC V4.0
;	lxi	h,1FC2h		;8K BASIC v4.0
;	lxi	h,3FC2h		;Extended BASIC V4.0
;	lxi	h,7EC2h		;Extended Disk BASIC v5.0

loop	lxi	sp,stack	;init SP so a RET jumps to loop
	in	10h		;get 2SIO status
	rrc			;new byte available?
	rnc			;no (jumps back to loop)

	in	11h		;get the byte
	cmp	l		;new byte = leader byte?
	rz			;yes (jumps back to loop)

	dcr	l		;not leader, decrement address
	mov	m,a		;store the byte (reverse order)
	rnz			;loop until L = 0

	pchl			;jump to code just loaded

stack	dw	loop
	end
