
	org	0
;
; 2SIO Loader for 4K BASIC Version 3.2
;
;  ** Set sense switches A11, A10 ON **
;
	mvi	a,3		;reset then init ACIA
	out	010h
	mvi	a,015h		;015h for 8N1, 011h for 8N2
	out	010h

; H = msb of load address
; L = lsb of load address = length of loader = leader byte

	lxi	h,00faeh	;4K BASIC V3.2
;	lxi	h,00fc2h	;4K BASIC V4.0
;	lxi	h,01fc2h	;8K BASIC v4.0
;	lxi	h,03fc2h	;Extended BASIC V4.0
;	lxi	h,07ec2h	;Extended Disk BASIC v5.0

loop	lxi	sp,stack	;init SP so a RET jumps to loop
	in	010h		;get 2sio status
	rrc			;new byte available?
	rnc			;no (jumps back to loop)
	in	011h		;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 downloaded

stack	dw	loop
	end

