;Name:  Derek Marston
;Date:   2-14
;Desc:  This program will send a byte serially on the TxD pin

RAM             EQU     800h;
FLASH           EQU     8000h;

StatusReg       EQU     00C4h;
DataReg         EQU     00C7h;
ControlReg1     EQU     00C2h;
ControlReg2     EQU     00C3h;


     org        FLASH
     bra        main

main:
     bsr        ConfigPort;
     ldaa       #0AAh;
loop:
     bsr        TransmitA;
     bra        loop;



;Name:          ConfigPort
;Input:         None
;Output:        None
;Destroys:      A
;Description:   Configures port for:
;               Asyncronous serial data
;               8 bit data, no parity, 1 stop bit
;               enable transmitter and receiever

ConfigPort:
     ldaa       #00100000q;
     staa       ControlReg1;
; THESE OPERATE NORMALLY when bit 7 is 0!  otherwise in loopback mode

     ldaa       #00001100q;       enable transmitter and receiver
     staa       ControlReg2;

     rts;


;Name:          TransmitA
;Input:         A = the byte to transmit
;Output:        None
;Destroys:      X
;Description:   Wait until the transmitter is ready (wait until the
;		TDRE bit in the Status Register is 1), then
;		write the contents of A to the Data register.
TransmitA:
      ldx       #StatusReg
;      brclr     0,x,10000000q,TransmitA;   wait until TDRE is 1
      ldab       StatusReg
      andb       #10000000q;
      beq        TransmitA;

      staa      DataReg
      rts;


