-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDUMP8000.asm
221 lines (196 loc) · 3.57 KB
/
DUMP8000.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
10 ORG 100H
20 JP MAIN
30PUTSTR EQU 0BFF1H
40PUTCHR EQU 0BE62H
50WAITK EQU 0BFCDH
60RPTCHR EQU 0BFEEH
70BUFFER: DB 'THIS BE NO TEST BRA! ['
80BUF00: DB 0,']',0
90BUFBUF: DEFS 24
100 DB 0
110MYPIN: DB 0
120MAIN: LD A,1
130 OUT (60H),A ; 8-BIT PIO
140 LD A,0
150 OUT (61H),A ; ALL OUTPUT
160MAIN03: CALL CLS
170 LD HL,GREET
180 CALL STRLN
190 LD DE,0000H
200 CALL PUTSTR
210 LD HL,GREET0
220 CALL STRLN
230 LD DE,0100H
240 CALL PUTSTR
250MAIN00: CALL WAITK
260 CALL MX2KEY
270 CP 'Q'
280 JP Z,THEEND
290 CP '0'
300 JP M,MAIN00
310 CP '8'
320 JP P,MAIN00
330 LD HL,PIN00
340 LD (HL),A
350 LD HL,BUF00
360 LD (HL),A
370 SUB 47
380 CP 1
390 JP Z,MAIN01
400 DEC A
410 LD B,A
420 LD A,1
430MAIN02: RLCA
440 AND 0FEH
450 DJNZ MAIN02
460MAIN01: LD (MYPIN),A
470 LD HL,PIN01
480 CALL BYTE
490 LD HL,PIN
500 CALL STRLN
510 LD DE,0200H
520 CALL PUTSTR
530 LD A,(MYPIN)
540 LD HL,BUFFER
550 CALL STRLN
560 LD DE,0300H
570 CALL PUTSTR
580 LD HL,BUFFER
590 LD DE,8000H
600 CALL STRLN
610 CALL RAMON
620MAIN0: LD A,(HL)
630 CP 65
640 JP M,MAIN1
650 ADD A,32 ; lowercase
660MAIN1: LD (DE),A
670 INC HL
680 INC DE
690 DJNZ MAIN0
700 CALL RAMOFF
710 CALL RAMON
720 LD HL,8000H
730 LD DE,BUFBUF
740 CALL STRLN
750MAIN2: LD A,(HL)
760 LD (DE),A
770 INC HL
780 INC DE
790 DJNZ MAIN2
800 CALL RAMOFF
810 LD HL,BUFBUF
820 CALL STRLN
830 LD DE,0400H
840 CALL PUTSTR
850 CALL WAITK
860 JP MAIN03
870THEEND: CALL CLS
890 RET
900CLS: LD B,144
910 LD DE,0
920CLS0: LD A,32
930 CALL RPTCHR
940 RET
950CLLN: LD B,24
960 LD E,0
970 JP CLS0
980RAMON:
990 LD A,(MYPIN)
1000 OUT (62H),A
1010 DI
1020 XOR A
1030 OUT (62H),A
1040 LD A,(MYPIN)
1050 OUT (62H),A
1060 IN A,(17H)
1070 LD (V19A),A
1080 XOR A
1090 OUT (62H),A
1100 LD A,(MYPIN)
1110 OUT (62H),A
1120 XOR A
1130 OUT (17H),A ; disable periph. interrupts
1140 OUT (62H),A
1150 LD A,(MYPIN)
1160 OUT (62H),A
1170 IN A, (19H)
1180 LD (V19B),A
1190 XOR A
1200 OUT (62H),A
1210 LD A,(MYPIN)
1220 OUT (62H),A
1230 LD A,(V19B)
1240 LD B, 50H ; /CEROM2=L, BANK1=0, BANK0=1
1250 OR B
1260 OUT (19H),A ; enable ext. ram to 0x8000-0xC0000
1270 XOR A
1280 OUT (62H),A
1290 RET
1300RAMOFF: LD A,(MYPIN)
1310 OUT (62H),A
1320 LD A,(V19B)
1330 OUT (19H),A
1340 XOR A
1350 OUT (62H),A
1360 LD A,(MYPIN)
1370 OUT (62H),A
1380 LD A,(V19A)
1390 OUT (17H),A ; re-enable ROM
1400 XOR A
1410 OUT (62H),A
1420 LD A,(MYPIN)
1430 OUT (62H),A
1440 EI
1450 XOR A
1460 OUT (62H),A
1470 RET
1480V19A: DB 0
1490V19B: DB 0
1500STRLN: LD B,0
1510 PUSH HL ; preserve HL
1520STRLN0: LD A,(HL)
1530 CP 0
1540 JP Z,STRLN1
1550 INC HL
1560 INC B
1570 JP STRLN0
1580STRLN1: POP HL ; restore HL
1590 RET
1600MX2KEY: LD B,0
1610 LD C,A ; A IS KEY INDEX
1620 LD HL,MATRIX
1630 ADD HL,BC
1640 LD A,(HL)
1650 RET
1660MATRIX: DB 0,0FFH
1670 DB 'QWERTYUASDFGHJKZXCVBNM,'
1680 DB 0FFH,0FFH,0FFH,0FFH,9,32,10,11,14,15 ; LEFT RIGHT UP DOWN
1690 DB 0FFH,'0.=+',13,'L;',0FFH,'123-'
1700 DB 0FFH,'IO',0FFH,'456*',0FFH,'P',8,0FFH,'789/)'
1710 DB 0FFH,0FFH,0FFH,0FFH,'(',0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
1720 DB 0,12,0FFH
1730GREET: DB 'Hit key to start',0
1740GREET0: DB '0. 1. 2. 3. 4. 5. 6. 7',0
1750BYTE: PUSH AF
1760 AND 0F0H
1770 RRCA
1780 RRCA
1790 RRCA
1800 RRCA
1810 CALL NIBBLE
1820 INC HL
1830 POP AF
1840 AND 15
1850 CALL NIBBLE
1860 INC HL
1870 RET
1880NIBBLE: SUB 10
1890 JP M,ZERO9
1900 ADD A,7
1910ZERO9: ADD A,58
1920 LD (HL),A
1930 RET
1940PIN: DB 'You picked '
1950PIN00: DB 0,', ie 0x'
1960PIN01: DB 0,0,0