]>
wirehaze git hosting - MS-DOS.git/blob - v2.0/source/EDLIN.ASM
1 title EDLIN for MSDOS
2.0
3 ;-----------------------------------------------------------------------;
8 ; V2.00 9/13/82 M.A. Ulloa ;
9 ; Modified to use Pathnames in command line file ;
10 ; specification, modified REPLACE to use an empty ;
11 ; string intead of the old replace string when this ;
12 ; is missing, and search and replace now start from ;
13 ; first line of buffer (like old version of EDLIN) ;
14 ; instead than current+1 line. Also added the U and ;
15 ; V commands that search (replace) starting from the ;
18 ; 9/15/82 M.A. Ulloa ;
19 ; Added the quote character (^V). ;
21 ; 9/16/82 M.A. Ulloa ;
22 ; Corrected bug about use of quote char when going ;
23 ; into default insert mode. Also corrected the problem ;
24 ; with ^Z being the end of file marker. End of file is ;
25 ; reached when an attempt to read returns less chars ;
28 ; 9/17/82 M.A. Ulloa ;
29 ; Corrected bug about boundaries for Copy ;
31 ; 10/4/82 Rev. 1 M.A. Ulloa ;
32 ; The IBM version now does NOT have the U and V ;
33 ; commands. The MSDOS version HAS the U and V commands. ;
34 ; Added the B switch, and modified the effect of ;
37 ; 10/7/82 Rev. 2 M.A. Ulloa ;
38 ; Changed the S and R commands to start from the ;
39 ; current line+1 (as U and V did). Took away U and V in ;
42 ; 10/13/82 Rev. 3 M.A. Ulloa ;
43 ; Now if parameter1 < 1 then parameter1 = 1 ;
45 ; 10/15/82 Rev. 4 M.A. Ulloa ;
46 ; Param4 if specified must be an absolute number that ;
47 ; reprecents the count. ;
49 ; 10/18/82 Rev. 5 M.A. Ulloa ;
50 ; Fixed problem with trying to edit files with the ;
51 ; same name as directories. Also, if the end of file is ;
52 ; reached it checks that a LF is the last character, ;
53 ; otherwise it inserts a CRLF pair at the end. ;
55 ; 10/20/82 Rev. 6 M.A.Ulloa ;
56 ; Changed the text of some error messages for IBM and ;
59 ; 10/25/82 Rev. 7 M.A.Ulloa ;
60 ; Made all messages as in the IBM vers. ;
62 ; 10/28/82 Rev. 8 M.A.Ulloa ;
63 ; Corrected problem with parsing for options. ;
65 ; Rev. 9 Aaron Reynolds ;
66 ; Made error messages external. ;
68 ; 12/08/82 Rev. 10 M.A. Ulloa ;
69 ; Corrected problem arising with having to restore ;
70 ; the old directory in case of a file name error. ;
72 ; 12/17/82 Rev. 11 M.A. Ulloa ;
73 ; Added the ROPROT equate for R/O file protection. ;
74 ; It causes only certain operations (L,P,S,W,A, and Q) ;
75 ; to be allowed on read only files. ;
77 ; 12/29/82 Rev. 12 M.A. Ulloa :
78 ; Added the creation error message. ;
80 ; 4/14/83 Rev. 13 N.Panners ;
81 ; Fixed bug in Merge which lost char if not ^Z. ;
82 ; Fixed bug in Copy to correctly check ;
86 ; 7/23/83 Rev. 14 N.Panners ;
87 ; Split EDLIN into two seperate modules to ;
88 ; allow assembly of sources on an IBM PC ;
91 ;-----------------------------------------------------------------------;
99 roprot equ true
;set to TRUE if protection to r/o files
103 Comand_Line_Length equ
128
104 quote_char equ 16h
;quote character = ^V
114 SUBTTL Contants
and Data areas
123 CONST
SEGMENT PUBLIC WORD
126 DATA SEGMENT PUBLIC WORD
129 DG GROUP
CODE,CONST
,DATA
131 CONST
SEGMENT PUBLIC WORD
133 EXTRN BADDRV
:BYTE,NDNAME
:BYTE,bad_vers_err
:BYTE,opt_err
:BYTE
134 EXTRN NOBAK
:BYTE,BADCOM
:BYTE,NEWFIL
:BYTE,DEST
:BYTE,MRGERR
:BYTE
135 EXTRN NODIR
:BYTE,DSKFUL
:BYTE,MEMFUL
:BYTE,FILENM
:BYTE
136 EXTRN NOSUCH
:BYTE,TOOLNG
:BYTE,EOF
:BYTE,ro_err
:byte,bcreat
:byte
138 PUBLIC TXT1
,TXT2
,FUDGE
,USERDIR
,HARDCH
142 make db "***MAUlloa/Microsoft/V20***"
145 if roprot
;***** R/O *****
146 roflag db 0 ; =1 if file is r/o
149 fourth db 0 ;fourth parameter flag
151 loadmod db 0 ;Load mode flag, 0 = ^Z marks the
152 ; end of a file, 1 = viceversa.
155 the_root db 0 ;root directory flag
157 fudge db 0 ;directory changed flag
166 db (dirstrlen
) dup(0)
168 fname_buffer db Comand_Line_Length
dup(0)
169 ;-----------------------------------------------------------------------;
171 TXT1
DB 0,80H
DUP (?
)
172 TXT2
DB 0,80H
DUP (?
)
177 DATA SEGMENT PUBLIC WORD
179 PUBLIC QFLG
,FCB2
,OLDLEN
,PARAM1
,PARAM2
,OLDDAT
,SRCHFLG
180 PUBLIC COMLINE
,NEWLEN
,SRCHMOD
,CURRENT
,LSTFND
,NUMPOS
181 PUBLIC LSTNUM
,SRCHCNT
,POINTER
,START
,ENDTXT
,USER_DRIVE
183 ;-----------------------------------------------------------------------;
184 ; Be carefull when adding parameters, they have to follow the
185 ; order in which they apperar here. (this is a table, ergo it
186 ; is indexed thru a pointer, and random additions will cause the
187 ; wrong item to be accessed). Also param4 is known to be the
188 ; count parameter, and known to be the fourth entry in the table
189 ; so it receives special treatment. (See GETNUM)
196 ;-----------------------------------------------------------------------;
211 THREE4TH
DW 1 DUP (?
)
216 COMBUF
DB 82H
DUP (?
)
217 EDITBUF
DB 258 DUP (?
)
221 fake_fcb db 37 dup (?
) ;fake for size figuring
226 amnt_req dw 1 dup (?
) ;ammount of bytes requested to read
227 olddat db 1 dup (?
) ;Used in replace and search,
228 ; replace by old data flag (1=yes)
229 srchmod db 1 dup (?
) ;Search mode: 1=from current+1 to
230 ; end of buffer, 0=from beg. of
231 ; buffer to the end (old way).
245 ASSUME
CS:DG
,DS:DG
,SS:DG
,ES:DG
247 EXTRN QUIT
:NEAR,QUERY
:NEAR,FNDFIRST
:NEAR,FNDNEXT
:NEAR
248 EXTRN UNQUOTE
:NEAR,LF
:NEAR,CRLF
:NEAR,OUT:NEAR
249 EXTRN REST_DIR
:NEAR,KILL_BL
:NEAR,INT_24
:NEAR
250 EXTRN FINDLIN
:NEAR,SHOWNUM
:NEAR,SCANLN
:NEAR
263 edl_pad db 0e00h dup (?
)
265 HEADER
DB "Vers 2.14"
268 MOV DX,OFFSET DG
:NDNAME
272 MOV BYTE PTR [ENDING
],0
273 MOV SP,OFFSET DG
:STACK
275 ;Code to print header
277 ; MOV DX,OFFSET DG:HEADER
278 ; MOV AH,STD_CON_STRING_OUTPUT
282 ;----- Check Version Number --------------------------------------------;
287 jae vers_ok
; version >= 2, enter editor
288 mov dx,offset dg
:bad_vers_err
290 ;-----------------------------------------------------------------------;
294 ;----- Process Pathnames -----------------------------------------------;
296 mov ax,(char_oper
shl 8) ;get switch character
299 jnz slashok
;if not / , then not PC
300 mov [dirchar
],"\" ;in PC, dir separator = \
302 mov [optchar
],"/" ;in PC, option char = /
305 mov si,81h
;point to cammand line
308 cmp al,13 ;A carriage return?
309 je noname
;yes, file name missing
311 mov di,offset dg
:fname_buffer
312 xor cx,cx ;zero pathname length
315 stosb ;put patname in buffer
322 cmp al,[optchar
] ; an option character?
333 lodsb ;get the option
338 mov dx,offset dg
:opt_err
;bad option specified
345 mov byte ptr dg
:[di],0 ;nul terminate the pathname
347 if roprot
;***** R/O *****
348 ;----- Check that file is not R/O --------------------------------------;
349 push cx ;save character count
350 mov dx,offset dg
:fname_buffer
351 mov al,0 ;get attributes
355 and cl,00000001b ;mask all but: r/o
356 jz attr_are_ok
;if all = 0 then file ok to edit,
357 mov dg
:[roflag
],01h ;otherwise: Error (GONG!!!)
359 pop cx ;restore character count
362 ;----- Scan for directory ----------------------------------------------;
363 dec di ;adjust to the end of the pathname
366 mov dx,offset dg
: fname_buffer
384 MOV DX,DI ;Point to char after '/'
386 DEC DX ;Point to char before '/'
393 SUB AX,DI ;Distance moved
394 SUB CX,AX ;Set correct CX
396 JB sj1
;Found a pathsep
397 JA sj2
;Started with a pathsep, root
403 jz sj1
;One character directory
406 mov al,dg
:[dirchar
] ;get directory separator character
408 repnz scasb ;(cx has the pathname length)
409 cld ;reset direction, just in case
413 jmp same_dir
;no dir separator char. found, the
414 ; file is in the current directory
415 ; of the corresponding drive. Ergo,
416 ; the FCB contains the data already.
419 jcxz sj2
;no more chars left, it refers to root
420 cmp byte ptr [di],':' ;is the prvious character a disk def?
423 mov dg
:[the_root
],01h ;file is in the root
425 inc di ;point to dir separator char.
427 stosb ;nul terminate directory name
429 push di ;save pointer to file name
430 mov dg
:[fudge
],01h ;remember that the current directory
433 ;----- Save current directory for exit ---------------------------------;
434 mov ah,get_default_drive
;save current drive
436 mov dg
:[user_drive
],al
438 mov dl,byte ptr ds:[fcb
] ;get specified drive if any
439 or dl,dl ;default disk?
441 dec dl ;adjust to real drive (a=0,b=1,...)
442 mov ah,set_default_drive
;change disks
446 mov dx,offset dg
:baddrv
450 mov ah,get_default_dpb
455 cmp al,-1 ;bad drive? (should always be ok)
457 mov dx,offset dg
:baddrv
461 cmp [bx.dpb_current_dir
],0
465 mov di,offset dg
:userdir
+ 1
480 ;----- Change directories ----------------------------------------------;
482 mov dx,offset dg
:[dirchar
] ;assume the root
484 mov dx,offset dg
:[fname_buffer
]
486 mov ah,chdir
;change directory
488 mov dx,offset dg
:baddrv
493 ;----- Set Up int 24 intercept -----------------------------------------;
495 mov ax,(get_interrupt_vector
shl 8) or 24h
497 mov word ptr [hardch
],bx
498 mov word ptr [hardch
+2],es
499 mov ax,(set_interrupt_vector
shl 8) or 24h
500 mov dx,offset dg
:int_24
505 ;----- Parse filename to FCB -------------------------------------------;
508 mov ax,(parse_file_descriptor
shl 8) or 1
512 ;-----------------------------------------------------------------------;
517 MOV DX,OFFSET DG
:BADDRV
521 CMP BYTE PTR DS:[FCB
+1]," "
528 ;File must not have .BAK extension
539 ;----- Check that file is not a directory ------------
544 jz sj50
;no error found
545 mov dx,offset dg
:bcreat
;creation error
548 mov ah,fcb_close
;no error, close the file
551 mov ah,fcb_delete
;delete the file
555 ;-----------------------------------------------------
557 MOV DX,OFFSET DG
:NEWFIL
558 MOV AH,STD_CON_STRING_OUTPUT
562 MOV DI,OFFSET DG
:FCB2
570 ;Create .$$$ file to make sure directory has room
571 MOV DX,OFFSET DG
:FCB2
576 CMP BYTE PTR [DELFLG
],0
581 MOV DX,OFFSET DG
:NODIR
584 MOV DX,OFFSET DG
:NOBAK
588 MOV WORD PTR DS:[FCB
+fcb_RR
],AX ;Set RR field to zero
589 MOV WORD PTR DS:[FCB
+fcb_RR
+2],AX
590 MOV WORD PTR [FCB2
+fcb_RR
],AX
591 MOV WORD PTR [FCB2
+fcb_RR
+2],AX
593 MOV WORD PTR DS:[FCB
+fcb_RECSIZ
],AX ;Set record length to 1
594 MOV WORD PTR [FCB2
+fcb_RECSIZ
],AX
595 MOV DX,OFFSET DG
:START
602 TEST BYTE PTR [HAVEOF
],-1
604 SUB CX,OFFSET DG
:START
;Available memory
605 SHR CX,1 ;1/2 of available memory
607 SHR CX,1 ;1/4 of available memory
608 MOV [ONE4TH
],CX ;Save amount of 1/4 full
609 ADD CX,AX ;3/4 of available memory
611 ADD DX,OFFSET DG
:START
612 MOV [THREE4TH
],DX ;Save pointer to 3/4 full
615 MOV AH,FCB_RANDOM_READ_BLOCK
616 mov [amnt_req
],cx ;save ammount of chars requested
619 ADD DI,CX ;Point to last byte
622 MOV BYTE PTR [DI],1
AH
624 MOV BYTE PTR [COMBUF
],128
625 MOV BYTE PTR [EDITBUF
],255
626 MOV BYTE PTR [EOL
],10
627 MOV [POINTER
],OFFSET DG
:START
630 TEST BYTE PTR [HAVEOF
],-1
635 MOV SP, OFFSET DG
:STACK
636 MOV AX,(SET_INTERRUPT_VECTOR
SHL 8) OR 23H
637 MOV DX,OFFSET DG
:ABORTCOM
641 MOV DX,OFFSET DG
:COMBUF
642 MOV AH,STD_CON_STRING_INPUT
644 MOV [COMLINE
],OFFSET DG
:COMBUF
+ 2
651 mov [fourth
],0 ;reset the fourth parameter flag
652 MOV BYTE PTR [QFLG
],0
654 MOV BP,OFFSET DG
:PARAM1
679 MOV DI,OFFSET DG
:COMTAB
688 JB COMERR
;Param. 2 must be >= param 1
692 if roprot
;***** R/O *****
693 cmp [roflag
],01 ;file r/o?
695 cmp byte ptr [bx+rotable
],01 ;operation allowed?
697 mov dx,offset dg
:ro_err
;error
736 MOV DX,OFFSET DG
:BADCOM
738 MOV AH,STD_CON_STRING_OUTPUT
745 cmp di,6 ;Is this the fourth parameter?
747 mov [fourth
],1 ;yes, set the flag
758 MOV CL,0 ;Flag no parameter seen yet
764 CMP DX,6553 ;Max line/10
765 JAE COMERR
;Ten times this is too big
766 MOV CL,1 ;Parameter digit has been found
781 JZ COMERR
;Don't allow zero as a parameter
785 cmp [fourth
],1 ;the fourth parameter?
786 je comerra
;yes, an error
791 cmp [fourth
],1 ;the fourth parameter?
792 je comerra
;yes, an error
797 cmp [fourth
],1 ;the fourth parameter?
798 je comerra
;yes, an error
803 cmp [fourth
],1 ;the fourth parameter?
804 je comerra
;yes, an error
808 jns sk2
;if below beg of buffer then default to the
809 mov bx,1 ; beg of buffer (line1)
818 COMTAB
DB "QTCMWASRDLPIE;",13
822 ;-----------------------------------------------------------------------;
823 ; Carefull changing the order of the next two tables. They are
824 ; linked and chnges should be be to both.
826 TABLE
DW NOCOM
;No command--edit line
833 dw replac_from_curr
;replace from current+1 line
834 dw search_from_curr
;search from current+1 line
841 if roprot
;***** R/O *****
847 if roprot
;***** R/O *****
848 ;-----------------------------------------------------------------------;
849 ; If = 1 then the command can be executed with a file that
850 ; is r/o. If = 0 the command can not be executed, and error.
859 db 0 ;replac_from_curr
860 db 1 ;search_from_curr
868 ;-----------------------------------------------------------------------;
871 if roprot
;***** R/O *****
873 cmp [roflag
],01 ;are we in r/o mode?
875 MOV DX,OFFSET DG
:FCB2
;yes, quit without query.
880 call rest_dir
;restore directory if needed
890 ;----- Load till physical end of file
891 cmp cx,word ptr[amnt_req
]
894 inc al ;reset zero flag
898 push di ;get rid of any ^Z at the end of the file
900 dec di ;points to last char
901 cmp byte ptr [di],1
ah
906 xor al,al ;set zero flag
907 call check_end
;check that we have a CRLF pair at the end
910 ;----- Load till first ^Z is found
916 jz not_found
;skip with zero flag set
917 REPNE SCASB ;Scan for end of file mark
919 LAHF ;Save flags momentarily
920 inc cx ;include the ^Z
923 mov di,cx ;not found at the end
925 LAHF ;Save flags momentarily
926 SUB CX,DI ;Reduce byte count if EOF found
929 call check_end
;check that we have a CRLF pair at the end
934 ;-----------------------------------------------------------------------
935 ; If the end of file was found, then check that the last character
936 ; in the file is a LF. If not put a CRLF pair in.
939 jnz not_end
;end was not reached
940 pushf ;save return flag
941 push di ;save pointer to buffer
942 add di,cx ;points to one past end on text
943 dec di ;points to last character
944 cmp di,offset dg
:start
946 cmp byte ptr[di],0ah ;is a LF the last character?
947 je check_done
;yes, exit
949 mov byte ptr[di+1],0dh ;no, put a CR
950 inc cx ;one more char in text
951 mov byte ptr[di+2],0ah ;put a LF
952 inc cx ;another character at the end
964 TEST BYTE PTR [HAVEOF
],-1
967 CMP [PARAM1
],0 ;See if parameter is missing
969 CMP DX,[THREE4TH
] ;See if already 3/4ths full
970 JAE RET2
;If so, then done already
976 SUB CX,DX ;Amount of memory available
981 mov [amnt_req
],cx ;save ammount of chars requested
982 MOV AH,FCB_RANDOM_READ_BLOCK
983 INT 21H
;Fill memory with file data
985 PUSH CX ;Save actual byte count
988 MOV BYTE PTR [HAVEOF
],1 ;Set flag if 1AH found in file
995 ADD AX,CX ;First byte after loaded text
996 CMP AX,[THREE4TH
] ;See if we made 3/4 full
1000 SUB CX,DI ;Length remaining over 3/4
1001 MOV BX,1 ;Look for one more line
1003 CALL SCANLN
;Look for BX lines
1004 CMP [DI-1],AL ;Check for full line
1009 REPNE SCASB ;Scan backwards for last line
1015 POP CX ;Actual amount read
1016 MOV WORD PTR [DI],1
AH ;Place EOF after last line
1019 ADD DI,CX ;Amount of file read but not used
1020 SUB WORD PTR DS:[FCB
+fcb_RR
],DI ;Adjust RR field in case end of file
1021 SBB WORD PTR DS:[FCB
+fcb_RR
+2],0 ; was not reached
1024 MOV BYTE PTR [HAVEOF
],0
1027 MOV DX,OFFSET DG
:EOF
1028 MOV AH,STD_CON_STRING_OUTPUT
1032 TEST BYTE PTR [HAVEOF
],-1
1034 TEST BYTE PTR [ENDING
],-1
1035 JNZ RET3
;Suppress memory error during End
1044 SUB DI,CX ;Write everything in front of here
1046 CMP DI,OFFSET DG
:START
;See if there's anything to write
1049 MOV BX,1 ;Look for one more line
1056 CMP BYTE PTR [DELFLG
],0
1059 CALL DELBAK
;Want to delete the .BAK file
1060 ;as soon as the first write occurs
1064 MOV DX,OFFSET DG
:START
1065 SUB CX,DX ;Amount to write
1069 MOV DX,OFFSET DG
:FCB2
1070 MOV AH,FCB_RANDOM_WRITE_BLOCK
1075 MOV DI,OFFSET DG
:START
1079 INC CX ;Amount of text remaining
1081 DEC DI ;Point to EOF
1089 MOV DX,OFFSET DG
:DSKFUL
1091 MOV AH,STD_CON_STRING_OUTPUT
1093 ;-----------------------------------------------------------------------
1094 call rest_dir
;restore to the proper directory
1095 ;-----------------------------------------------------------------------
1101 xor bx,bx ;get last line in the buffer
1106 or bx,bx ;was it specified?
1107 jnz frstok
;yes, use it
1109 cmp bx,1 ;if current line =1 start from there
1111 inc bx ;start from current+1 line
1113 cmp bx,[lastlin
] ;check that we are in the buffer
1114 ja ret$5
;if not just quit
1117 or dx,dx ;was param2 specified?
1118 jnz scndok
;yes,....
1119 mov dx,bx ;no, take the end line to be the
1120 add dx,22 ; start line + 23
1123 cmp dx,[lastlin
] ;check that we are in the buffer
1125 mov dx,[lastlin
] ;we are not, take the last line as end
1127 cmp dx,bx ;is param1 < param2 ?
1128 jbe ret$5
;yes, no backwards listing, quit
1129 push dx ;save the end line
1130 push bx ;save start line
1131 mov bx,dx ;set the current line
1136 pop bx ;restore start line
1137 call findlin
;get pointer to start line
1138 mov si,di ;save pointer
1139 pop di ;get end line
1140 sub di,bx ;number of lines
1171 ; SI = Pointer to text buffer
1174 ; Ouputs specified no. of line to terminal, each
1175 ; with leading line number.
1177 ; BX = Last line output.
1178 ; All registers destroyed.
1215 MOV DI,2 + OFFSET DG
:EDITBUF
1238 mov byte ptr [srchmod
],1 ;search from curr+1 line
1242 mov byte ptr [srchmod
],0 ;search from beg of buffer
1244 MOV BYTE PTR [SRCHFLG
],0
1249 CALL LOADBUF
;Count length of line
1252 ADD DX,CX ;Length of new line
1261 SUB CX,SI ;Get no. of char on line before change
1263 CALL OUTCNT
;Output first part of line
1265 MOV SI,1+ OFFSET DG
:TXT2
1267 CALL OUTCNT
;Output change
1269 ADD SI,[OLDLEN
] ;Skip over old stuff in line
1270 MOV CX,DX ;DX=no. of char left in line
1271 ADD CX,2 ;Include CR/LF
1272 CALL OUTCNT
;Output last part of line
1273 CALL QUERY
;Check if change OK
1278 MOV SI,1+ OFFSET DG
:TXT2
1282 ADD [LSTFND
],CX ;Bump pointer beyond new text
1285 SUB [SRCHCNT
],DX ;Old text will not be searched
1306 MOV DX,OFFSET DG
:TOOLNG
1310 mov byte ptr [srchmod
],1 ;search from curr+1 line
1314 mov byte ptr [srchmod
],0 ;search from beg of buffer
1316 MOV BYTE PTR [SRCHFLG
],1
1337 MOV DX,OFFSET DG
:NOSUCH
1339 MOV AH,STD_CON_STRING_OUTPUT
1345 DEC BX ;Current <= Last matched line
1387 INC BX ;Default is current line plus one
1404 MOV AH,STD_CON_STRING_INPUT
;Get input buffer
1405 MOV DX,OFFSET DG
:EDITBUF
1413 MOV SI,2 + OFFSET DG
:EDITBUF
1414 ;-----------------------------------------------------------------------
1415 call unquote
;scan for quote chars if any
1416 ;-----------------------------------------------------------------------
1422 ; CX = Length of new text
1423 ; DX = Length of original text
1424 ; SI = Pointer to new text
1425 ; DI = Pointer to old text in buffer
1427 ; New text replaces old text in buffer and buffer
1428 ; size is adjusted. CX or DX may be zero.
1429 ; CX, SI, DI all destroyed. No other registers affected.
1465 MOV DX,OFFSET DG
:MEMFUL
1466 MOV AH,STD_CON_STRING_OUTPUT
1471 MOV DX,OFFSET DG
:BADCOM
1476 MOV BYTE PTR [MOVFLG
],1
1479 MOV BYTE PTR [MOVFLG
],0
1482 MOV BX,[PARAM3
] ;Third parameter must be specified
1484 MOV DX,OFFSET DG
:DEST
1486 MOV BX,[PARAM1
] ;Get the first parameter
1487 OR BX,BX ;Not specified?
1489 MOV BX,[CURRENT
] ;Defaults to the current line
1491 MOV [PARAM1
],BX ;Save it since current line may change
1493 CALL FINDLIN
;Get a pointer to the line
1494 MOV [PTR_1
],DI ;Save it
1495 MOV BX,[PARAM2
] ;Get the second parameter
1496 OR BX,BX ;Not specified?
1498 MOV BX,[CURRENT
] ;Defaults to the current line
1499 MOV [PARAM2
],BX ;Save it since current line may change
1501 ;Parameters must not overlap
1508 INC BX ;Get pointer to line Param2+1
1511 MOV [PTR_2
],SI ;Save it
1513 MOV DI,[PTR_1
] ;Restore pointer to line Param1
1514 SUB CX,DI ;Calculate number of bytes to copy
1515 MOV [COPYSIZ
],CX ;Save in COPYSIZ
1516 PUSH CX ;And on the stack
1517 MOV AX,[PARAM4
] ;Is count specified?
1569 JMP SHORT COPY_TEXT_1
1571 CMP BYTE PTR[MOVFLG
],0
1600 MOV CX,[ENDTXT
] ;Get End-of-text marker
1602 SUB CX,DI ;Calculate number of bytes to copy
1606 REP MOVSB ;Copy CX bytes
1612 MOV [POINTER
],DI ;Current line is first free loc
1613 MOV [CURRENT
],BX ; in the file
1614 MOV [ENDTXT
],BP ;End-of-text is last free loc before
1622 MOV AX,(PARSE_FILE_DESCRIPTOR
SHL 8) OR 1
1623 MOV DI,OFFSET DG
:FCB3
1626 MOV DX,OFFSET DG
:BADDRV
1629 MOV DX,OFFSET DG
:FCB3
1633 MOV DX,OFFSET DG
:FILENM
1635 MOV AX,(SET_INTERRUPT_VECTOR
SHL 8) OR 23H
1636 MOV DX,OFFSET DG
:ABORTMERGE
1648 ;Set DMA address for reading in new file
1653 MOV WORD PTR DS:[FCB3
+fcb_RR
],AX
1654 MOV WORD PTR DS:[FCB3
+fcb_RR
+2],AX
1656 MOV WORD PTR DS:[FCB3
+fcb_RECSIZ
],AX
1657 MOV DX,OFFSET DG
:FCB3
1660 MOV AH,FCB_RANDOM_READ_BLOCK
1664 MOV DX,OFFSET DG
:MRGERR
1665 MOV AH,STD_CON_STRING_OUTPUT
1685 MOV BYTE PTR [DI],1
AH
1686 MOV DX,OFFSET DG
:FCB3
1689 MOV DX,OFFSET DG
:START
1696 MOV AX,(SET_INTERRUPT_VECTOR
SHL 8) OR 23H
;Set vector 23H
1697 MOV DX,OFFSET DG
:ABORTINS
1710 CALL SETPTS
;Update the pointers into file
1712 MOV DX,OFFSET DG
:EDITBUF
1713 MOV AH,STD_CON_STRING_INPUT
1716 MOV SI,2 + OFFSET DG
:EDITBUF
1717 CMP BYTE PTR [SI],1
AH
1719 ;-----------------------------------------------------------------------
1720 call unquote
;scan for quote chars if any
1721 ;-----------------------------------------------------------------------
1742 MOV DX,OFFSET DG
:START
1747 MOV AX,CS ;Restore segment registers
1751 MOV SP,OFFSET DG
:STACK
1771 MOV AX,(SET_INTERRUPT_VECTOR
SHL 8) OR 23H
1772 MOV DX,OFFSET DG
:ABORTCOM
1777 MOV [PARAM1
],-1 ;Read in max. no of lines
1780 ;Write text out to .$$$ file
1781 MOV BYTE PTR [ENDING
],1 ;Suppress memory errors
1782 MOV BX,-1 ;Write max. no of lines
1784 TEST BYTE PTR [HAVEOF
],-1
1790 MOV DX,OFFSET DG
:FCB2
1791 MOV AH,FCB_RANDOM_WRITE_BLOCK
1792 INT 21H
;Write end-of-file byte
1797 LEA DI,[SI+fcb_FILSIZ
]
1801 MOV SI,OFFSET DG
:BAK
1804 ;Rename original file .BAK
1808 MOV DI,OFFSET DG
:FCB2
+ fcb_FILSIZ
1811 ;Rename .$$$ file to original name
1812 MOV DX,OFFSET DG
:FCB2
1814 call rest_dir
;restore directory if needed
1822 MOV SP,OFFSET DG
:STACK
1828 MOV BYTE PTR [DELFLG
],1
1829 MOV DI,9+OFFSET DG
:FCB2
1830 MOV SI,OFFSET DG
:BAK
1833 ;Delete old backup file (.BAK)
1835 MOV DX,OFFSET DG
:FCB2
1837 MOV DI,9+OFFSET DG
:FCB2
1846 \1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a\1a