-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcode.asm
195 lines (170 loc) · 2.84 KB
/
code.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
org 0000h
mov P1, #0ffh;
start:clr p3.0;rly
mov P0,#00h;
mov P2,#00h;
setb p1.0;full==1
setb p1.1;mid==1
setb p1.2;empty==1
setb p1.3;t2==1
acall lcd;
jnb p1.3, main;t2==0
clr p0.3;if t2!=0
mov A,#01h;
acall command;
mov A,#80h;
acall command;
acall display;tank is empty
mov A,#0ch;
acall command;
acall display6;fill tank
main:setb p0.3;
jnb p1.2,next;
mov A,#01h;
acall command;
mov A,#80h;
acall command;
acall display;tank is empty
mov A,#0ch;
acall command;
acall display1;motor is on
next:jnb p1.1,next1;
setb p0.3;
mov A,#01h;
acall command;
mov A,#80h;
acall command;
acall display2;tank is filling
mov A,#0ch;
acall command;
acall display1;motor is on
next1:jnb p1.0,next2;
setb p0.3;
mov A,#01h;
acall command;
mov A,#80h;
acall command;
acall display3;tank is mid
mov A,#0ch;
acall command;
acall display1;motor is on
next2:clr p0.3;
mov A,#01h;
acall command;
mov A,#80h;
acall command;
acall display4;fill tank
mov A,#0ch;
acall command;
acall display5;motor is off
display:mov dptr,#table1;tank is empty
again:clr A;
movc A,@A+dptr;
jz skip;
mov p2,a;
acall data1;
inc dptr;
sjmp again;
skip:mov A,#0ch;
acall command;
display1:mov dptr,#table2;motor is on
again1:clr A;
movc A,@A+dptr;
jz skip1;
mov p2,a;
acall data1;
inc dptr;
sjmp again1;
skip1:mov A,#0ch;
acall command;
display2:mov dptr,#table3;tank is filling
again2:clr A;
movc A,@A+dptr;
jz skip2;
mov p2,a;
acall data1;
inc dptr;
sjmp again2;
skip2:mov A,#0ch;
acall command;
display3:mov dptr,#table4;tank is mid
again3:clr A;
movc A,@A+dptr;
jz skip3;
mov p2,a;
acall data1;
inc dptr;
sjmp again3;
skip3:mov A,#0ch;
acall command;
display4:mov dptr,#table5;tank is full
again4:clr A;
movc A,@A+dptr;
jz skip4;
mov p2,a;
acall data1;
inc dptr;
sjmp again4;
skip4:mov A,#0ch;
acall command;
display5:mov dptr,#table6;motor is off
again5:clr A;
movc A,@A+dptr;
jz skip5;
mov p2,a;
acall data1;
inc dptr;
sjmp again5;
skip5:mov A,#0ch;
acall command;
display6:mov dptr,#table7;fill tank
again6:clr A;
movc A,@A+dptr;
jz skip6;
mov p2,a;
acall data1;
inc dptr;
sjmp again6;
skip6:mov A,#0ch;
acall command;
lcd:mov A, #38h;
acall command;
mov A,#0eh;
acall command;
mov A,#01h;
acall command;
mov A,#06h;
acall command;
command:acall busy;
clr p0.0;rs
setb p0.1;rw
mov P2,A;
setb p0.2;en
nop;
clr p0.2;
ret;
busy:setb p2.7;busy flag
clr p0.0;rs
setb p0.1;rw
wait:clr p0.2;en
nop;
setb p0.2;
jb p2.7,wait;
ret;
data1:acall busy;
setb p0.0;rs
clr p0.1;rw
mov p2,A;
setb p0.2;en
nop;
clr p0.2;
ret;
org 0100h;
table1: db 'tank is empty',0;
table2: db 'motor is on',0;
table3: db 'tank is filling',0;
table4: db 'tank is mid',0;
table5: db 'tank is full',0;
table6: db 'motor is off',0;
table7: db 'fill tank',0;
end;