-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.asm
271 lines (258 loc) · 3.92 KB
/
main.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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
ORG 0000h
mov p2,#10111111b
mov p1,#00111111b
mov p3,#00111111b
clr p0.6
clr p0.7
clr p0.5
ljmp 1000h
ORG 1000h
repeat:
clr p0.0
setb p0.0
mov a,#0AAh
mov r0,#0d
lcall START
ljmp repeat
START:
lcall f_send
lcall f_read
lcall f_display
ret
f_send:
inc r0
clr p0.1
rrc a
mov p0.2,c
setb p0.1
cjne r0,#8d,f_wyslij
ret
f_read:
clr a
mov r0,#0d
times_8:
inc r0
clr p0.1
mov c,p0.2
rrc a
setb p0.1
cjne r0,#08d,times_8
mov r6,a
mov a,#0d
clr p0.1
mov c,p0.2
rlc a
setb p0.1
mov r7,a
clr p0.0
ret
f_display:
mov a,r7
cjne a,#0d,bridge
;posivite
clr p0.6
mov a,r6
rrc a
jnc calkowita_plus
dec a
mov p3,#01101101b
ljmp ustaw_0_plus
calkowita_plus:
mov p3,#00111111b
ustaw_0_plus:
mov b,#100d
div ab
check_zeroS: ;handles display
cjne a,#0d,check_oneS
clr p0.7
clr p0.5
clr p0.6
ljmp ustawione
check_oneS:
cjne a,#1d,ustawione
setb p0.7
setb p0.5
clr p0.6
ljmp ustawione
ustawione:
mov a,b
mov b,#10d
div ab
check_zero_plus: ;handles display
cjne a,#0d,check_one_plus
mov p1,#00111111b
ljmp dziesiatki_plus
check_one_plus:
cjne a,#1d,check_two_plus
mov p1,#00000110b
ljmp dziesiatki_plus
check_two_plus:
cjne a,#2d,check_3_plus
mov p1,#01011011b
ljmp dziesiatki_plus
check_3_plus:
cjne a,#3d,check_4_plus
mov p1,#01001111b
ljmp dziesiatki_plus
check_4_plus:
cjne a,#4d,check_5_plus
mov p1,#01100110b
ljmp dziesiatki_plus
check_5_plus:
cjne a,#5d,check_6_plus
mov p1,#01101101b
ljmp dziesiatki_plus
check_6_plus:
cjne a,#6d,check_7_plus
mov p1,#01111101b
ljmp dziesiatki_plus
check_7_plus:
cjne a,#7d,check_8_plus
mov p1,#00000111b
ljmp dziesiatki_plus
bridge: ;unknown
mov a,r7
cjne a,#0d,negative
check_8_plus:
cjne a,#8d,check_9_plus
mov p1,#01111111b
ljmp dziesiatki_plus
check_9_plus:
mov p1,#01101111b
dziesiatki_plus:
mov a,b
check_zeroJ_plus:
cjne a,#0d,check_oneJ_plus
mov p2,#10111111b
ljmp done
check_oneJ_plus:
cjne a,#1d,check_twoJ_plus
mov p2,#10000110b
ljmp done
check_twoJ_plus:
cjne a,#2d,check_3j_plus
mov p2,#11011011b
ljmp done
check_3j_plus:
cjne A,#3d,check_4j_plus
mov p2,#11001111b
ljmp done
check_4j_plus:
cjne A,#4d,check_5j_plus
mov p2,#11100110b
ljmp done
check_5j_plus:
cjne A,#5d,check_6j_plus
mov p2,#11101101b
ljmp done
check_6j_plus:
cjne A,#6d,check_7j_plus
mov p2,#11111101b
ljmp done
check_7j_plus:
cjne A,#7d,check_8j_plus
mov p2,#10000111b
ljmp done
check_8j_plus:
cjne A,#8d,check_9j_plus
mov p2,#11111111b
ljmp done
check_9j_plus:
mov p2,#11101111b
ljmp done
negative:
mov p0,#01000000b
mov a,r6
cpl a
rrc a
inc a
jc calkowita
dec a
mov p3,#01101101b
ljmp ustaw_0
calkowita:
mov p3,#00111111b
ustaw_0:
mov b,#10d
div ab
check_zero: ;handles display
cjne a,#0d,check_one
mov p1,#00000000b
ljmp dziesiatki
check_one:
cjne a,#1d,check_two
mov p1,#00000110b
ljmp dziesiatki
check_two:
cjne a,#2d,check_3
mov p1,#01011011b
ljmp dziesiatki
check_3:
cjne a,#3d,check_4
mov p1,#01001111b
ljmp dziesiatki
check_4:
cjne a,#4d,check_5
mov p1,#01100110b
ljmp dziesiatki
check_5:
cjne a,#5d,check_6
mov p1,#01101101b
ljmp dziesiatki
check_6:
cjne a,#6d,check_7
mov p1,#01111101b
ljmp dziesiatki
check_7:
cjne a,#7d,check_8
mov p1,#00000111b
ljmp dziesiatki
check_8:
cjne a,#8d,check_9
mov p1,#01111111b
ljmp dziesiatki
check_9:
mov p1,#01101111b
dziesiatki:
mov a,b
check_zeroJ:
cjne a,#0d,check_oneJ
mov p2,#10111111b
ljmp done
check_oneJ:
cjne a,#1d,check_twoJ
mov p2,#10000110b
ljmp done
check_twoJ:
cjne a,#2d,check_3j
mov p2,#11011011b
ljmp done
check_3j:
cjne A,#3d,check_4j
mov p2,#11001111b
ljmp done
check_4j:
cjne A,#4d,check_5j
mov p2,#11100110b
ljmp done
check_5j:
cjne A,#5d,check_6j
mov p2,#11101101b
ljmp done
check_6j:
cjne A,#6d,check_7j
mov p2,#11111101b
ljmp done
check_7j:
cjne A,#7d,check_8j
mov p2,#10000111b
ljmp done
check_8j:
cjne A,#8d,check_9j
mov p2,#11111111b
ljmp done
check_9j:
mov p2,#11101111b
done:
ret
END