-
Notifications
You must be signed in to change notification settings - Fork 1
/
sci.sub
98 lines (76 loc) · 3.42 KB
/
sci.sub
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
;*******************************************************************************
; Serial Communication interface
;*******************************************************************************
;*******************************************************************************
; STRINGS
;*******************************************************************************
hexakars fcc '0123456789ABCDEF'
;*******************************************************************************
; FUNCTIONS
;*******************************************************************************
;*******************************************************************************
; Initialize SCI controller for 57600 bps
#spauto
SCIInit proc
clr SCC3
mov #SCBR_PD_1+SCBR_BD_1,SCBR
mov #$26,SCPSC ; PDS(1)+PSSB(6)
mov #ENSCI_,SCC1
mov #TE_+RE_,SCC2
rts
;*******************************************************************************
; Purpose: Convert a binary number to its hex ASCII equivalent
; Input : A = binary number (0..15)
; Output : A = ASCII equivalent ('0'..'9','A'..'F')
; Note(s):
#spauto
ToHexASCII proc
and #$0F
add #$90
daa
adc #$40
daa
rts
;*******************************************************************************
; Prints a byte in hexa format from A
#spauto
sciputb proc
psha ch@@
pshhx
nsa ; Upper nibble
bsr ToHexASCII
bsr sciputc
lda ch@@,sp ; Lower nibble
bsr ToHexASCII
bsr sciputc
pull
rts
;*******************************************************************************
; Tries to read character from SCI. Carry bit shows if there is received character in A or not.
#spauto
scigetc proc
brclr 5,SCS1,Done@@ ; SCRF = 1 ?
lda SCDR
sec ; RX info in carry bit
Done@@ rts
;*******************************************************************************
; Prints a string. String address is in H:X
#spauto
sciputs proc
Loop@@ lda ,x
beq Done@@
bsr sciputc
aix #1
bra Loop@@
Done@@ equ :AnRTS
;*******************************************************************************
; Prints a character from A
#spauto
sciputc proc
Loop@@ bsr TBMHandle
brclr 7,SCS1,Loop@@ ; wait to send out the previous character
sta SCDR ; also SCTE is cleared here
rts
;*******************************************************************************
#sp
;*******************************************************************************