-
Notifications
You must be signed in to change notification settings - Fork 2
/
test3-rom-serial.asm
47 lines (42 loc) · 1.61 KB
/
test3-rom-serial.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
; Test program to bit-bang a single character out SOD as serial async data
; assemble with: asm85 -b0000:00ff test3-rom-serial.asm
;
; This program does not use any RAM or stack instructions, so it can be run
; from a ROM-only system.
;
; The BITTIME is calculated for a 6.144MHz processor clock.
org 00000H
BITTIME equ 0113H ; 6.144 time delay for a single bit
;BITTIME equ 0112H ; 6.000 time delay for a single bit
OUTBITS equ 11 ; Serial bits to send (start, 8 data, 2 stop)
START:
mvi c,'T' ; Send a test character
COUT:
di
mvi b,OUTBITS ; Number of output bits
xra a ; Clear carry for start bit
CO1:
mvi a,080H ; Set the SDE flag
rar ; Shift carry into SOD flag
cmc ; and invert carry. Why? (serial is inverted?)
sim ; Output data bit
lxi h,BITTIME ; Load the time delay for one bit width
CO2:
dcr l ; Wait for bit time
jnz CO2
dcr h
jnz CO2
stc ; Shift in stop bit(s)
mov a,c ; Get char to send
rar ; LSB into carry
mov c,a ; Store rotated data
dcr b
jnz CO1 ; Send next bit
ei
lxi h,03fffH ; Wait a while before sending the character again
CHILL:
dcr l
jnz CHILL
dcr h
jnz CHILL
jmp START