summaryrefslogtreecommitdiff
path: root/v2.0/source/EDLPROC.ASM
diff options
context:
space:
mode:
Diffstat (limited to 'v2.0/source/EDLPROC.ASM')
-rw-r--r--v2.0/source/EDLPROC.ASM531
1 files changed, 531 insertions, 0 deletions
diff --git a/v2.0/source/EDLPROC.ASM b/v2.0/source/EDLPROC.ASM
new file mode 100644
index 0000000..0128b1d
--- /dev/null
+++ b/v2.0/source/EDLPROC.ASM
@@ -0,0 +1,531 @@
1
2
3FALSE EQU 0
4TRUE EQU NOT FALSE
5
6KANJI EQU FALSE
7
8roprot equ FALSE ;set to TRUE if protection to r/o files
9 ; desired.
10FCB EQU 5CH
11
12Comand_Line_Length equ 128
13quote_char equ 16h ;quote character = ^V
14
15
16PAGE
17
18 .xlist
19 INCLUDE DOSSYM.ASM
20 .list
21
22
23SUBTTL Contants and Data areas
24PAGE
25
26PROMPT EQU "*"
27STKSIZ EQU 80H
28
29CODE SEGMENT PUBLIC
30CODE ENDS
31
32CONST SEGMENT PUBLIC WORD
33
34 EXTRN TXT1:BYTE,TXT2:BYTE,FUDGE:BYTE,HARDCH:DWORD,USERDIR:BYTE
35
36CONST ENDS
37
38DATA SEGMENT PUBLIC WORD
39
40 EXTRN OLDLEN:WORD,OLDDAT:BYTE,SRCHFLG:BYTE,COMLINE:WORD
41 EXTRN PARAM1:WORD,PARAM2:WORD,NEWLEN:WORD,SRCHMOD:BYTE
42 EXTRN CURRENT:WORD,POINTER:WORD,START:BYTE,ENDTXT:WORD
43 EXTRN USER_DRIVE:BYTE,LSTNUM:WORD,NUMPOS:WORD,LSTFND:WORD
44 EXTRN SRCHCNT:WORD
45
46DATA ENDS
47
48DG GROUP CODE,CONST,DATA
49
50CODE SEGMENT PUBLIC
51
52ASSUME CS:DG,DS:DG,SS:DG,ES:DG
53
54 PUBLIC REST_DIR,KILL_BL,INT_24,SCANLN,FINDLIN,SHOWNUM
55 PUBLIC FNDFIRST,FNDNEXT,CRLF,LF,OUT,UNQUOTE
56
57 if kanji
58 PUBLIC TESTKANJ
59 endif
60
61 EXTRN CHKRANGE:NEAR
62
63EDLPROC:
64
65RET1: RET
66
67FNDFIRST:
68 MOV DI,1+OFFSET DG:TXT1
69 mov byte ptr[olddat],1 ;replace with old value if none new
70 CALL GETTEXT
71 OR AL,AL ;Reset zero flag in case CX is zero
72 JCXZ RET1
73 cmp al,1ah ;terminated with a ^Z ?
74 jne sj8
75 mov byte ptr[olddat],0 ;do not replace with old value
76sj8:
77 MOV [OLDLEN],CX
78 XOR CX,CX
79 CMP AL,0DH
80 JZ SETBUF
81 CMP BYTE PTR [SRCHFLG],0
82 JZ NXTBUF
83SETBUF:
84 DEC SI
85NXTBUF:
86 MOV [COMLINE],SI
87 MOV DI,1+OFFSET DG:TXT2
88 CALL GETTEXT
89 CMP BYTE PTR [SRCHFLG],0
90 JNZ NOTREPL
91 CMP AL,0DH
92 JNZ HAVCHR
93 DEC SI
94HAVCHR:
95 MOV [COMLINE],SI
96NOTREPL:
97 MOV [NEWLEN],CX
98 MOV BX,[PARAM1]
99 OR BX,BX
100 JNZ CALLER
101 cmp byte ptr[srchmod],0
102 jne sj9
103 mov bx,1 ;start from line number 1
104 jmp short sj9a
105sj9:
106 MOV BX,[CURRENT]
107 INC BX ;Default search and replace to current+1
108sj9a:
109 CALL CHKRANGE
110CALLER:
111 CALL FINDLIN
112 MOV [LSTFND],DI
113 MOV [NUMPOS],DI
114 MOV [LSTNUM],DX
115 MOV BX,[PARAM2]
116 CMP BX,1
117 SBB BX,-1 ;Decrement everything except zero
118 CALL FINDLIN
119 MOV CX,DI
120 SUB CX,[LSTFND]
121 OR AL,-1
122 JCXZ aret
123 CMP CX,[OLDLEN]
124 jae sj10
125aret: ret
126sj10:
127 MOV [SRCHCNT],CX
128
129FNDNEXT:
130
131; Inputs:
132; [TXT1+1] has string to search for
133; [OLDLEN] has length of the string
134; [LSTFND] has starting position of search in text buffer
135; [LSTNUM] has line number which has [LSTFND]
136; [SRCHCNT] has length to be searched
137; [NUMPOS] has beginning of line which has [LSTFND]
138; Outputs:
139; Zero flag set if match found
140; [LSTFND],[LSTNUM],[SRCHCNT] updated for continuing the search
141; [NUMPOS] has beginning of line in which match was made
142
143 MOV AL,[TXT1+1]
144 MOV CX,[SRCHCNT]
145 MOV DI,[LSTFND]
146SCAN:
147 OR DI,DI ;Clear zero flag in case CX=0
148 REPNE SCASB
149 JNZ RET11
150 MOV DX,CX
151 MOV BX,DI ;Save search position
152 MOV CX,[OLDLEN]
153 DEC CX
154 MOV SI,2 + OFFSET DG:TXT1
155 CMP AL,AL ;Set zero flag in case CX=0
156if kanji
157 dec si ;Want to look at the first character again
158 dec di
159kanjchar:
160 lodsb
161 call testkanj
162 jz nxt_kj_char
163 xchg ah,al
164 lodsb
165 mov bx,[di]
166 add di,2
167 cmp ax,bx
168 jnz not_kj_match
169 dec cx
170 loop kanjchar
171nxt_kj_char:
172 cmp al,byte ptr[di]
173 jnz not_kj_match
174 inc di
175 loop kanjchar
176
177not_kj_match:
178else
179 REPE CMPSB
180endif
181 MOV CX,DX
182 MOV DI,BX
183 JNZ SCAN
184 MOV [SRCHCNT],CX
185 MOV CX,DI
186 MOV [LSTFND],DI
187 MOV DI,[NUMPOS]
188 SUB CX,DI
189 MOV AL,10
190 MOV DX,[LSTNUM]
191;Determine line number of match
192GETLIN:
193 INC DX
194 MOV BX,DI
195 REPNE SCASB
196 JZ GETLIN
197 DEC DX
198 MOV [LSTNUM],DX
199 MOV [NUMPOS],BX
200 XOR AL,AL
201RET11: RET
202
203
204GETTEXT:
205
206; Inputs:
207; SI points into command line buffer
208; DI points to result buffer
209; Function:
210; Moves [SI] to [DI] until ctrl-Z (1AH) or
211; RETURN (0DH) is found. Termination char not moved.
212; Outputs:
213; AL = Termination character
214; CX = No of characters moved.
215; SI points one past termination character
216; DI points to next free location
217
218 XOR CX,CX
219
220GETIT:
221 LODSB
222;-----------------------------------------------------------------------
223 cmp al,quote_char ;a quote character?
224 jne sj101 ;no, skip....
225 lodsb ;yes, get quoted character
226 call make_cntrl
227 jmp short sj102
228;-----------------------------------------------------------------------
229sj101:
230 CMP AL,1AH
231 JZ DEFCHK
232sj102:
233 CMP AL,0DH
234 JZ DEFCHK
235 STOSB
236 INC CX
237 JMP SHORT GETIT
238
239DEFCHK:
240 OR CX,CX
241 JZ OLDTXT
242 PUSH DI
243 SUB DI,CX
244 MOV BYTE PTR [DI-1],cl
245 POP DI
246 RET
247
248OLDTXT:
249 cmp byte ptr[olddat],1 ;replace with old text?
250 je sj11 ;yes...
251 mov byte ptr[di-1],cl ;zero text buffer char count
252 ret
253
254sj11:
255 MOV CL,BYTE PTR [DI-1]
256 ADD DI,CX
257 RET
258
259
260FINDLIN:
261
262; Inputs
263; BX = Line number to be located in buffer (0 means last line)
264; Outputs:
265; DX = Actual line found
266; DI = Pointer to start of line DX
267; Zero set if BX = DX
268; AL,CX destroyed. No other registers affected.
269
270 MOV DX,[CURRENT]
271 MOV DI,[POINTER]
272 CMP BX,DX
273 JZ RET4
274 JA FINDIT
275 OR BX,BX
276 JZ FINDIT
277 MOV DX,1
278 MOV DI,OFFSET DG:START
279 CMP BX,DX
280 JZ RET4
281FINDIT:
282 MOV CX,[ENDTXT]
283 SUB CX,DI
284SCANLN:
285 MOV AL,10
286 OR AL,AL ;Clear zero flag
287FINLIN:
288 JCXZ RET4
289 REPNE SCASB
290 INC DX
291 CMP BX,DX
292 JNZ FINLIN
293RET4: RET
294
295
296SHOWNUM:
297
298; Inputs:
299; BX = Line number to be displayed
300; Function:
301; Displays line number on terminal in 8-character
302; format, suppressing leading zeros.
303; AX, CX, DX destroyed. No other registers affected.
304
305 PUSH BX
306 MOV AL," "
307 CALL OUT
308 CALL CONV10
309 MOV AL,":"
310 CALL OUT
311 MOV AL,"*"
312 POP BX
313 CMP BX,[CURRENT]
314 JZ STARLIN
315 MOV AL," "
316STARLIN:
317 JMP OUT
318
319
320CONV10:
321
322;Inputs:
323; BX = Binary number to be displayed
324; Function:
325; Ouputs binary number. Five digits with leading
326; zero suppression. Zero prints 5 blanks.
327
328 XOR AX,AX
329 MOV DL,AL
330 MOV CX,16
331CONV:
332 SHL BX,1
333 ADC AL,AL
334 DAA
335 XCHG AL,AH
336 ADC AL,AL
337 DAA
338 XCHG AL,AH
339 ADC DL,DL
340 LOOP CONV
341 MOV BL,"0"-" "
342 XCHG AX,DX
343 CALL LDIG
344 MOV AL,DH
345 CALL DIGITS
346 MOV AL,DL
347DIGITS:
348 MOV DH,AL
349 SHR AL,1
350 SHR AL,1
351 SHR AL,1
352 SHR AL,1
353 CALL LDIG
354 MOV AL,DH
355LDIG:
356 AND AL,0FH
357 JZ ZERDIG
358 MOV BL,0
359ZERDIG:
360 ADD AL,"0"
361 SUB AL,BL
362 JMP OUT
363
364RET5: RET
365
366
367CRLF:
368 MOV AL,13
369 CALL OUT
370LF:
371 MOV AL,10
372OUT:
373 PUSH DX
374 XCHG AX,DX
375 MOV AH,STD_CON_OUTPUT
376 INT 21H
377 XCHG AX,DX
378 POP DX
379 RET
380
381
382;-----------------------------------------------------------------------;
383; Will scan buffer given pointed to by SI and get rid of quote
384;characters, compressing the line and adjusting the length at the
385;begining of the line.
386; Preserves al registers except flags and AX .
387
388unquote:
389 push cx
390 push di
391 push si
392 mov di,si
393 mov cl,[si-1] ;length of buffer
394 xor ch,ch
395 mov al,quote_char
396 cld
397unq_loop:
398 jcxz unq_done ;no more chars in the buffer, exit
399 repnz scasb ;search for quote character
400 jnz unq_done ;none found, exit
401 push cx ;save chars left in buffer
402 push di ;save pointer to quoted character
403 push ax ;save quote character
404 mov al,byte ptr[di] ;get quoted character
405 call make_cntrl
406 mov byte ptr[di],al
407 pop ax ;restore quote character
408 mov si,di
409 dec di ;points to the quote character
410 inc cx ;include the carriage return also
411 rep movsb ;compact line
412 pop di ;now points to after quoted character
413 pop cx
414 jcxz sj13 ;if quote char was last of line do not adjust
415 dec cx ;one less char left in the buffer
416sj13: pop si
417 dec byte ptr[si-1] ;one less character in total buffer count also
418 push si
419 jmp short unq_loop
420
421unq_done:
422 pop si
423 pop di
424 pop cx
425 ret
426
427
428;-----------------------------------------------------------------------;
429; Convert the character in AL to the corresponding control
430; character. AL has to be between @ and _ to be converted. That is,
431; it has to be a capital letter. All other letters are left unchanged.
432
433make_cntrl:
434 push ax
435 and ax,11100000b
436 cmp ax,01000000b
437 pop ax
438 jne sj14
439 and ax,00011111b
440sj14:
441 ret
442
443
444;---- Kill spaces in buffer --------------------------------------------;
445kill_bl:
446 lodsb ;get rid of blanks
447 cmp al,' '
448 je kill_bl
449 ret
450
451
452;----- Restore INT 24 vector and old current directory -----------------;
453rest_dir:
454 cmp [fudge],0
455 je no_fudge
456
457 mov ax,(set_interrupt_vector shl 8) or 24h
458 lds dx,[hardch]
459 int 21h
460 push cs
461 pop ds
462
463 mov dx,offset dg:userdir ;restore directory
464 mov ah,chdir
465 int 21h
466 mov dl,[user_drive] ;restore old current drive
467 mov ah,set_default_drive
468 int 21h
469
470no_fudge:
471 ret
472
473;----- INT 24 Processing -----------------------------------------------;
474
475int_24_retaddr dw offset dg:int_24_back
476
477int_24 proc far
478assume ds:nothing,es:nothing,ss:nothing
479
480 pushf
481 push cs
482 push [int_24_retaddr]
483 push word ptr [hardch+2]
484 push word ptr [hardch]
485 ret
486int_24 endp
487
488int_24_back:
489 cmp al,2 ;abort?
490 jnz ireti
491 push cs
492 pop ds
493
494assume ds:dg
495
496 call rest_dir
497 int 20h
498ireti:
499 iret
500
501 IF KANJI
502TESTKANJ:
503 CMP AL,81H
504 JB NOTLEAD
505 CMP AL,9FH
506 JBE ISLEAD
507 CMP AL,0E0H
508 JB NOTLEAD
509 CMP AL,0FCH
510 JBE ISLEAD
511NOTLEAD:
512 PUSH AX
513 XOR AX,AX ;Set zero
514 POP AX
515 RET
516
517ISLEAD:
518 PUSH AX
519 XOR AX,AX ;Set zero
520 INC AX ;Reset zero
521 POP AX
522 RET
523 ENDIF
524
525;-----------------------------------------------------------------------;
526
527CODE ENDS
528 END EDLPROC
529
530
531 \ No newline at end of file