-
Notifications
You must be signed in to change notification settings - Fork 0
/
E0FILEIO.ASM
322 lines (296 loc) · 3.31 KB
/
E0FILEIO.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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
;********************************************************
;* SC80 text screen editor File I/O module Tape *
;* (c) TCHV,1989-93 *
;********************************************************
EXTRN nivgr,werhgr,START,CURX,BLBEG,BLEND
EXTRN JMPBL,OUT1, MARK,DISADR
RDFIL:: CALL DISHDL
JNZ RDF0
CALL PRINT
DW INFSTR
DB 'NOT FOUND',80H
CALL INPNAM
JMP RDFIL+3
RDF0: LHLD nivgr
CALL RDBOD
LHLD nivgr
MOV D,H
MOV E,L
CALL CONVRT
XCHG
SHLD werhgr
JMP START
RDBL:: LHLD CURX
PUSH H
CALL DISHDL
RDB00: JNZ RDB0
CALL INFPR
DW 0
DB 'NOT FOUND',80H
CALL INPNAM
JMP RDB00
RDB0: LHLD werhgr
INX H
CALL RDBOD
LHLD werhgr
INX H
SHLD BLBEG
MOV D,H
MOV E,L
CALL CONVR0
XCHG
SHLD BLEND
DCX H
SHLD werhgr
POP H
SHLD CURX
CALL JMPBL
JMP OUT1
CONVR0: MOV A,M
CPI 1AH
RZ
INX H
CPI 0AH
JZ CONVR0
STAX D
INX D
JMP CONVR0
CONVRT: CALL CONVR0
CONV0: DCX D
LDAX D
INX D
CPI 0DH
JZ CONV1
MVI A,0DH
STAX D
INX D
CONV1: MVI A,0FFH
STAX D
RET
DISHDL: CALL CLRSTR
CALL INFPR
DW 1
DC 'READ'
DISH0: CALL INFPR
DW 10
DC 'FILE:'
LXI H,FILNAM
LXI B,NAMMES
CALL INPSTR
RD20: CALL INFPR
DW 33
DC 'FILE:'
LXI H,FILNAM
LXI D,FCB
CALL GTFNAM
LXI D,80H
MVI C,1AH
CALL 5
LXI D,FCB
MVI C,11H
CALL 5 ; SEARCH FIRST
INR A
RZ
LXI H,80H
LXI B,20H
DSP0: DCR A
JZ DSP1
DAD B
JMP DSP0
DSP1: XCHG
LXI H,INFSTR+38
INX D
MVI B,8
CALL DSH00
MVI A,'.'
MOV M,A
INX H
MVI B,3
DSH00: LDAX D
MOV M,A
INX H
INX D
DCR B
JNZ DSH00
XRA A
INR A
RET
GTFNAM: MOV A,M
CPI 20H
JNZ GTN99
INX H
JMP GTFNAM
GTN99: PUSH D
XRA A
MVI C,25H
STAX D
INX D
DCR C
JNZ $-3
POP D
INX H
MOV A,M
DCX H
CPI ':'
JNZ GTNAM
MOV A,M
INX H
INX H
ANI 0FFH-20H
SUI 40H
STAX D
GTNAM: INX D
MVI C,8
CALL GTN0
MOV A,M
CPI '.'
JNZ $+4
INX H
MVI C,3
CALL GTN0
RET
GTN0: MOV A,M
CPI 61H
JC $+5
SUI 20H
INX H
CPI '.'
MVI B,20H
JZ GTN1
CPI 20H
JC GTN1
CPI '*'
MVI B,'?'
JZ GTN1
STAX D
INX D
DCR C
JNZ GTN0
GTN1: MOV A,B
INR C
DCR C
RZ
STAX D
INX D
JMP $-4
RDBOD: PUSH H ; READ FILE FROM DISK
LXI D,FCB
MVI C,0FH ; OPEN FILE
CALL 5
INR A
POP H
JNZ DS00
ERR1: CALL CLRSTR
CALL INFPR
DW 39
DB 'UNABLE OPEN FILE',80H
CALL GETCHR
JMP START
DS00:
RDLOOP: PUSH H
XCHG
MVI C,1AH
CALL 5
LXI D,5CH
MVI C,14H
CALL 5
POP H
LXI D,128
DAD D
ORA A
JZ RDLOOP
; pokamest perepolnenie ne opredelqem
LXI D,FCB
MVI C,10H
CALL 5
CALL MAXRAM
MVI M,1AH
RET
WRFIL::
CALL MARK
PUSH H
CALL DISHW
LHLD nivgr
XCHG
LHLD werhgr
XCHG
CALL WRSEG
POP H
JMP DISADR
WRBL:: CALL MARK
PUSH H
CALL DISHW
LHLD BLBEG
XCHG
LHLD BLEND
DCX H
XCHG
CALL WRSEG
POP H
JMP DISADR
WRSEG: PUSH H
PUSH D
LXI D,FCB
MVI C,13H ; ERASE FILE
CALL 5
LXI D,FCB
MVI C,16H ; OPEN FILE
CALL 5
LXI D,80H
MVI C,1AH
CALL 5
POP D
POP H
PUSH H
LXI H,80H
MVI B,80H
INX D
WRB00: XTHL
CALL CDEHL
JZ WRB10
MOV A,M
INX H
XTHL
CPI 0FFH
JZ WRB11
CPI 0DH
JNZ $+8
CALL TOBUF
MVI A,0AH
CALL TOBUF
JMP WRB00
TOBUF: MOV M,A
INX H
DCR B
RNZ
PUSHS: PUSH D
LXI D,FCB
MVI C,15H
CALL 5
POP D
MVI B,80H
LXI H,80H
RET
WRB10: XTHL
WRB11: MVI A,1AH
CALL TOBUF
POP H
MOV A,B
CPI 80H
CNZ PUSHS
LXI D,FCB
MVI C,10H
CALL 5
RET
DISHW: CALL CLRSTR
CALL INFPR
DW 1
DC 'WRITE'
CALL INFPR
DW 10
DC 'FILE:'
INPNAM: LXI H,FILNAM
LXI B,NAMMES
CALL INPSTR
JMP RD20
END