;*************************************************************************
;
;  Quick binary file loader for the IMSAI SIO-2
;
;  	Using the front panel or a ROM monitor, enter the bytes of this
;	program into memory at address zero. Run the program from
;	address zero and then send the file PC2FLOP.COM (8-bit binary)
;	through the serial port. Nothing is displayed while the file
;	loads. After the file transfer is complete, reset the machine
;	and run PC2FLOP from address 0100h.
;
;************************************************************************
SIOACR	equ	03h		;console port - control register
SIOADR	equ	02h		;console port - data register
SIORDA	equ	02h		;read data available flag
SIOTRE	equ	01h		;transmit register empty flag
SIOCTL	equ	08h		;interrupt control register

LOADADR	equ	0100h		;address of program being loaded

	org	0

serInit	xra	a
	out	SIOCTL		;no interrupts
	
	out	SIOACR		;account for possible power up into
	out	SIOACR		;   synchronous mode
	out	SIOACR

	mvi	a,40h		;reset 8251
	out	SIOACR

	mvi	a,4Eh		;8N1, /16
	out	SIOACR
	
	mvi	a,37h		;reset errors, enable xmit, rcv
	out	SIOACR

	lxi	h,LOADADR	;HL->starting address for program

loop	in	SIOACR		;wait for a character
	ani	SIORDA		
	jz	loop

	in	SIOADR		;get the byte
	mov	m,a		;store it
	inx	h		;move to next location
	jmp	loop

	end
