-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathHEX test.asm
161 lines (148 loc) · 2.46 KB
/
HEX test.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
10 ORG 100H
20 JP MAIN
30WRASR EQU 0BFAFH
40PUTSTR EQU 0BFF1H
50INKEY EQU 089BEH
60PUTCHR EQU 0BE62H
70INITSR EQU 0871AH
80AOUT EQU 0BD09H
90OPENSR EQU 0BCE8H
100CLOSSR EQU 0BCEBH
110LRDSR EQU 0BD15H
120WAITK EQU 0BFCDH
130WCHRSR EQU 0BFAFH
140WSTSR EQU 0BFB2H
150A2HEX EQU 0F9BDH
160RPTCHR EQU 0BFEEH
170OUTPUT: DB 0,0,0,0,0,0,0,0
180 DB 0,0,0,0,0,0,0,0
190 DB 0,0,0,0,0,0,0,0
200 DB 0,0,0,0,0,0,0,0
210 DB 0,0,0,0,0,0,0,0
220 DB 0,0,0,0,0,0,0,0
230 DB 0,0,0,0,0,0,0,0
240 DB 0,0,0,0,0,0,0,0
250 DB 0,0,0,0,0,0,0,0
260 DB 0,0,0,0,0,0,0,0
270 DB 0,0,0,0,0,0,0,0
280 DB 0,0,0,0,0,0,0,0
290 DB 0,0,0,0,0,0,0,0
300 DB 0,0,0,0,0,0,0,0
310 DB 0,0,0,0,0,0,0,0
320 DB 0,0,0,0,0,0,0,0
330BUFFER: DB ':10010000'
340 DB 'CDA201214302CDC6'
350 DB '01110000CDF1BF3EB9'
360 DB 0
370MAIN: CALL INITSR
380 CALL OPENSR
390 CALL CLS
400 LD HL, GREET
410 CALL STRLN
420 LD DE, 00004H
430 CALL PUTSTR
440LOOP00: LD HL, BUFFER
450 CALL STRLN
460 LD DE, 00000H
470 CALL PUTSTR
480 LD DE,OUTPUT
490 LD HL, BUFFER
500 LD A,(HL)
510 CP ':'
520 JP NZ,FMTERR
530 INC HL
540 CALL GETBY
550 CP 0
560 JP Z,THEEND
570 LD (NUMBY),A
580 INC HL
590 CALL GETBY
600 LD (DE),A
610 INC HL
620 INC DE
630 CALL GETBY
640 LD (DE),A
650 INC HL
660 INC DE
670 LD BC,(NUMBY)
680LOOP01: CALL GETBY
690 LD (DE),A
700 INC DE
710 DJNZ LOOP01
720 RET
1000GETBY: LD A,(HL)
1010 CP '0'
1020 JP C,GETBYX
1030 CP 'G'
1040 JP NC,GETBYX
1050 CP 'A'
1060 JP NC,GETBY1
1070 SUB 7 ; A-F
1080GETBY1: SUB 48
1090 LD B,A
1100 SLA B
1110 SLA B
1120 SLA B
1130 SLA B ; MULT 16
1140 INC HL
1150 LD A,(HL)
1160 CP '0'
1170 JP C,GETBYX
1180 CP 'G'
1190 JP NC,GETBYX
1200 CP 'A'
1210 JP NC,GETBY2
1220 SUB 7 ; A-F
1230GETBY2: SUB 48
1240 ADD A,B ; A CONTAINS BYTE
1250 RET
1260GETBYX: CALL FMTERR
1270 RET
1970ADDR0: DB 0
1980ADDR1: DB 0
1990NUMBY: DB 0,0
2000FMTERR: CALL CLS
2010 LD HL, GREET
2020 CALL STRLN
2030 LD DE, 00000H
2040 CALL PUTSTR
2050WAIT: CALL WAITK
2060 CP 0
2070 JP Z,WAIT
2080 RET
2090THEEND: LD A,0
2100 OUT (67H),A
2110 LD HL,BYE
2120 CALL STRLN
2130 LD DE,0500H
2140 CALL PUTSTR
2150 RET
2200CLS: LD A,144
2210 LD (CLSN),A
2220 LD DE,0
2230 LD (CLSX),DE
2240 LD A,32
2250 LD (CHAR),A
2260CLS0: LD A,(CLSN)
2270 LD B,A
2280 LD A,(CHAR)
2290 LD DE,(CLSY)
2300 CALL RPTCHR
2310 RET
2320CLSN: DB 144
2330CLSY: DB 0
2340CLSX: DB 0
2350CHAR: DB 32
3450STRLN: LD B,0
3460 PUSH HL
3470STRLN0: LD A,(HL)
3480 CP 0
3490 JP Z,STRLN1
3500 INC HL
3510 INC B
3520 JP STRLN0
3530STRLN1: POP HL
3540 RET
5000GREET: DB 'Let's go'',0
5050BYE: DB 'Good Bye...',0