-
Notifications
You must be signed in to change notification settings - Fork 4
/
9.RS232.asm
176 lines (171 loc) · 2.74 KB
/
9.RS232.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
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
UART_BUSY BIT 00h
PROG EQU 0000h
ORG PROG+0000h
SJMP START
;Interrupt Vector Table
ORG PROG+0023h
LCALL UART_ISR
RETI
ORG PROG+0030h
START:
CLR UART_BUSY
MOV TMOD,#00100001b ; Timer1 in Mode 2, Timer0 in Mode 1
MOV TH1, #0F3h ; Baud Rate = 2400 bps at 12.000MHz
MOV SCON,#01010000b ; UART in Mode 1
SETB ES ; Enable UART Interrupt
SETB EA ; Enable Interrupt
SETB TR1 ; Start Timer 1
MOV A,#'H'
CALL UART_PUTC
MOV A,#'e'
CALL UART_PUTC
MOV A,#'l'
CALL UART_PUTC
MOV A,#'l'
CALL UART_PUTC
MOV A,#'o'
CALL UART_PUTC
MOV A,#','
CALL UART_PUTC
MOV A,#' '
CALL UART_PUTC
MOV A,#'W'
CALL UART_PUTC
MOV A,#'e'
CALL UART_PUTC
MOV A,#' '
CALL UART_PUTC
MOV A,#'a'
CALL UART_PUTC
MOV A,#'r'
CALL UART_PUTC
MOV A,#'e'
CALL UART_PUTC
MOV A,#' '
CALL UART_PUTC
MOV A,#'N'
CALL UART_PUTC
MOV A,#'o'
CALL UART_PUTC
MOV A,#'.'
CALL UART_PUTC
MOV A,#'1'
CALL UART_PUTC
MOV A,#'2'
CALL UART_PUTC
MOV A,#'!'
CALL UART_PUTC
MOV A,#0Ah
CALL UART_PUTC
MOV P1,#255
GoodMoring: MOV P1,#255
CJNE A,#01H,AfterNoon
MOV P1,#0
MOV A,#'G'
CALL UART_PUTC
MOV A,#'o'
CALL UART_PUTC
MOV A,#'o'
CALL UART_PUTC
MOV A,#'d'
CALL UART_PUTC
MOV A,#' '
CALL UART_PUTC
MOV A,#'M'
CALL UART_PUTC
MOV A,#'o'
CALL UART_PUTC
MOV A,#'r'
CALL UART_PUTC
MOV A,#'i'
CALL UART_PUTC
MOV A,#'n'
CALL UART_PUTC
MOV A,#'g'
CALL UART_PUTC
MOV A,#'!'
CALL UART_PUTC
MOV A,#0Ah
CALL UART_PUTC
MOV A,#255
JMP GoodMoring
AfterNoon: CJNE A,#02H,GoodNight
MOV P1,#0
MOV A,#'G'
CALL UART_PUTC
MOV A,#'o'
CALL UART_PUTC
MOV A,#'o'
CALL UART_PUTC
MOV A,#'d'
CALL UART_PUTC
MOV A,#' '
CALL UART_PUTC
MOV A,#'A'
CALL UART_PUTC
MOV A,#'f'
CALL UART_PUTC
MOV A,#'t'
CALL UART_PUTC
MOV A,#'e'
CALL UART_PUTC
MOV A,#'r'
CALL UART_PUTC
MOV A,#'n'
CALL UART_PUTC
MOV A,#'o'
CALL UART_PUTC
MOV A,#'o'
CALL UART_PUTC
MOV A,#'n'
CALL UART_PUTC
MOV A,#'!'
CALL UART_PUTC
MOV A,#0Ah
CALL UART_PUTC
MOV A,#255
JMP GoodMoring
GoodNight: CJNE A,#03H,Finish
MOV P1,#0
MOV A,#'G'
CALL UART_PUTC
MOV A,#'o'
CALL UART_PUTC
MOV A,#'o'
CALL UART_PUTC
MOV A,#'d'
CALL UART_PUTC
MOV A,#' '
CALL UART_PUTC
MOV A,#'N'
CALL UART_PUTC
MOV A,#'i'
CALL UART_PUTC
MOV A,#'g'
CALL UART_PUTC
MOV A,#'h'
CALL UART_PUTC
MOV A,#'t'
CALL UART_PUTC
MOV A,#'!'
CALL UART_PUTC
MOV A,#0Ah
CALL UART_PUTC
MOV A,#255
Finish: JMP GoodMoring
UART_ISR:
JB RI,RECEIVED
TRANSMITTED:
CLR UART_BUSY
CLR TI
RET
RECEIVED:
MOV A,SBUF
CLR RI
RET
UART_PUTC:
JB UART_BUSY,UART_PUTC
SETB UART_BUSY
MOV SBUF,A
RET
END