summaryrefslogtreecommitdiff
path: root/v4.0/src/CMD/EDLIN/EDLCMD2.ASM
diff options
context:
space:
mode:
Diffstat (limited to 'v4.0/src/CMD/EDLIN/EDLCMD2.ASM')
-rw-r--r--v4.0/src/CMD/EDLIN/EDLCMD2.ASM1203
1 files changed, 1203 insertions, 0 deletions
diff --git a/v4.0/src/CMD/EDLIN/EDLCMD2.ASM b/v4.0/src/CMD/EDLIN/EDLCMD2.ASM
new file mode 100644
index 0000000..decc228
--- /dev/null
+++ b/v4.0/src/CMD/EDLIN/EDLCMD2.ASM
@@ -0,0 +1,1203 @@
1 PAGE 60,132
2TITLE Edlcmd2 - PART2 procedures called from EDLIN
3
4
5;======================= START OF SPECIFICATIONS =========================
6;
7; MODULE NAME: EDLCMD2.SAL
8;
9; DESCRIPTIVE NAME: EDLIN ROUTINES
10;
11; FUNCTION: THIS MODULE PROVIDES ROUTINES NEEDED FOR EDLIN'S EXECUTION.
12;
13; ENTRY POINT: ANY CALLED ROUTINE
14;
15; EXIT NORMAL: NA
16;
17; EXIT ERROR : NA
18;
19; INTERNAL REFERENCES:
20;
21; EXTERNAL REFERENCES:
22;
23; ROUTINE: EDLCMD1 - ROUTINES MAY BE CALLED FROM EDLCMD1
24; EDLMES - ROUTINES MAY BE CALLED FROM EDLMES
25;
26; NOTES: THIS MODULE IS TO BE PREPPED BY SALUT WITH THE "PR" OPTIONS.
27; LINK EDLIN+EDLCMD1+EDLCMD2+EDLMES+EDLPARSE
28;
29;
30; REVISION HISTORY:
31;
32; AN000 VERSION DOS 4.00 - REVISIONS MADE RELATE TO THE FOLLOWING:
33;
34; - IMPLEMENT SYSPARSE
35; - IMPLEMENT MESSAGE RETRIEVER
36; - IMPLEMENT DBCS ENABLING
37; - ENHANCED VIDEO SUPPORT
38; - EXTENDED OPENS
39; - SCROLLING ERROR
40;
41; COPYRIGHT: "MS DOS EDLIN UTILITY"
42; "VERSION 4.00 (C) COPYRIGHT 1988 Microsoft"
43;
44;======================= END OF SPECIFICATIONS ===========================
45
46include edlequ.asm
47
48CODE SEGMENT PUBLIC
49CODE ENDS
50
51CONST SEGMENT PUBLIC WORD
52CONST ENDS
53
54cstack segment stack
55cstack ends
56
57DATA SEGMENT PUBLIC WORD
58DATA ENDS
59
60
61DG GROUP CODE,CONST,cstack,DATA
62
63CONST SEGMENT PUBLIC WORD
64 extrn crlf_ptr:byte,lf_ptr:byte,qmes_ptr:byte,ask_ptr:byte
65 extrn bak:byte,$$$file:byte,delflg:byte,loadmod:byte,txt1:byte
66 extrn txt2:byte,memful_ptr:word,YES_BYTE:BYTE
67
68 extrn Del_Bak_Ptr:byte ;an000;dms;
69 extrn cont_ptr:byte ;an000;dms:6/10/87
70
71CONST ENDS
72
73DATA SEGMENT PUBLIC WORD
74 extrn ParamCt:WORD
75 extrn current:word,pointer:word,start:word,endtxt:word
76 extrn wrt_handle:word,editbuf:byte,ext_ptr:word,qflg:byte
77 extrn temp_path:byte,line_num:word,line_flag:byte
78 extrn line_num_buf_ptr:byte,arg_buf:byte,arg_buf_ptr:word
79 extrn olddat:byte,oldlen:word,newlen:word,param1:word,param2:word
80 extrn srchflg:byte,srchmod:byte,comline:word,lstfnd:word,numpos:word
81 extrn lstnum:word,last:word,srchcnt:word,amnt_req:word
82
83 extrn lc_adj:byte ;an000;dms:6/10/87
84 extrn continue:byte ;an000;dms:6/10/87
85 extrn pg_count:byte ;an000;dms:6/10/87
86 extrn Disp_Len:byte ;an000;dms;
87 extrn Disp_Width:byte ;an000;dms;
88 extrn lc_flag:byte ;an000;dms:6/10/87
89
90 if kanji
91 extrn lbtbl:dword
92 endif
93
94DATA ENDS
95
96CODE SEGMENT PUBLIC
97
98ASSUME CS:DG,DS:DG,SS:CStack,ES:DG
99
100 public findlin,shownum,loadbuf,crlf,lf,abortcom,unquote
101 public kill_bl,make_caps,display,dispone,make_cntrl
102 public query,quit,scanln,delbak,scaneof,memerr
103 public fndfirst,fndnext,replace
104 if kanji
105 public testkanj
106 endif
107 extrn std_printf:near,command:near,chkrange:near,ComErr:NEAR
108 extrn Xerror:near
109
110
111FINDLIN:
112
113; Inputs
114; BX = Line number to be located in buffer (0 means last line+1)
115; Outputs:
116; DX = Actual line found
117; DI = Pointer to start of line DX
118; Zero set if BX = DX (if specified line found)
119; AL,CX destroyed. No other registers affected.
120
121 MOV DX,[CURRENT]
122 MOV DI,[POINTER]
123 CMP BX,DX ; fast find. Current = requested
124 retz
125 JA FINDIT ; start scanning at current?
126 OR BX,BX ; special case of EOF?
127 JZ FINDIT ; yes
128 MOV DX,1 ; set up for scan at beginning
129 MOV DI,OFFSET DG:START
130 CMP BX,DX ; at beginning?
131 retz
132FINDIT:
133 MOV CX,[ENDTXT] ; count of bytes in buffer
134 SUB CX,DI ; for scan
135SCANLN:
136 MOV AL,10 ; LF is what we look for.
137 OR AL,AL ; Clear zero flag for JCXZ
138FINLIN:
139 JCXZ RET4 ; at end? Yes, no skip.
140 REPNE SCASB ; find EOL
141 INC DX ; increment count
142 CMP BX,DX ; find correct line?
143 JNZ FINLIN ; no, try again.
144RET4: return
145
146; Inputs:
147; BX = Line number to be displayed
148; Function:
149; Displays line number on terminal in 8-character
150; format, suppressing leading zeros.
151; AX, CX, DX destroyed. No other registers affected.
152
153SHOWNUM:
154 mov dx,offset dg:line_num_buf_ptr
155 mov line_num,bx
156 MOV line_flag,"*"
157 CMP BX,[CURRENT]
158 JZ STARLIN
159 MOV line_flag," "
160STARLIN:
161 call std_printf
162ret5: return
163
164
165DISPONE:
166 MOV DI,1
167
168DISPLAY:
169
170; Inputs:
171; BX = Line number
172; SI = Pointer to text buffer
173; DI = No. of lines
174; Function:
175; Ouputs specified no. of line to terminal, each
176; with leading line number.
177; Outputs:
178; BX = Last line output.
179; All registers destroyed.
180
181 MOV CX,[ENDTXT]
182 SUB CX,SI
183 retz ; no lines to display
184;=========================================================================
185; Initialize screen size and line counts for use by display.
186;
187; Date : 6/10/87
188;=========================================================================
189
190 push ax ;an000;save affected regs
191
192 mov al,dg:disp_len ;an000;length of video display
193 mov pg_count,al ;an000;init. screen size ctr.
194
195 pop ax ;an000;restore affected regs
196
197;=========================================================================
198
199 mov dx,di ;number of lines to print
200;
201; CX is the number of bytes in the buffer
202; dx is the number of lines to be output
203;
204DISPLN:
205 SaveReg <CX,DX>
206 CALL SHOWNUM
207 RestoreReg <DX,CX>
208 mov di,offset dg:arg_buf
209;
210; Copy chars until CR/LF or end of line hit
211;
212OUTLN:
213 LODSB
214 CMP DI,254+offset dg:arg_buf ; are we at end of buffer?
215 JAE StoreDone ; Yes, do NOT store
216 CMP AL," "
217 JAE SEND
218 CMP AL,10
219 JZ SEND
220 CMP AL,13
221 JZ SEND
222 CMP AL,9
223 JZ SEND
224 MOV AH,"^"
225 OR AL,40h
226 XCHG AL,AH
227 STOSW
228 JMP StoreDone
229SEND:
230 stosb
231StoreDone:
232 CMP AL,10 ; perform copy until LF is seen
233 LOOPNZ OUTLN
234;
235; Make sure buffer ends with CRLF
236;
237 cmp byte ptr [di-1],10
238 jz Terminate
239;
240; No LF seen. See if CR
241;
242 cmp byte ptr [di-1],CR
243 jz StoreLF
244 mov al,CR
245 stosb
246StoreLF:
247 mov al,10
248 stosb
249Terminate:
250 mov byte ptr [di],0
251
252 call EDLIN_DISP_COUNT ;an000;determine lines printed
253 ; DMS:6/10/87
254 push dx
255 mov dx,offset dg:arg_buf_ptr
256 call std_printf
257 pop dx
258 JCXZ ret7
259 INC BX
260
261 call EDLIN_PG_COUNT ;an000;adjust screen line count
262 ; DMS:6/10/87
263 cmp lc_flag,false ;an000;continue DISPLAY?
264 ; DMS:6/10/87
265 JNZ DISPLN
266 DEC BX
267ret7: return
268
269FNDFIRST:
270 MOV DI,1+OFFSET DG:TXT1
271 mov byte ptr[olddat],1 ;replace with old value if none new
272 CALL GETTEXT
273 OR AL,AL ;Reset zero flag in case CX is zero
274 JCXZ RET7
275 cmp al,1ah ;terminated with a ^Z ?
276 jne sj8
277 mov byte ptr[olddat],0 ;do not replace with old value
278sj8:
279 MOV [OLDLEN],CX
280 XOR CX,CX
281 CMP AL,0DH
282 JZ SETBUF
283 CMP BYTE PTR [SRCHFLG],0
284 JZ NXTBUF
285SETBUF:
286 DEC SI
287NXTBUF:
288 MOV [COMLINE],SI
289 MOV DI,1+OFFSET DG:TXT2
290 CALL GETTEXT
291 CMP BYTE PTR [SRCHFLG],0
292 JNZ NOTREPL
293 CMP AL,0DH
294 JNZ HAVCHR
295 DEC SI
296HAVCHR:
297 MOV [COMLINE],SI
298NOTREPL:
299 MOV [NEWLEN],CX
300 MOV BX,[PARAM1]
301 OR BX,BX
302 JNZ CALLER
303 cmp byte ptr[srchmod],0
304 jne sj9
305 mov bx,1 ;start from line number 1
306 jmp short sj9a
307sj9:
308 MOV BX,[CURRENT]
309 INC BX ;Default search and replace to current+1
310sj9a:
311 CALL CHKRANGE
312CALLER:
313 CALL FINDLIN
314 MOV [LSTFND],DI
315 MOV [NUMPOS],DI
316 MOV [LSTNUM],DX
317 MOV BX,[PARAM2]
318 CMP BX,1
319 SBB BX,-1 ;Decrement everything except zero
320 CALL FINDLIN
321 MOV CX,DI
322 SUB CX,[LSTFND]
323 OR AL,-1
324 JCXZ aret
325 CMP CX,[OLDLEN]
326 jae sj10
327aret: return
328sj10:
329 MOV [SRCHCNT],CX
330
331FNDNEXT:
332
333; Inputs:
334; [TXT1+1] has string to search for
335; [OLDLEN] has length of the string
336; [LSTFND] has starting position of search in text buffer
337; [LSTNUM] has line number which has [LSTFND]
338; [SRCHCNT] has length to be searched
339; [NUMPOS] has beginning of line which has [LSTFND]
340; Outputs:
341; Zero flag set if match found
342; [LSTFND],[LSTNUM],[SRCHCNT] updated for continuing the search
343; [NUMPOS] has beginning of line in which match was made
344
345 MOV AL,[TXT1+1]
346 MOV CX,[SRCHCNT]
347 MOV DI,[LSTFND]
348SCAN:
349 OR DI,DI ;Clear zero flag in case CX=0
350 REPNE SCASB ;look for first byte of string
351
352 retnz ;return if you don't find
353if kanji
354 call kanji_check ;see if the found byte is on a character boundary
355 jnz scan
356endif
357 MOV DX,CX
358 MOV BX,DI ;Save search position
359 MOV CX,[OLDLEN]
360 DEC CX
361 MOV SI,2 + OFFSET DG:TXT1
362 CMP AL,AL ;Set zero flag in case CX=0
363 REPE CMPSB
364 MOV CX,DX
365 MOV DI,BX
366 JNZ SCAN
367 MOV [SRCHCNT],CX
368 MOV CX,DI
369 MOV [LSTFND],DI
370 MOV DI,[NUMPOS]
371 SUB CX,DI
372 MOV AL,10
373 MOV DX,[LSTNUM]
374;Determine line number of match
375GETLIN:
376 INC DX
377 MOV BX,DI
378 REPNE SCASB
379 JZ GETLIN
380 DEC DX
381 MOV [LSTNUM],DX
382 MOV [NUMPOS],BX
383 XOR AL,AL
384 return
385
386if kanji
387
388;Kanji_check idea is to scan backwards to the first
389; character which can't be a kanji or part of one
390; (.lt. 40h) then scan forward to see if the
391; current byte is on character boundary
392;
393;Output ZR <==> we're on a character boundary
394; NZ <==> we're not on character boundary i.e. No Match
395kanji_check:
396 push ax ;save search character
397 push di
398 dec di ;point to the character we found
399 mov si,di ;start searching bakwards from there
400 std
401srch_loop:
402 lodsb
403 cmp al,40H
404 jae srch_loop
405 inc si ;point to first non-kanji
406 cld ;forward search
407kan_loop:
408 cmp si,di ;are we at current byte?
409 jae passed_char ;if we are, or are passed it, exit
410 call next_char ;otherwise advance si to next char
411 jmp short kan_loop ;and loop
412passed_char:
413 pop di
414 pop ax
415 ret
416
417;Next_char si points to a character boundary
418; advance si to point to the beginning of the next char
419;
420;
421next_char:
422 push ax
423 lodsb
424 call testkanj
425 jz not_kanj
426 inc si
427not_kanj:
428 pop ax
429 ret
430
431;--------------------------------------------------------------------;
432; TESTKANJ ~ FIND OUT IS THE BYTE IS A KANJI PREFIX ;
433; ;
434; entry: AL byte to test ;
435; ;
436; exit: NZ if lead byte ortherwise ZR ;
437; ;
438; modifies: AX ;
439; ;
440;--------------------------------------------------------------------;
441
442testkanj:
443 push ax
444 xchg ah,al ;put byte in ah
445 push ds
446 push si
447 lds si,cs:[lbtbl] ;get pointer to lead byte table
448ktlop:
449 lodsb ;direction flag should be OK
450 or al,al ;are we at the end of table?
451 jz notlead ;brif so
452 cmp al,ah ;is START RANGE > CHARACTER?
453 ja notlead ;brif so, not a lead character (carry clear)
454 lodsb ;get second range byte
455 cmp ah,al ;is CHARACTER > END RANGE
456 ja ktlop ;brif so, not a lead character (check next range)
457 or al,al ;make NZ
458notl_exit:
459 pop si
460 pop ds
461 pop ax
462 ret
463notlead:
464 cmp al,al
465 jmp notl_exit
466
467endif
468
469GETTEXT:
470
471; Inputs:
472; SI points into command line buffer
473; DI points to result buffer
474; Function:
475; Moves [SI] to [DI] until ctrl-Z (1AH) or
476; RETURN (0DH) is found. Termination char not moved.
477; Outputs:
478; AL = Termination character
479; CX = No of characters moved.
480; SI points one past termination character
481; DI points to next free location
482
483 XOR CX,CX
484
485GETIT:
486 LODSB
487;-----------------------------------------------------------------------
488 cmp al,quote_char ;a quote character?
489 jne sj101 ;no, skip....
490 lodsb ;yes, get quoted character
491 call make_cntrl
492 jmp short sj102
493;-----------------------------------------------------------------------
494sj101:
495 CMP AL,1AH
496 JZ DEFCHK
497sj102:
498 CMP AL,0DH
499 JZ DEFCHK
500 STOSB
501 INC CX
502 JMP SHORT GETIT
503
504DEFCHK:
505 OR CX,CX
506 JZ OLDTXT
507 PUSH DI
508 SUB DI,CX
509 MOV BYTE PTR [DI-1],cl
510 POP DI
511 return
512
513OLDTXT:
514 cmp byte ptr[olddat],1 ;replace with old text?
515 je sj11 ;yes...
516 mov byte ptr[di-1],cl ;zero text buffer char count
517 return
518
519sj11:
520 MOV CL,BYTE PTR [DI-1]
521 ADD DI,CX
522 return
523
524REPLACE:
525
526; Inputs:
527; CX = Length of new text
528; DX = Length of original text
529; SI = Pointer to new text
530; DI = Pointer to old text in buffer
531; Function:
532; New text replaces old text in buffer and buffer
533; size is adjusted. CX or DX may be zero.
534; CX, SI, DI all destroyed. No other registers affected.
535
536 CMP CX,DX
537 JZ COPYIN
538 PUSH SI
539 PUSH DI
540 PUSH CX
541 MOV SI,DI
542 ADD SI,DX
543 ADD DI,CX
544 MOV AX,[ENDTXT]
545 SUB AX,DX
546 ADD AX,CX
547 CMP AX,[LAST]
548 JAE MEMERR
549 XCHG AX,[ENDTXT]
550 MOV CX,AX
551 SUB CX,SI
552 CMP SI,DI
553 JA DOMOV
554 ADD SI,CX
555 ADD DI,CX
556 STD
557DOMOV:
558 INC CX
559
560 REP MOVSB
561 CLD
562 POP CX
563 POP DI
564 POP SI
565COPYIN:
566 REP MOVSB
567 return
568
569MEMERR:
570 MOV DX,OFFSET DG:MEMFUL_ptr
571 call std_printf
572 JMP COMMAND
573
574
575LOADBUF:
576 MOV DI,2 + OFFSET DG:EDITBUF
577 MOV CX,255
578 MOV DX,-1
579LOADLP:
580 LODSB
581 STOSB
582 INC DX
583 CMP AL,13
584 LOOPNZ LOADLP
585 MOV [EDITBUF+1],DL
586 retz
587TRUNCLP:
588 LODSB
589 INC DX
590 CMP AL,13
591 JNZ TRUNCLP
592 DEC DI
593 STOSB
594 return
595
596SCANEOF:
597 cmp [loadmod],0
598 je sj52
599
600;----- Load till physical end of file
601
602 cmp cx,word ptr[amnt_req]
603 jb sj51
604 xor al,al
605 inc al ;reset zero flag
606 return
607sj51:
608 jcxz sj51b
609 push di ;get rid of any ^Z at the end of the file
610 add di,cx
611 dec di ;points to last char
612 cmp byte ptr [di],1ah
613 pop di
614 jne sj51b
615 dec cx
616sj51b:
617 xor al,al ;set zero flag
618 call check_end ;check that we have a CRLF pair at the end
619 return
620
621;----- Load till first ^Z is found
622
623sj52:
624 PUSH DI
625 PUSH CX
626 MOV AL,1AH
627 or cx,cx
628 jz not_found ;skip with zero flag set
629 REPNE SCASB ;Scan for end of file mark
630 jnz not_found
631 LAHF ;Save flags momentarily
632 inc cx ;include the ^Z
633 SAHF ;Restore flags
634not_found:
635 mov di,cx ;not found at the end
636 POP CX
637 LAHF ;Save flags momentarily
638 SUB CX,DI ;Reduce byte count if EOF found
639 SAHF ;Restore flags
640 POP DI
641 call check_end ;check that we have a CRLF pair at the end
642
643 return
644
645
646;-----------------------------------------------------------------------
647; If the end of file was found, then check that the last character
648; in the file is a LF. If not put a CRLF pair in.
649
650check_end:
651 jnz not_end ;end was not reached
652 pushf ;save return flag
653 push di ;save pointer to buffer
654 add di,cx ;points to one past end on text
655 dec di ;points to last character
656 cmp di,offset dg:start
657 je check_no
658 cmp byte ptr[di],0ah ;is a LF the last character?
659 je check_done ;yes, exit
660check_no:
661 mov byte ptr[di+1],0dh ;no, put a CR
662 inc cx ;one more char in text
663 mov byte ptr[di+2],0ah ;put a LF
664 inc cx ;another character at the end
665check_done:
666 pop di
667 popf
668not_end:
669 return
670
671CRLF:
672 push dx
673 mov dx,offset dg:crlf_ptr
674 call std_printf
675 pop dx
676 return
677LF:
678 MOV dx,offset dg:lf_ptr
679 call std_printf
680 return
681
682ABORTCOM:
683 MOV AX,CS
684 MOV DS,AX
685 MOV ES,AX
686 MOV AX,cstack
687 MOV SS,AX
688 MOV SP,STACK
689 STI
690 CALL CRLF
691 JMP COMMAND
692
693DELBAK:
694 ;Delete old backup file (.BAK)
695
696 MOV BYTE PTR [DELFLG],1
697 MOV DI,[EXT_PTR]
698 MOV SI,OFFSET DG:BAK
699 MOVSW
700 MOVSW
701 MOVSB
702 MOV AH,UNLINK
703 MOV DX,OFFSET DG:TEMP_PATH
704 INT 21H
705; $if c ;error ? ;an000; dms;
706 JNC $$IF1
707 cmp ax,Access_Denied ;file read only? ;an000; dms;
708; $if e ;yes ;an000; dms;
709 JNE $$IF2
710 mov bx,[Wrt_Handle] ;close .$$$ file ;an000; dms;
711 mov ah,Close ;close function ;an000; dms;
712 int 21h ;close it ;an000; dms;
713
714 mov di,[Ext_Ptr] ;point to extension ;an000; dms;
715 mov si,offset dg:$$$File ;point to .$$$ extension;an000; dms;
716 movsw ;get .$$$ extension ;an000; dms;
717 movsw ; ;an000; dms;
718 movsb ; ;an000; dms;
719 mov dx,offset dg:Temp_Path ;point to .$$$ file ;an000; dms;
720 mov ah,Unlink ;delete it ;an000; dms;
721 int 21h ; ;an000; dms;
722
723 mov di,[Ext_Ptr] ;point to extension ;an000; dms;
724 mov si,offset dg:BAK ;point to .BAK extension;an000; dms;
725 movsw ;get .BAK extension ;an000; dms;
726 movsw ; ;an000; dms;
727 movsb ; ;an000; dms;
728 mov dx,offset dg:Del_Bak_Ptr;point to error message ;an000; dms;
729 jmp Xerror ;display message & exit ;an000; dms;
730; $endif
731$$IF2:
732; $endif
733$$IF1:
734
735 MOV DI,[EXT_PTR]
736 MOV SI,OFFSET DG:$$$FILE
737 MOVSW
738 MOVSW
739 MOVSB
740 return
741
742
743;-----------------------------------------------------------------------;
744; Will scan buffer given pointed to by SI and get rid of quote
745;characters, compressing the line and adjusting the length at the
746;begining of the line.
747; Preserves al registers except flags and AX .
748
749unquote:
750 push cx
751 push di
752 push si
753 mov di,si
754 mov cl,[si-1] ;length of buffer
755 xor ch,ch
756 mov al,quote_char
757 cld
758unq_loop:
759 jcxz unq_done ;no more chars in the buffer, exit
760 repnz scasb ;search for quote character
761 jnz unq_done ;none found, exit
762 push cx ;save chars left in buffer
763 push di ;save pointer to quoted character
764 push ax ;save quote character
765 mov al,byte ptr[di] ;get quoted character
766 call make_cntrl
767 mov byte ptr[di],al
768 pop ax ;restore quote character
769 mov si,di
770 dec di ;points to the quote character
771 inc cx ;include the carriage return also
772 rep movsb ;compact line
773 pop di ;now points to after quoted character
774 pop cx
775 jcxz sj13 ;if quote char was last of line do not adjust
776 dec cx ;one less char left in the buffer
777sj13: pop si
778 dec byte ptr[si-1] ;one less character in total buffer count also
779 push si
780 jmp short unq_loop
781
782unq_done:
783 pop si
784 pop di
785 pop cx
786 return
787
788
789;-----------------------------------------------------------------------;
790; Convert the character in AL to the corresponding control
791; character. AL has to be between @ and _ to be converted. That is,
792; it has to be a capital letter. All other letters are left unchanged.
793
794make_cntrl:
795 push ax
796 and ax,11100000b
797 cmp ax,01000000b
798 pop ax
799 jne sj14
800 and ax,00011111b
801sj14:
802 return
803
804
805;---- Kill spaces in buffer --------------------------------------------;
806;=========================================================================
807; kill_bl : Parses over spaces in a buffer.
808;
809; Date : 6/10/86
810;=========================================================================
811kill_bl:
812
813 push bx ;an000;save affected reg.
814kill_bl_cont:
815
816 lodsb ;get rid of blanks
817 cmp al,9
818 je kill_bl_cont ;an000;it is a tab
819
820 cmp al,10
821 je kill_bl_cont ;an000;if LF
822
823 cmp al,' '
824 je kill_bl_cont ;an000;we have a space
825
826 if kanji ;an000;is this a kanji assembly
827 call testkanj ;an000;do we have a dbcs lead byte
828; $if nz ;an000;yes, we have a lead byte
829 JZ $$IF5
830 cmp al,dbcs_lead_byte;an000;is it 81h
831; $if z ;an000;it is 81h
832 JNZ $$IF6
833 mov bl,ds:[si] ;an000;set up for compare
834 cmp bl,asian_blk;an000;is it 40h
835; $if z ;an000;we have an asian blank
836 JNZ $$IF7
837 lodsb ;an000;skip byte containing 81h
838 jmp kill_bl_cont
839; $endif ;an000;
840$$IF7:
841; $endif ;an000;fall through no delim
842$$IF6:
843 ; found
844; $endif ;an000;end test for dbcs lead byte
845$$IF5:
846 endif ;an000;end conditional assembly
847
848 pop bx ;an000;restore affected reg.
849 return
850
851;----- Capitalize the character in AL ----------------------------------;
852; ;
853; Input: ;
854; ;
855; AL contains a character to capitalize ;
856; ;
857; Output: ;
858; ;
859; AL contains a capitalized character ;
860; ;
861;-----------------------------------------------------------------------;
862
863MAKE_CAPS:
864 CMP AL,"a"
865 JB CAPS1
866 CMP AL,"z"
867if KANJI
868 JA CAPS1 ; M003 MSKK TAR 476, kana chars
869else
870 JG CAPS1
871endif
872 AND AL,0DFH
873CAPS1:
874 return
875
876QUIT:
877 CMP ParamCt,1
878 JZ Quit1
879CERR: JMP ComErr
880Quit1: CMP Param1,0
881 JNZ CERR
882 MOV DX,OFFSET DG:QMES_ptr
883 call std_printf
884
885IF KANJI
886 CALL TESTKANJ
887 JZ ASCII
888 MOV AX, (STD_CON_INPUT_FLUSH SHL 8) + 0
889 INT 21H ; Eat the trailing byte.
890 JMP CRLF
891ASCII:
892ENDIF
893;=========================================================================
894; We are invoking the VAL_YN proc here. This will replace the
895; method of Y/N validation used prior to DOS 4.00.
896;
897; Date : 6/10/87
898;=========================================================================
899
900 call val_yn ;an000;pass Y/N byte in AL to macro
901 cmp ax,yes ;an000;did we return a Y
902 jz NoCRLF ;an000; dms; close the file
903 cmp ax,no ;an000; dms; return N?
904; $if ne ;an000; dms; neither N or Y - reprompt
905 JE $$IF11
906 push dx ;an000; dms; must be N
907 mov dx,offset dg:crlf_ptr ;an000; dms; spit out CRLF
908 call std_printf ;an000; dms; and return
909 pop dx ;an000; dms; to caller
910 jmp Quit1 ;an000; dms; reprompt
911; $endif ;an000; dms;
912$$IF11:
913 push dx ;an000; dms; must be N
914 mov dx,offset dg:crlf_ptr ;an000; dms; spit out CRLF
915 call std_printf ;an000; dms; and return
916 pop dx ;an000; dms; to caller
917 return ;an000; dms;
918
919;=========================================================================
920; End of Y/N validation check for qmes_ptr
921;=========================================================================
922
923NOCRLF:
924 MOV BX,[WRT_HANDLE]
925 MOV AH,CLOSE
926 INT 21H
927 MOV DX,OFFSET DG:TEMP_PATH
928 MOV AH,UNLINK
929 INT 21H
930 mov ah,exit
931 xor al,al
932 INT 21H
933
934QUERY:
935 TEST BYTE PTR [QFLG],-1
936 retz
937 MOV DX,OFFSET DG:ASK_ptr
938 call std_printf
939 PUSH AX
940 CALL CRLF
941 POP AX
942IF KANJI
943 CALL TESTKANJ
944 JZ ASCII1
945 PUSH AX
946 MOV AX,(STD_CON_INPUT_FLUSH SHL 8) + 0
947 INT 21H ;Eat the trailing byte
948 XOR AX,AX
949 INC AX ; non zero flag
950 POP AX
951 return
952ASCII1:
953ENDIF
954 CMP AL,13 ;Carriage return means yes
955 retz
956;=========================================================================
957; We are invoking the VAL_YN proc here. This will replace the
958; method of Y/N validation used prior to DOS 4.00.
959; This invocation of val_yn will return ZR if Y is found, otherwise
960; it will return NZ.
961;
962; Date : 6/10/87
963;=========================================================================
964
965 call val_yn ;an000;pass Y/N byte in AL to macro
966 cmp ax,yes ;an000;did we return a Y
967 je Query_Exit ;an000; dms; exit Y/N validation
968 cmp ax,no ;an000; dms; N response?
969 jne Query ;an000; dms; no - reprompt user
970 cmp ax,yes ;an000; dms; must have N response - force
971 ; NZ flag
972Query_Exit:
973
974
975;=========================================================================
976; End of Y/N validation check for ask_ptr
977;=========================================================================
978
979 return
980
981;=========================================================================
982; EDLIN_DISP_COUNT: This routine will determine the number of lines
983; actually displayed to the screen. Lines displayed to
984; the screen for one EDLIN line printed will be calculated
985; by the following formula:
986;
987; LINES_PRINTED = (LINE_LEN + 10) / SCREEN_WIDTH
988;
989; LINES_PRINTED - Actual number of lines printed on screen
990; for one EDLIN line. If LINES_PRINTED has
991; a remainder, it will be rounded up.
992;
993; LINE_LEN - The length, in bytes, of the EDLIN line
994; printed.
995;
996; SCREEN_WIDTH - The width in bytes of the current display.
997;
998; Inputs : DI - offset into buffer containing line printed
999; DISP_WIDTH - width of current video output
1000;
1001; Outputs: LC_ADJ - factor to adjust line counter by
1002;
1003; Date : 6/10/87
1004;=========================================================================
1005
1006EDLIN_DISP_COUNT proc near ;an000;lines printed
1007
1008 push dx ;an000;save affected regs
1009 push di ;an000;
1010 push ax ;an000;
1011 push bx ;an000;
1012 push cx ;an000;
1013
1014 mov bx,offset dg:arg_buf ;an000;arg_buf holds line
1015 ; printed
1016 mov ax,di ;an000;where print line ends
1017 sub ax,bx ;an000;diff = line's length
1018 add ax,10 ;an000;adjust for leading blks
1019 mov cl,dg:disp_width ;an000;set up for division
1020 div cl ;an000;divide AX by the
1021 ; width of the console
1022 cmp ah,0 ;an000;see if a remainder
1023; $if nz ;an000;if a remainder
1024 JZ $$IF13
1025 add al,1 ;an000;increment AL 1
1026 ; to round upward
1027; $endif ;an000;
1028$$IF13:
1029
1030 mov lc_adj,al ;an000;number of lines printed
1031 ; on console
1032 pop cx ;an000;restore affected regs
1033 pop bx ;an000;
1034 pop ax ;an000;
1035 pop di ;an000;
1036 pop dx ;an000;
1037
1038 ret ;an000;return to caller
1039
1040EDLIN_DISP_COUNT endp ;an000;end proc
1041
1042;=========================================================================
1043; EDLIN_PG_COUNT : This routine determines whether or not we will continue
1044; displaying text lines based on the count of lines that
1045; can be output to the current video screen.
1046;
1047; Inputs : LC_ADJ - adjustment factor for number of lines printed
1048; PG_COUNT - number of lines remaining on current video
1049; display
1050; DX - holds the total number of lines to print
1051; CONTINUE - signals if the user wants to continue
1052; printing lines.
1053;
1054; Outputs: LC_FLAG - used to signal completion of print
1055;
1056; Date : 6/10/87
1057;=========================================================================
1058
1059EDLIN_PG_COUNT proc near ;an000;track remaining lines
1060
1061 push ax ;an000;save affected regs
1062
1063 mov lc_flag,true ;an000;init. flag to signal
1064 ; continue printing
1065
1066 mov al,pg_count ;an000;set up for page adj.
1067 cmp al,lc_adj ;an000;see if we are at end
1068; $if be ;an000
1069 JNBE $$IF15
1070 mov pg_count,0 ;an000;set pg_count to 0
1071; $else
1072 JMP SHORT $$EN15
1073$$IF15:
1074 sub al,lc_adj ;an000;adjust number of lines
1075 mov pg_count,al ;an000;save remaining line ct.
1076; $endif ;an000;
1077$$EN15:
1078
1079 dec dx ;an000;decrease total number
1080 ; of lines to print by 1
1081; $if nz ;an000;more lines to print
1082 JZ $$IF18
1083 cmp pg_count,0 ;an000;have we printed screen
1084; $if be ;an000;we have printed screen
1085 JNBE $$IF19
1086 call EDLIN_PG_PROMPT ;an000;prompt the user to
1087 ; "Continue(Y/N)?"
1088 cmp continue,true ;an000;did user say continue
1089; $if z ;an000;continue
1090 JNZ $$IF20
1091 mov al,dg:disp_len ;an000;begin init of screen
1092; dec al ;an000; length
1093 mov pg_count,al ;an000;
1094; $else ;an000;do not continue
1095 JMP SHORT $$EN20
1096$$IF20:
1097 mov lc_flag,false ;an000;signal no more to print
1098; $endif ;an000;
1099$$EN20:
1100; $endif ;an000;
1101$$IF19:
1102; $else ;an000;total lines printed
1103 JMP SHORT $$EN18
1104$$IF18:
1105 mov lc_flag,false ;an000;signal no more to print
1106; $endif ;an000;
1107$$EN18:
1108
1109 pop ax ;an000;restore affected regs
1110
1111 ret ;an000;return to caller
1112
1113EDLIN_PG_COUNT endp ;an000;end procedure
1114
1115;=========================================================================
1116; EDLIN_PG_PROMPT : This routine prompts the user as to whether or not to
1117; continue printing lines to the video display, if lines
1118; are still present for printing.
1119;
1120; Inputs : none
1121;
1122; Outputs: CONTINUE - flag that signals other routines whether or
1123; not to continue printing.
1124;
1125; Date : 6/10/87
1126;=========================================================================
1127
1128EDLIN_PG_PROMPT proc near ;an000;ask user to continue?
1129
1130 push dx ;an000;save affected regs.
1131 push ax ;an000;
1132
1133EPP_Reprompt:
1134
1135 mov dx,offset dg:cont_ptr ;an000;point to Continue msg.
1136 call std_printf ;an000;invoke message ret.
1137
1138 push ax ;an000;save affected regs.
1139 call crlf ;an000;send crlf
1140 pop ax ;an000;restore affected regs.
1141
1142 call val_yn ;an000;Y/N validation
1143
1144 cmp ax,yes ;an000;did we have a Y
1145 jz EPP_True_Exit ;an000;we had a Y
1146 cmp ax,no ;an000;did we have a N
1147 jz EPP_False_Exit ;an000;yes
1148 jmp EPP_Reprompt ;an000;neither Y or N - reprompt
1149
1150EPP_True_Exit:
1151
1152 mov Continue,True ;an000;flag Y found
1153 jmp EPP_Exit ;an000;exit routine
1154
1155EPP_False_Exit:
1156
1157 mov Continue,False ;an000;flag N found
1158
1159EPP_Exit:
1160
1161 pop ax ;an000;restore affected regs.
1162 pop dx ;an000;
1163
1164 ret ;an000;return to caller
1165
1166EDLIN_PG_PROMPT endp ;an000;end procedure
1167
1168;=========================================================================
1169; val_yn: This proc validates a Y/N response entered by the user. The
1170; routine uses the new functionality of "GET EXTENDED COUNTRY
1171; INFORMATION" being implemented in DOS 4.00.
1172;
1173; Inputs : AL - character to be validated for Y/N response
1174;
1175; Outputs: AX - 00h = "N"o
1176; - 01h = "Y"es
1177;=========================================================================
1178
1179val_yn proc near ;an000;validate Y/N response
1180
1181 push dx ;an000;save affected registers
1182 push cx ;an000;
1183 push bx ;an000;
1184
1185 mov dl,al ;an000;character to be checked for Y/N
1186 mov ah,GetExtCntry ;an000;get extended country information
1187 mov al,yn_chk ;an000;perform Y/N checking
1188 mov cx,max_len ;an000;max. len. of Y/N char.
1189 int 21h ;an000;invoke function
1190
1191 pop bx ;an000;restore affected registers
1192 pop cx ;an000;
1193 pop dx ;an000;
1194
1195 ret ;an000;return to caller
1196
1197val_yn endp ;an000;end proc
1198
1199
1200
1201code ends
1202 end
1203 \ No newline at end of file