
	org	100h
Monitor 	EQU	0FF7Ch;
CmdReg		EQU	8800h;
PortA		EQU	1000h;
StatusReg	EQU	8800h
DataReg		EQU	8000h

main:
	bsr	Config8251A;	Configure USART
	bsr	TransmitA;	Transmit Data
	jmp	Monitor;	End program


;Name:		Config8251A
;Input:		None
;Output: 	None
;Destroys:	A
;Description:	Configure 8251 for :
;		Asyncronous serial data
;		Baud Rate Factor = 16
;		8Bit data, no parity
;		1 stop bit
;		Enable transmitter

Config8251A:
	ldaa	#0FFh;		Sets pin 6 high
	staa	PortA;		sends hardware reset to USART
	ldaa	#00h;
	staa	PortA;
	ldaa 	#4Eh;		Load data
	staa 	CmdReg;		Send data to register
        ldaa    #05h;
	staa	CmdReg;		Transmit data
	rts;


;Name:		TransmitA
;Input:		A = the Byte to transmit.
;Output:	None.
;Destroys:	None.
;Description:	Wait until the transmitter is ready (wait until the 
;		TxRDY bit in the same Status Register is 1), then 
;		write the contents of A to the Data register.
TransmitA:
	ldx 	#StatusReg
	brclr	0,x,01h,TransmitA	; go to write A if contents
					; Back to loop to wait
	staa	DataReg			; Write data
	rts				; Return to loop for more data

