;
;  Serial port echo at 9600 baud for Heath H89
;

SIOBASE equ	0D0h		;for DCE port (320Q)
;SIOBASE equ	0D8h		;for DTE port (330Q)
;SIOBASE equ	0E0h		;for LP port (340Q)

SIODATA	equ	SIOBASE+0	;data register
SIOIEN	equ	SIOBASE+1	;interrupt enable
SIOIID	equ	SIOBASE+2	;interupt ID
SIOLCTL	equ	SIOBASE+3	;line control
SIOMCTL	equ	SIOBASE+4	;modem control
SIOLSTS	equ	SIOBASE+5	;line status
SIOMSTS	equ	SIOBASE+6	;modem status

SIOBDL	equ	SIOBASE+0	;LSB of baud rate divisor (when DLAB 1)
SIOBDH	equ	SIOBASE+1	;MSB of baud rate divisor (when DLAB 1)

SIORDRF	equ	01h		;receive data register full
SIOTDRE	equ	20h		;transmit data register empty
SIODLAB	equ	80h		;data latch access bit (for baud rate)

	org	2300h		;above Heath monitor RAM

; Initialize 8250

	mvi	a,83h		;access baud rate (DLAB high)
	out	SIOLCTL

	mvi	a,12		;9600 baud LSB
	out	SIOBDL
	xra	a		;9600 baud MSB
	out	SIOBDH

	mvi	a,03h		;8N1
	out	SIOLCTL

; Loop echoing received characters

loop	in	SIOLSTS		;check line status
	rrc			;check receive data (LSBit)
	jnc	loop

	in	SIODATA		;read character
	out	SIODATA		;echo it back out
	jmp 	loop

	end
