Instruction manual

0005 d3 03 out (3),a ;write to control port
0007 3e 37 ld a,037h ;enable receive and transmit
0009 d3 03 out (3),a ;write to control port
000b c9 ret
000c ;
000c ;Puts a single char (byte value) on serial output
000c ;Call with char to send in A register. Uses B register
000c 47 write_char: ld b,a ;store char
000d db 03 write_char_loop: in a,(3) ;check if OK to send
000f e6 01 and 001h ;check TxRDY bit
0011 ca 0d 00 jp z,write_char_loop ;loop if not set
0014 78 ld a,b ;get char back
0015 d3 02 out (2),a ;send to output
0017 c9 ret ;returns with char in a
0018 ;
0018 ;Subroutine to write a zero-terminated string to serial output
0018 ;Pass address of string in HL register
0018 ;No error checking
0018 db 03 write_string: in a,(3) ;read status
001a e6 01 and 001h ;check TxRDY bit
001c ca 18 00 jp z,write_string ;loop if not set
001f 7e ld a,(hl) ;get char from string
0020 a7 and a ;check if 0
0021 c8 ret z ;yes, finished
0022 d3 02 out (2),a ;no, write char to output
0024 23 inc hl ;next char in string
0025 c3 18 00 jp write_string ;start over
0028 ;
0028 ;Binary loader. Receive a binary file, place in memory.
0028 ;Address of load passed in HL, length of load (= file length) in BC
0028 db 03 bload: in a,(3) ;get status
002a e6 02 and 002h ;check RxRDY bit
002c ca 28 00 jp z,bload ;not ready, loop
002f db 02 in a,(2)
0031 77 ld (hl),a
0032 23 inc hl
0033 0b dec bc ;byte counter
0034 78 ld a,b ;need to test BC this way because
0035 b1 or c ;dec rp instruction does not change flags
0036 c2 28 00 jp nz,bload
46