# File echo_char_test.asm 0000 ;Program to test serial port. 0000 ;To be entered with ROM Program_loader. 0000 ;Includes port initialization commands 0000 ;When running, should echo typed characters to display. 0000 ;Sends entered characters to output port 0 LEDs also. 0000 org 0800h ;org not really needed, all jumps relative 0800 3e 4e ld a,04eh ;1 stop bit, no parity, 8-bit char, 16x baud 0802 d3 03 out (3),a ;write to control port 0804 3e 37 ld a,037h ;enable receive and transmit 0806 d3 03 out (3),a ;write to control port 0808 db 03 echo_loop_1: in a,(3) ;get status 080a e6 02 and 002h ;check RxRDY bit 080c 28 fa jr z,echo_loop_1 ;not ready, loop 080e db 02 in a,(2) ;get char 0810 d3 00 out (0),a ;data to LEDs 0812 47 ld b,a ;save received char in b reg 0813 db 03 echo_loop_2: in a,(3) ;get status 0815 e6 01 and 001h ;check TxRDY bit 0817 28 fa jr z,echo_loop_2 ;loop if not set 0819 78 ld a,b ;get char back 081a d3 02 out (2),a ;send to output 081c 18 ea jr echo_loop_1 ;start over 081e 081e # End of file echo_char_test.asm 081e