-
Notifications
You must be signed in to change notification settings - Fork 0
/
test4.asm
222 lines (196 loc) · 5.02 KB
/
test4.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
org 0
;
; read inport direct after reset to determine which program to run
in a,(0)
cp 0feh
jp z,ramtst ; ram test - test 32k ram chip with 0x55, 0xaa. halt on any error
cp 0fdh
jp z,iotst ; io test - just mirror inport to outport
cp 0fch
jp z,dice ; roll a dice results in show 1..6
;
; fall though to hello program if no switch it set
;---------------------------------------------
; welcome msg 'HELLo USEr'
hello: ld a,(ledh)
call outchr
ld a,(lede)
call outchr
ld a,(ledl)
call outchr
ld a,(ledl)
call outchr
ld a,(ledo)
call outchr
call outspc
ld a,(ledu)
call outchr
ld a,(leds)
call outchr
ld a,(lede)
call outchr
ld a,(ledr)
call outchr
call outspc
jp hello
;---------------------------------------------
iotst:
in a,(0)
out (0),a
jp iotst
;---------------------------------------------
dice:
ld a,(ledmin) ; show '-' to wait for input 0xff (all switches off)
out (0),a
dice2: in a,(0)
cp 0ffh
jp nz,dice2 ; if in is not 0xff, wait..
ld a,(ledspc) ; clear '-'; start 'rolling a dice'
out (0),a
dice3: ld b,-1
dice4: inc b
ld a,b
cp 6 ; if 6 ->
jp z,dice3 ; -> reset to 0 (we only want 0..5)
in a,(0) ; check if any switch is on (in != 0xff)
cp 0ffh
jp z,dice4 ; no switch - continue inc b..
inc b ; here: any switch was triggered; b is now 1..6
ld a,b ; out led 6
cp 6
jp nz,dice5
ld a,(led6)
out (0),a
jp dice2 ; another roll the dice..
dice5: ld a,b ; out led 5
cp 5
jp nz,dice6
ld a,(led5)
out (0),a
jp dice2 ; another roll the dice..
dice6: ld a,b ; out led 4
cp 4
jp nz,dice7
ld a,(led4)
out (0),a
jp dice2 ; another roll the dice..
dice7: ld a,b ; out led 3
cp 3
jp nz,dice8
ld a,(led3)
out (0),a
jp dice2 ; another roll the dice..
dice8: ld a,b ; out led 2
cp 2
jp nz,dice9
ld a,(led2)
out (0),a
jp dice2 ; another roll the dice..
dice9: ld a,(led1) ; out led 1
out (0),a
jp dice2 ; another roll the dice..
;---------------------------------------------
ramtst: ld bc,led0 ;bc points to ledn
ld d,10 ;count runs 0-9 loop
ld a,(bc)
; ld a,(led0) ;11000000b
out (0),a
rambeg:
ld hl,08000h ;mem start
ramtst2:
ld a,55h
ld (hl),a
ld a,(hl)
cp 55h
jp nz,fail
ld a,0aah
ld (hl),a
ld a,(hl)
cp 0aah
jp nz,fail
inc hl ;mem end ffffh -> 0
ld a,h
cp 0
jp nz,ramtst2
ld a,l
cp 0
jp nz,ramtst2
dec d
jp z,ramtst
inc bc ;bc points no next ledn code
ld a,(bc)
out (0),a
jp rambeg
fail: halt
outchr: ;A contains led value
ld e,20 ;delay value char
out (0),a
call delaye
ld e,5 ;some blank time after each char
ld a,(ledspc)
out (0),a ;blank
call delaye
ret
outspc: ld e,100
ld a,(ledspc)
out (0),a ;blank
call delaye
ret
delaye: call delay1 ;256 x NOP
dec e
jp nz,delaye ;times e
ret
delay1: ld a,0 ;256 x NOP; A is destroyed
del11: nop
inc a
jp nz,del11
del12: ret
;ledX defb 1gfedcbab --a--
; | |
; f b
; | |
; --g--
; | |
; e c
; | |
; --d--
;
led0: defb 11000000b ; 0: c0h a, b, c, d, e, f
led1: defb 11111001b ; 1: f9h b, c
led2: defb 10100100b ; 2: a4h a, b, d, e, g
led3: defb 10110000b ; 3: b0h a, b, c, d, g
led4: defb 10011001b ; 4: 99h b, c, f, g
led5: defb 10010010b ; 5: 92h a, c, d, f, g
led6: defb 10000010b ; 6: 82h a, c, d, e, f, g
led7: defb 11111000b ; 7: f8h a, b, c
led8: defb 10000000b ; 8: 80h a, b, c, d, e, f, g
led9: defb 10010000b ; 9: 90h a, b, c, d, f, g
ledmin: defb 10111111b ; -: bfh g
ledspc: defb 11111111b ; : ffh
leda: defb 10001000b ; A: 88h a, b, c, e, f, g
ledb: defb 10000011b ; b: 83h c, d, e, f, g
ledc: defb 11000110b ; C: c6h a, d, e, f
ledd: defb 10100001b ; d: a1h b, c, d, e, g
lede: defb 10000110b ; E: 86h a, d, e, f, g
ledf: defb 10001000b ;
ledg: defb 10001000b ;
ledh: defb 10001001b ; H: 89h b, c, e, f, g
ledi: defb 10001000b ;
ledj: defb 10001000b ;
ledk: defb 10001000b ;
ledl: defb 11000111b ; L: c7h d, e, f
ledm: defb 10001000b ;
ledn: defb 10001000b ;
ledo: defb 10100011b ; o: a3h c, d, e, g
ledp: defb 10001000b ;
ledq: defb 10001000b ;
ledr: defb 10101111b ; r: afh e, g
leds: defb 10010010b ; S: 92h a, c, d, f, g
ledt: defb 10001000b ;
ledu: defb 11000001b ; U: c1h b, c, d, e ,f
ledv: defb 10001000b ;
ledw: defb 10001000b ;
ledx: defb 10001000b ;
ledy: defb 10001000b ;
ledz: defb 10001000b ;
end