;* asynchronous communications driver.
;
; set by default to 300 baud, even parity, 1 stop
;
pasdat equ 20h ; ascom data port
passts equ 22h ; ascom status
pasmod equ 24h ; ascom mode
pascmd equ 26h ; ascom command
passf1 equ 28h ; special function latch 1
passf2 equ 2ah ; special function latch 2
ascin: call ascsts ; ascom input
ora a
jz ascin ; wait for character
in pasdat ; get data
ani 07fh
ret ; exit...
ascsts: call ascit ; initialize
in passts ; status ascom for input
ani 00111000b
jz ascst2 ; if no error
mvi a,00110111b
out pascmd ; clear error
ascst2: in passts ; get status
ani 10b
rz ; if not ready
mvi a,255
ret ; exit...data ready
ascout: call ascit ; initialize
in passts ; ascom output
ani 00111000b
jz ascot2 ; if no error
mvi a,00110111b
out pascmd ; reset error
ascot2: in passts
ani 01b
jz ascout ; if transmit busy
mvi a,00100111b
out pascmd ; set rts
mov a,c
out pasdat
ret ; exit...
ascit: mvi a,0
ascia equ $-1 ; initialize ascom routine
ora a
rnz ; exit if done
inr a
sta ascia ; set initialized
xra a
out passf1 ; clear special function latches
out passf2
mvi a,01111010b
out pasmod
mvi a,00110101b ; 300 baud, even, 1 stop 7 bits
out pasmod
mvi a,00100111b
out pascmd ; send rcv dtr
ret