-
Notifications
You must be signed in to change notification settings - Fork 6
/
HEX RECV.asm
119 lines (109 loc) · 1.74 KB
/
HEX RECV.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
10 ORG 2000H
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
170MAIN: CALL INITSR
180 CALL OPENSR
190 CALL CLS
200 LD HL, GREET
210 CALL STRLN
220 LD DE, 00004H
230 CALL PUTSTR
240LOOP00: LD HL, BUFFER
250 CALL LRDSR
260 LD HL, BUFFER
270 LD A,(HL)
280 CP ':'
290 JP NZ,FMTERR
300 INC HL
310 CALL GETBY
320 CP A,0
330 JP Z,THEEND
340 LD (NUMBY),A
350 INC HL
360 CALL GETBY
370 LD (ADDR1),A
380 INC HL
390 CALL GETBY
400 LD (ADDR0),A
410 LD DE,(ADDR0)
420 LD BC,(NUMBY)
430LOOP01: CALL GETBY
440 LD (DE),A
450 INC DE
460 DJNZ, LOOP01
470 JP LOOP00
1000GETBY: LD A,(HL)
1010 CP '0'
1020 JP C,LOOP0X
1030 CP 'G'
1040 JP NC,LOOP0X
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
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 'Send binhex',0
5010BUFFER: DEFS 44
5020 DB 0
5030BYE: DB 'Good Bye...',0