diff options
| author | 2024-04-25 21:24:10 +0100 | |
|---|---|---|
| committer | 2024-04-25 22:32:27 +0000 | |
| commit | 2d04cacc5322951f187bb17e017c12920ac8ebe2 (patch) | |
| tree | 80ee017efa878dfd5344b44249e6a241f2a7f6e2 /v4.0/src/CMD/EDLIN | |
| parent | Merge pull request #430 from jpbaltazar/typoptbr (diff) | |
| download | ms-dos-main.tar.gz ms-dos-main.tar.xz ms-dos-main.zip | |
Diffstat (limited to 'v4.0/src/CMD/EDLIN')
| -rw-r--r-- | v4.0/src/CMD/EDLIN/EDLCMD1.ASM | 664 | ||||
| -rw-r--r-- | v4.0/src/CMD/EDLIN/EDLCMD2.ASM | 1203 | ||||
| -rw-r--r-- | v4.0/src/CMD/EDLIN/EDLEQU.ASM | 156 | ||||
| -rw-r--r-- | v4.0/src/CMD/EDLIN/EDLIN.ASM | 1843 | ||||
| -rw-r--r-- | v4.0/src/CMD/EDLIN/EDLIN.LNK | 7 | ||||
| -rw-r--r-- | v4.0/src/CMD/EDLIN/EDLIN.SKL | 75 | ||||
| -rw-r--r-- | v4.0/src/CMD/EDLIN/EDLMES.ASM | 665 | ||||
| -rw-r--r-- | v4.0/src/CMD/EDLIN/EDLPARSE.ASM | 281 | ||||
| -rw-r--r-- | v4.0/src/CMD/EDLIN/EDLSTDSW.INC | 32 | ||||
| -rw-r--r-- | v4.0/src/CMD/EDLIN/MAKEFILE | 56 |
10 files changed, 4982 insertions, 0 deletions
diff --git a/v4.0/src/CMD/EDLIN/EDLCMD1.ASM b/v4.0/src/CMD/EDLIN/EDLCMD1.ASM new file mode 100644 index 0000000..ea304f4 --- /dev/null +++ b/v4.0/src/CMD/EDLIN/EDLCMD1.ASM | |||
| @@ -0,0 +1,664 @@ | |||
| 1 | PAGE 60,132; | ||
| 2 | TITLE EDLCMD1.ASM | ||
| 3 | |||
| 4 | ;======================= START OF SPECIFICATIONS ========================= | ||
| 5 | ; | ||
| 6 | ; MODULE NAME: EDLCMD1.SAL | ||
| 7 | ; | ||
| 8 | ; DESCRIPTIVE NAME: EDLIN ROUTINES | ||
| 9 | ; | ||
| 10 | ; FUNCTION: THIS MODULE PROVIDES ROUTINES NEEDED FOR EDLIN'S EXECUTION. | ||
| 11 | ; | ||
| 12 | ; ENTRY POINT: ANY CALLED ROUTINE | ||
| 13 | ; | ||
| 14 | ; EXIT NORMAL: NA | ||
| 15 | ; | ||
| 16 | ; EXIT ERROR : NA | ||
| 17 | ; | ||
| 18 | ; INTERNAL REFERENCES: | ||
| 19 | ; | ||
| 20 | ; EXTERNAL REFERENCES: | ||
| 21 | ; | ||
| 22 | ; ROUTINE: EDLCMD2 - ROUTINES MAY BE CALLED FROM EDLCMD2 | ||
| 23 | ; EDLMES - ROUTINES MAY BE CALLED FROM EDLMES | ||
| 24 | ; | ||
| 25 | ; NOTES: THIS MODULE IS TO BE PREPPED BY SALUT WITH THE "PR" OPTIONS. | ||
| 26 | ; LINK EDLIN+EDLCMD1+EDLCMD2+EDLMES+EDLPARSE | ||
| 27 | ; | ||
| 28 | ; REVISION HISTORY: | ||
| 29 | ; | ||
| 30 | ; AN000 VERSION DOS 4.00 - REVISIONS MADE RELATE TO THE FOLLOWING: | ||
| 31 | ; | ||
| 32 | ; - IMPLEMENT SYSPARSE | ||
| 33 | ; - IMPLEMENT MESSAGE RETRIEVER | ||
| 34 | ; - IMPLEMENT DBCS ENABLING | ||
| 35 | ; - ENHANCED VIDEO SUPPORT | ||
| 36 | ; - EXTENDED OPENS | ||
| 37 | ; - SCROLLING ERROR | ||
| 38 | ; | ||
| 39 | ; COPYRIGHT: "MS DOS EDLIN UTILITY" | ||
| 40 | ; "VERSION 4.00 (C) COPYRIGHT 1988 Microsoft" | ||
| 41 | ; | ||
| 42 | ;======================= END OF SPECIFICATIONS =========================== | ||
| 43 | |||
| 44 | include edlequ.asm | ||
| 45 | |||
| 46 | SUBTTL Contants and Data areas | ||
| 47 | PAGE | ||
| 48 | |||
| 49 | |||
| 50 | CODE SEGMENT PUBLIC | ||
| 51 | CODE ENDS | ||
| 52 | |||
| 53 | CONST SEGMENT PUBLIC WORD | ||
| 54 | CONST ENDS | ||
| 55 | |||
| 56 | cstack segment stack | ||
| 57 | cstack ends | ||
| 58 | |||
| 59 | DATA SEGMENT PUBLIC WORD | ||
| 60 | DATA ENDS | ||
| 61 | |||
| 62 | DG GROUP CODE,CONST,cstack,DATA | ||
| 63 | |||
| 64 | CONST SEGMENT PUBLIC WORD | ||
| 65 | EXTRN DSKFUL_ptr:word,READ_ERR_PTR:word | ||
| 66 | EXTRN NOSUCH_ptr:word,TOOLNG_ptr:word,EOF_ptr:word | ||
| 67 | extrn txt1:byte,txt2:byte | ||
| 68 | CONST ENDS | ||
| 69 | |||
| 70 | cstack segment stack | ||
| 71 | cstack ends | ||
| 72 | |||
| 73 | DATA SEGMENT PUBLIC WORD | ||
| 74 | extrn ParamCt:WORD | ||
| 75 | extrn current:word,pointer:word,start:word,endtxt:word | ||
| 76 | extrn wrt_handle:word,editbuf:byte,path_name:byte,fname_len:word | ||
| 77 | extrn arg_buf:byte,arg_buf_ptr:word | ||
| 78 | extrn olddat:byte,oldlen:word,newlen:word,param1:word,param2:word | ||
| 79 | extrn srchflg:byte,srchmod:byte,comline:word,lstfnd:word,numpos:word | ||
| 80 | extrn lstnum:word,srchcnt:word,amnt_req:word,delflg:byte,lastlin:word | ||
| 81 | extrn three4th:word,one4th:word,last:word,rd_handle:word,ending:byte | ||
| 82 | extrn haveof:byte | ||
| 83 | extrn Disp_Len:Byte | ||
| 84 | |||
| 85 | DATA ENDS | ||
| 86 | |||
| 87 | CODE SEGMENT PUBLIC | ||
| 88 | ASSUME CS:DG,DS:DG,SS:CStack,ES:DG | ||
| 89 | |||
| 90 | extrn findlin:near,shownum:near,loadbuf:near | ||
| 91 | extrn delbak:near,unquote:near,lf:near | ||
| 92 | extrn dispone:near,display:near,query:near | ||
| 93 | extrn quit:near,scanln:near,scaneof:near | ||
| 94 | extrn fndfirst:near,fndnext:near,replace:near,memerr:near | ||
| 95 | extrn std_printf:near,chkrange:near,comerr:near | ||
| 96 | |||
| 97 | public xerror,bad_read,append,nocom,pager,list | ||
| 98 | public delete,replac_from_curr,search_from_curr,ewrite,wrt | ||
| 99 | |||
| 100 | NOMOREJ:JMP NOMORE | ||
| 101 | |||
| 102 | APPEND: | ||
| 103 | CMP ParamCt,1 | ||
| 104 | JZ AppendOK | ||
| 105 | JMP ComErr | ||
| 106 | AppendOK: | ||
| 107 | TEST BYTE PTR [HAVEOF],-1 | ||
| 108 | JNZ NOMOREJ | ||
| 109 | MOV DX,[ENDTXT] | ||
| 110 | CMP [PARAM1],0 ;See if parameter is missing | ||
| 111 | JNZ PARMAPP | ||
| 112 | CMP DX,[THREE4TH] ;See if already 3/4ths full | ||
| 113 | jb parmapp | ||
| 114 | return ;If so, then done already | ||
| 115 | PARMAPP: | ||
| 116 | MOV DI,DX | ||
| 117 | MOV CX,[LAST] | ||
| 118 | SUB CX,DX ;Amount of memory available | ||
| 119 | jnz sj53 | ||
| 120 | jmp memerr | ||
| 121 | sj53: | ||
| 122 | MOV DX,[ENDTXT] | ||
| 123 | MOV BX,[RD_HANDLE] | ||
| 124 | mov [amnt_req],cx ;Save number of chars requested | ||
| 125 | MOV AH,READ | ||
| 126 | INT 21H ;Fill memory with file data | ||
| 127 | CMP CX,AX ;Did we read less than we asked for? | ||
| 128 | JZ SJ55 | ||
| 129 | ; Make sure this is an end-of-file by trying to read more | ||
| 130 | PUSH AX ;Save old byte count | ||
| 131 | ADD DX,AX ;Point to next open space in buffer | ||
| 132 | MOV CX,1 ;Just one character past EOF | ||
| 133 | MOV AH,READ | ||
| 134 | INT 21H | ||
| 135 | CMP AX,0 ;Is it EOF? | ||
| 136 | POP AX | ||
| 137 | JNZ SJ54 ;No -- we have one more character | ||
| 138 | MOV BYTE PTR [HAVEOF],1 ;Yes - set old style system call flag | ||
| 139 | JMP SHORT SJ55 | ||
| 140 | SJ54: | ||
| 141 | INC AX ;Include one more char in byte count | ||
| 142 | sj55: | ||
| 143 | MOV CX,AX ;Want byte count in CX | ||
| 144 | PUSH CX ;Save actual byte count | ||
| 145 | CALL SCANEOF | ||
| 146 | JNZ NOTEND | ||
| 147 | MOV BYTE PTR [HAVEOF],1 ;Set flag if 1AH found in file | ||
| 148 | NOTEND: | ||
| 149 | XOR DX,DX | ||
| 150 | MOV BX,[PARAM1] | ||
| 151 | OR BX,BX | ||
| 152 | JNZ COUNTLN | ||
| 153 | MOV AX,DI | ||
| 154 | ADD AX,CX ;First byte after loaded text | ||
| 155 | CMP AX,[THREE4TH] ;See if we made 3/4 full | ||
| 156 | JBE COUNTLN | ||
| 157 | MOV DI,[THREE4TH] | ||
| 158 | MOV CX,AX | ||
| 159 | SUB CX,DI ;Length remaining over 3/4 | ||
| 160 | MOV BX,1 ;Look for one more line | ||
| 161 | COUNTLN: | ||
| 162 | CALL SCANLN ;Look for BX lines | ||
| 163 | CMP [DI-1],AL ;Check for full line | ||
| 164 | JZ FULLN | ||
| 165 | CMP HavEof,1 | ||
| 166 | JNZ DoBackScan | ||
| 167 | ; | ||
| 168 | ; We have an incomplete line in the buffer at end of file. Fix it up to be | ||
| 169 | ; pretty. | ||
| 170 | ; | ||
| 171 | MOV BYTE PTR [DI],13 ; CR | ||
| 172 | MOV BYTE PTR [DI+1],10 ; LF | ||
| 173 | ADD DI,2 ; length is 2 greater | ||
| 174 | POP CX | ||
| 175 | ADD CX,2 | ||
| 176 | PUSH CX | ||
| 177 | JMP SHORT FULLN | ||
| 178 | |||
| 179 | DoBackScan: | ||
| 180 | DEC DI | ||
| 181 | MOV CX,[LAST] | ||
| 182 | STD | ||
| 183 | REPNE SCASB ;Scan backwards for last line | ||
| 184 | CLD | ||
| 185 | INC DI | ||
| 186 | INC DI | ||
| 187 | DEC DX | ||
| 188 | FULLN: | ||
| 189 | POP CX ;Actual amount read | ||
| 190 | MOV WORD PTR [DI],1AH ;Place EOF after last line | ||
| 191 | SUB CX,DI | ||
| 192 | XCHG DI,[ENDTXT] | ||
| 193 | ADD DI,CX ;Amount of file read but not used | ||
| 194 | ; Must seek for old partial line | ||
| 195 | OR DI,DI | ||
| 196 | JZ FULLN1 | ||
| 197 | PUSH DX | ||
| 198 | PUSH BX | ||
| 199 | MOV BX,[RD_HANDLE] | ||
| 200 | MOV DX,DI | ||
| 201 | NEG DX | ||
| 202 | MOV CX,-1 | ||
| 203 | MOV AL,1 | ||
| 204 | MOV AH,LSEEK | ||
| 205 | INT 21H | ||
| 206 | POP BX | ||
| 207 | POP DX | ||
| 208 | JC BAD_READ | ||
| 209 | FULLN1: | ||
| 210 | CMP BX,DX | ||
| 211 | JNZ EOFCHK | ||
| 212 | MOV BYTE PTR [HAVEOF],0 | ||
| 213 | return | ||
| 214 | NOMORE: | ||
| 215 | MOV DX,OFFSET DG:EOF_ptr | ||
| 216 | call std_printf | ||
| 217 | ret3: return | ||
| 218 | |||
| 219 | BAD_READ: | ||
| 220 | MOV DX,OFFSET DG:READ_ERR_ptr | ||
| 221 | MOV DI,offset dg:path_name | ||
| 222 | ADD DI,[FNAME_LEN] | ||
| 223 | MOV AL,0 | ||
| 224 | STOSB | ||
| 225 | JMP XERROR | ||
| 226 | |||
| 227 | EOFCHK: | ||
| 228 | TEST BYTE PTR [HAVEOF],-1 | ||
| 229 | JNZ NOMORE | ||
| 230 | TEST BYTE PTR [ENDING],-1 | ||
| 231 | retnz ;Suppress memory error during End | ||
| 232 | JMP MEMERR | ||
| 233 | |||
| 234 | EWRITE: | ||
| 235 | CMP ParamCt,1 | ||
| 236 | JBE EWriteOK | ||
| 237 | JMP ComErr | ||
| 238 | EWriteOK: | ||
| 239 | MOV BX,[PARAM1] | ||
| 240 | OR BX,BX | ||
| 241 | JNZ WRT | ||
| 242 | MOV CX,[ONE4TH] | ||
| 243 | MOV DI,[ENDTXT] | ||
| 244 | SUB DI,CX ;Write everything in front of here | ||
| 245 | JBE RET3 | ||
| 246 | CMP DI,OFFSET DG:START ;See if there's anything to write | ||
| 247 | JBE RET3 | ||
| 248 | XOR DX,DX | ||
| 249 | MOV BX,1 ;Look for one more line | ||
| 250 | CALL SCANLN | ||
| 251 | JMP SHORT WRTADD | ||
| 252 | WRT: | ||
| 253 | INC BX | ||
| 254 | CALL FINDLIN | ||
| 255 | WRTADD: | ||
| 256 | CMP BYTE PTR [DELFLG],0 | ||
| 257 | JNZ WRTADD1 | ||
| 258 | PUSH DI | ||
| 259 | CALL DELBAK ;Want to delete the .BAK file | ||
| 260 | ;as soon as the first write occurs | ||
| 261 | POP DI | ||
| 262 | WRTADD1: | ||
| 263 | MOV CX,DI | ||
| 264 | MOV DX,OFFSET DG:START | ||
| 265 | SUB CX,DX ;Amount to write | ||
| 266 | retz | ||
| 267 | MOV BX,[WRT_HANDLE] | ||
| 268 | MOV AH,WRITE | ||
| 269 | INT 21H | ||
| 270 | JC WRTERR | ||
| 271 | CMP AX,CX ; MZ correct full disk detection | ||
| 272 | JNZ WRTERR ; MZ correct full disk detection | ||
| 273 | MOV SI,DI | ||
| 274 | MOV DI,OFFSET DG:START | ||
| 275 | MOV [POINTER],DI | ||
| 276 | MOV CX,[ENDTXT] | ||
| 277 | SUB CX,SI | ||
| 278 | INC CX ;Amount of text remaining | ||
| 279 | CLD | ||
| 280 | REP MOVSB | ||
| 281 | DEC DI ;Point to EOF | ||
| 282 | MOV [ENDTXT],DI | ||
| 283 | MOV [CURRENT],1 | ||
| 284 | return | ||
| 285 | |||
| 286 | WRTERR: | ||
| 287 | MOV BX,[WRT_HANDLE] | ||
| 288 | MOV AH,CLOSE | ||
| 289 | INT 21H | ||
| 290 | MOV DX,OFFSET DG:DSKFUL_ptr | ||
| 291 | xERROR: | ||
| 292 | push cs | ||
| 293 | pop ds | ||
| 294 | call std_printf | ||
| 295 | mov al,0ffh | ||
| 296 | mov ah,exit | ||
| 297 | int 21h | ||
| 298 | |||
| 299 | NOTFNDJ:JMP NOTFND | ||
| 300 | |||
| 301 | replac_from_curr: | ||
| 302 | CMP ParamCt,2 | ||
| 303 | JBE Replace1 | ||
| 304 | JMP ComErr | ||
| 305 | Replace1: | ||
| 306 | mov byte ptr [srchmod],1 ;search from curr+1 line | ||
| 307 | jmp short sj6 | ||
| 308 | |||
| 309 | REPLAC: | ||
| 310 | mov byte ptr [srchmod],0 ;search from beg of buffer | ||
| 311 | sj6: | ||
| 312 | MOV BYTE PTR [SRCHFLG],0 | ||
| 313 | CALL FNDFIRST | ||
| 314 | JNZ NOTFNDJ | ||
| 315 | REPLP: | ||
| 316 | MOV SI,[NUMPOS] | ||
| 317 | CALL LOADBUF ;Count length of line | ||
| 318 | SUB DX,[OLDLEN] | ||
| 319 | MOV CX,[NEWLEN] | ||
| 320 | ADD DX,CX ;Length of new line | ||
| 321 | CMP DX,254 | ||
| 322 | jbe len_ok | ||
| 323 | Jmp TOOLONG | ||
| 324 | len_ok: | ||
| 325 | MOV BX,[LSTNUM] | ||
| 326 | PUSH DX | ||
| 327 | CALL SHOWNUM | ||
| 328 | POP DX | ||
| 329 | MOV CX,[LSTFND] | ||
| 330 | MOV SI,[NUMPOS] | ||
| 331 | SUB CX,SI ;Get no. of char on line before change | ||
| 332 | DEC CX | ||
| 333 | mov di,offset dg:arg_buf ;Initialize the output string buffer | ||
| 334 | CALL OUTCNT ;Output first part of line | ||
| 335 | PUSH SI | ||
| 336 | MOV SI,1+ OFFSET DG:TXT2 | ||
| 337 | MOV CX,[NEWLEN] | ||
| 338 | CALL OUTCNT ;Output change | ||
| 339 | POP SI | ||
| 340 | ADD SI,[OLDLEN] ;Skip over old stuff in line | ||
| 341 | MOV CX,DX ;DX=no. of char left in line | ||
| 342 | ADD CX,2 ;Include CR/LF | ||
| 343 | CALL OUTCNT ;Output last part of line | ||
| 344 | xor al,al | ||
| 345 | stosb | ||
| 346 | mov dx,offset dg:arg_buf_ptr | ||
| 347 | call std_printf | ||
| 348 | CALL QUERY ;Check if change OK | ||
| 349 | JNZ REPNXT | ||
| 350 | CALL PUTCURS | ||
| 351 | MOV DI,[LSTFND] | ||
| 352 | DEC DI | ||
| 353 | MOV SI,1+ OFFSET DG:TXT2 | ||
| 354 | MOV DX,[OLDLEN] | ||
| 355 | MOV CX,[NEWLEN] | ||
| 356 | DEC CX | ||
| 357 | ADD [LSTFND],CX ;Bump pointer beyond new text | ||
| 358 | INC CX | ||
| 359 | DEC DX | ||
| 360 | SUB [SRCHCNT],DX ;Old text will not be searched | ||
| 361 | JAE SOMELEFT | ||
| 362 | MOV [SRCHCNT],0 | ||
| 363 | SOMELEFT: | ||
| 364 | INC DX | ||
| 365 | CALL REPLACE | ||
| 366 | REPNXT: | ||
| 367 | CALL FNDNEXT | ||
| 368 | retnz | ||
| 369 | JMP REPLP | ||
| 370 | |||
| 371 | OUTCNT: | ||
| 372 | JCXZ RET8 | ||
| 373 | OUTLP: | ||
| 374 | LODSB | ||
| 375 | stosb | ||
| 376 | DEC DX | ||
| 377 | LOOP OUTLP | ||
| 378 | RET8: return | ||
| 379 | |||
| 380 | TOOLONG: | ||
| 381 | MOV DX,OFFSET DG:TOOLNG_ptr | ||
| 382 | JMP SHORT PERR | ||
| 383 | |||
| 384 | search_from_curr: | ||
| 385 | CMP ParamCt,2 | ||
| 386 | JBE Search1 | ||
| 387 | JMP ComErr | ||
| 388 | Search1: | ||
| 389 | mov byte ptr [srchmod],1 ;search from curr+1 line | ||
| 390 | jmp short sj7 | ||
| 391 | |||
| 392 | SEARCH: | ||
| 393 | mov byte ptr [srchmod],0 ;search from beg of buffer | ||
| 394 | sj7: | ||
| 395 | MOV BYTE PTR [SRCHFLG],1 | ||
| 396 | CALL FNDFIRST | ||
| 397 | JNZ NOTFND | ||
| 398 | SRCH: | ||
| 399 | MOV BX,[LSTNUM] | ||
| 400 | MOV SI,[NUMPOS] | ||
| 401 | CALL DISPONE | ||
| 402 | MOV DI,[LSTFND] | ||
| 403 | MOV CX,[SRCHCNT] | ||
| 404 | MOV AL,10 | ||
| 405 | CLD | ||
| 406 | REPNE SCASB | ||
| 407 | JNZ NOTFND | ||
| 408 | MOV [LSTFND],DI | ||
| 409 | MOV [NUMPOS],DI | ||
| 410 | MOV [SRCHCNT],CX | ||
| 411 | INC [LSTNUM] | ||
| 412 | CALL QUERY | ||
| 413 | JZ PUTCURS1 | ||
| 414 | CALL FNDNEXT | ||
| 415 | JZ SRCH | ||
| 416 | NOTFND: | ||
| 417 | MOV DX,OFFSET DG:NOSUCH_ptr | ||
| 418 | PERR: | ||
| 419 | call std_printf | ||
| 420 | return | ||
| 421 | |||
| 422 | ; | ||
| 423 | ; Replace enters here with LSTNUM pointing to the correct line. | ||
| 424 | ; | ||
| 425 | PUTCURS: | ||
| 426 | MOV BX,[LSTNUM] | ||
| 427 | jmp short putcursor | ||
| 428 | ; | ||
| 429 | ; Search enters here with LSTNUM pointing AFTER the correct line | ||
| 430 | ; | ||
| 431 | putcurs1: | ||
| 432 | MOV BX,[LSTNUM] | ||
| 433 | DEC BX ;Current <= Last matched line | ||
| 434 | |||
| 435 | putcursor: | ||
| 436 | CALL FINDLIN | ||
| 437 | MOV [CURRENT],DX | ||
| 438 | MOV [POINTER],DI | ||
| 439 | return | ||
| 440 | |||
| 441 | ; | ||
| 442 | ; n,mD deletes a range of lines. Allowable values for n are: | ||
| 443 | ; 1 ... LAST. Allowable values for m are: | ||
| 444 | ; 1 ... LAST. | ||
| 445 | ; nD deletes a single line | ||
| 446 | ; D deletes the current line | ||
| 447 | ; | ||
| 448 | DELETE: | ||
| 449 | CMP ParamCt,2 ; at most two parameters specified. | ||
| 450 | JA ComErrJ | ||
| 451 | MOV BX,Param1 | ||
| 452 | OR BX,BX ; default first arg? | ||
| 453 | JNZ DelParm2 | ||
| 454 | MOV BX,Current ; use current as default | ||
| 455 | MOV Param1,BX | ||
| 456 | DelParm2: | ||
| 457 | MOV BX,Param2 ; did we default second arg? | ||
| 458 | OR BX,BX | ||
| 459 | JNZ DelCheck ; no, use it. | ||
| 460 | MOV BX,Param1 ; use param1 as default | ||
| 461 | MOV Param2,BX | ||
| 462 | DelCheck: | ||
| 463 | MOV BX,Param1 | ||
| 464 | CALL ChkRange ; returns by itself if bad range | ||
| 465 | ; | ||
| 466 | ; BX is first line of range to be deleted. Param2 is last line in range to | ||
| 467 | ; be deleted. Get pointer to beginning of block. Save location | ||
| 468 | ; | ||
| 469 | CALL FINDLIN ; Grab line | ||
| 470 | retnz ; If not found => return | ||
| 471 | PUSH BX | ||
| 472 | PUSH DI | ||
| 473 | ; | ||
| 474 | ; Get pointer past end of block (Param2+1). | ||
| 475 | ; | ||
| 476 | MOV BX,Param2 | ||
| 477 | INC BX | ||
| 478 | CALL FINDLIN | ||
| 479 | ; | ||
| 480 | ; Set up pointers. Compute number of chars to move. | ||
| 481 | ; | ||
| 482 | MOV SI,DI ; move from second line+1 | ||
| 483 | POP DI ; restore destination (first line) | ||
| 484 | POP Current ; Current line is first param | ||
| 485 | MOV Pointer,DI ; internal current line | ||
| 486 | MOV CX,EndTxt ; compute count | ||
| 487 | SUB CX,SI | ||
| 488 | JB ComErrJ ; should never occur: ChkRange | ||
| 489 | INC CX ; remember ^Z at end | ||
| 490 | CLD | ||
| 491 | REP MOVSB ; move data | ||
| 492 | DEC DI | ||
| 493 | MOV EndTxt,DI ; reset end pointer | ||
| 494 | return | ||
| 495 | |||
| 496 | COMERRJ: | ||
| 497 | JMP COMERR | ||
| 498 | |||
| 499 | PAGER: | ||
| 500 | CMP ParamCt,2 | ||
| 501 | JA ComErrJ | ||
| 502 | xor bx,bx ;get last line in the buffer | ||
| 503 | call findlin | ||
| 504 | mov [lastlin],dx | ||
| 505 | |||
| 506 | mov bx,[param1] | ||
| 507 | or bx,bx ;was it specified? | ||
| 508 | jnz frstok ;yes, use it | ||
| 509 | mov bx,[current] | ||
| 510 | cmp bx,1 ;if current line =1 start from there | ||
| 511 | je frstok | ||
| 512 | inc bx ;start from current+1 line | ||
| 513 | frstok: | ||
| 514 | cmp bx,[lastlin] ;check that we are in the buffer | ||
| 515 | jbe frstok1 | ||
| 516 | return ;if not just quit | ||
| 517 | frstok1: | ||
| 518 | mov dx,[param2] | ||
| 519 | or dx,dx ;was param2 specified? | ||
| 520 | jnz scndok ;yes,.... | ||
| 521 | mov dx,bx ;no, take the end line to be the | ||
| 522 | ; start line + length of active display | ||
| 523 | |||
| 524 | ;========================================================================= | ||
| 525 | ; This modification is to provide support for screens larger than | ||
| 526 | ; 24 lines. | ||
| 527 | ; | ||
| 528 | ; Date : 6/10/87 | ||
| 529 | ;========================================================================= | ||
| 530 | |||
| 531 | push ax ;an000;save affected registers | ||
| 532 | |||
| 533 | mov ah,00h ;an000;zero out high byte | ||
| 534 | mov al,dg:disp_len ;an000;set ax to active display length | ||
| 535 | sub ax,2 ;an000;adjust for length of screen & current | ||
| 536 | ; line | ||
| 537 | add dx,ax ;an000;this gives us the last line to be | ||
| 538 | ; printed | ||
| 539 | pop ax ;an000;restore affected registers | ||
| 540 | |||
| 541 | ;========================================================================= | ||
| 542 | |||
| 543 | scndok: | ||
| 544 | inc dx | ||
| 545 | cmp dx,[lastlin] ;check that we are in the buffer | ||
| 546 | jbe infile | ||
| 547 | mov dx,[lastlin] ;we are not, take the last line as end | ||
| 548 | infile: | ||
| 549 | cmp dx,bx ;is param1 < param2 ? | ||
| 550 | retz | ||
| 551 | ja sj33 | ||
| 552 | jmp comerr ;yes, no backwards listing, print error | ||
| 553 | sj33: | ||
| 554 | push dx ;save the end line | ||
| 555 | push bx ;save start line | ||
| 556 | mov bx,dx ;set the current line | ||
| 557 | dec bx | ||
| 558 | call findlin | ||
| 559 | mov [pointer],di | ||
| 560 | mov [current],dx | ||
| 561 | pop bx ;restore start line | ||
| 562 | call findlin ;get pointer to start line | ||
| 563 | mov si,di ;save pointer | ||
| 564 | pop di ;get end line | ||
| 565 | sub di,bx ;number of lines | ||
| 566 | jmp short display_lines | ||
| 567 | |||
| 568 | |||
| 569 | LIST: | ||
| 570 | CMP ParamCt,2 | ||
| 571 | JBE ListOK | ||
| 572 | JMP ComERR | ||
| 573 | ListOK: | ||
| 574 | MOV BX,[PARAM1] | ||
| 575 | OR BX,BX | ||
| 576 | JNZ CHKP2 | ||
| 577 | MOV BX,[CURRENT] | ||
| 578 | SUB BX,11 | ||
| 579 | JA CHKP2 | ||
| 580 | MOV BX,1 | ||
| 581 | CHKP2: | ||
| 582 | CALL FINDLIN | ||
| 583 | retnz | ||
| 584 | MOV SI,DI | ||
| 585 | MOV DI,[PARAM2] | ||
| 586 | INC DI | ||
| 587 | SUB DI,BX | ||
| 588 | JA DISPLAY_lines | ||
| 589 | |||
| 590 | ;========================================================================= | ||
| 591 | ; This modification is to provide support for screens larger than | ||
| 592 | ; 24 lines. | ||
| 593 | ; | ||
| 594 | ; Date : 6/10/87 | ||
| 595 | ;========================================================================= | ||
| 596 | |||
| 597 | push ax ;an000;save affected registers | ||
| 598 | |||
| 599 | mov ah,00h ;an000;zero out high byte | ||
| 600 | mov al,dg:disp_len ;an000;set ax to active display length dec ax ;an000;allow room at bottom for | ||
| 601 | ; messages | ||
| 602 | mov di,ax ;an000;number of lines to print an | ||
| 603 | ; entire screen less 1. | ||
| 604 | pop ax ;an000;restore affected registers | ||
| 605 | |||
| 606 | ;========================================================================= | ||
| 607 | |||
| 608 | display_lines: | ||
| 609 | call DISPLAY | ||
| 610 | return | ||
| 611 | |||
| 612 | Break <NOCOM - edit a single line> | ||
| 613 | |||
| 614 | ; | ||
| 615 | ; NOCOM is called when there is a single line being edited. This occurs when | ||
| 616 | ; the command letter is CR or is ;. | ||
| 617 | ; | ||
| 618 | NOCOM: | ||
| 619 | CMP ParamCt,2 | ||
| 620 | JB NoComOK | ||
| 621 | JMP ComErr | ||
| 622 | NoComOK: | ||
| 623 | DEC [COMLINE] | ||
| 624 | MOV BX,[PARAM1] | ||
| 625 | OR BX,BX | ||
| 626 | JNZ HAVLIN | ||
| 627 | MOV BX,[CURRENT] | ||
| 628 | INC BX ;Default is current line plus one | ||
| 629 | CALL CHKRANGE | ||
| 630 | HAVLIN: | ||
| 631 | CALL FINDLIN | ||
| 632 | MOV SI,DI | ||
| 633 | MOV [CURRENT],DX | ||
| 634 | MOV [POINTER],SI | ||
| 635 | jz sj12 | ||
| 636 | ret12: return | ||
| 637 | sj12: | ||
| 638 | CMP SI,[ENDTXT] | ||
| 639 | retz | ||
| 640 | CALL LOADBUF | ||
| 641 | MOV [OLDLEN],DX | ||
| 642 | MOV SI,[POINTER] | ||
| 643 | CALL DISPONE | ||
| 644 | CALL SHOWNUM | ||
| 645 | MOV AH,STD_CON_STRING_INPUT ;Get input buffer | ||
| 646 | MOV DX,OFFSET DG:EDITBUF | ||
| 647 | INT 21H | ||
| 648 | CALL lf | ||
| 649 | MOV CL,[EDITBUF+1] | ||
| 650 | MOV CH,0 | ||
| 651 | JCXZ RET12 | ||
| 652 | MOV DX,[OLDLEN] | ||
| 653 | MOV SI,2 + OFFSET DG:EDITBUF | ||
| 654 | ;----------------------------------------------------------------------- | ||
| 655 | call unquote ;scan for quote chars if any | ||
| 656 | ;----------------------------------------------------------------------- | ||
| 657 | mov cl,[EditBuf+1] ;an000; dms;get new line length | ||
| 658 | mov ch,0 ;an000; dms;clear high byte | ||
| 659 | MOV DI,[POINTER] | ||
| 660 | JMP Replace ; MZ 11/30 | ||
| 661 | |||
| 662 | CODE ENDS | ||
| 663 | END | ||
| 664 | \ No newline at end of file | ||
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 | ||
| 2 | TITLE 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 | |||
| 46 | include edlequ.asm | ||
| 47 | |||
| 48 | CODE SEGMENT PUBLIC | ||
| 49 | CODE ENDS | ||
| 50 | |||
| 51 | CONST SEGMENT PUBLIC WORD | ||
| 52 | CONST ENDS | ||
| 53 | |||
| 54 | cstack segment stack | ||
| 55 | cstack ends | ||
| 56 | |||
| 57 | DATA SEGMENT PUBLIC WORD | ||
| 58 | DATA ENDS | ||
| 59 | |||
| 60 | |||
| 61 | DG GROUP CODE,CONST,cstack,DATA | ||
| 62 | |||
| 63 | CONST 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 | |||
| 71 | CONST ENDS | ||
| 72 | |||
| 73 | DATA 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 | |||
| 94 | DATA ENDS | ||
| 95 | |||
| 96 | CODE SEGMENT PUBLIC | ||
| 97 | |||
| 98 | ASSUME 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 | |||
| 111 | FINDLIN: | ||
| 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 | ||
| 132 | FINDIT: | ||
| 133 | MOV CX,[ENDTXT] ; count of bytes in buffer | ||
| 134 | SUB CX,DI ; for scan | ||
| 135 | SCANLN: | ||
| 136 | MOV AL,10 ; LF is what we look for. | ||
| 137 | OR AL,AL ; Clear zero flag for JCXZ | ||
| 138 | FINLIN: | ||
| 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. | ||
| 144 | RET4: 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 | |||
| 153 | SHOWNUM: | ||
| 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," " | ||
| 160 | STARLIN: | ||
| 161 | call std_printf | ||
| 162 | ret5: return | ||
| 163 | |||
| 164 | |||
| 165 | DISPONE: | ||
| 166 | MOV DI,1 | ||
| 167 | |||
| 168 | DISPLAY: | ||
| 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 | ; | ||
| 204 | DISPLN: | ||
| 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 | ; | ||
| 212 | OUTLN: | ||
| 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 | ||
| 229 | SEND: | ||
| 230 | stosb | ||
| 231 | StoreDone: | ||
| 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 | ||
| 246 | StoreLF: | ||
| 247 | mov al,10 | ||
| 248 | stosb | ||
| 249 | Terminate: | ||
| 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 | ||
| 267 | ret7: return | ||
| 268 | |||
| 269 | FNDFIRST: | ||
| 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 | ||
| 278 | sj8: | ||
| 279 | MOV [OLDLEN],CX | ||
| 280 | XOR CX,CX | ||
| 281 | CMP AL,0DH | ||
| 282 | JZ SETBUF | ||
| 283 | CMP BYTE PTR [SRCHFLG],0 | ||
| 284 | JZ NXTBUF | ||
| 285 | SETBUF: | ||
| 286 | DEC SI | ||
| 287 | NXTBUF: | ||
| 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 | ||
| 296 | HAVCHR: | ||
| 297 | MOV [COMLINE],SI | ||
| 298 | NOTREPL: | ||
| 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 | ||
| 307 | sj9: | ||
| 308 | MOV BX,[CURRENT] | ||
| 309 | INC BX ;Default search and replace to current+1 | ||
| 310 | sj9a: | ||
| 311 | CALL CHKRANGE | ||
| 312 | CALLER: | ||
| 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 | ||
| 327 | aret: return | ||
| 328 | sj10: | ||
| 329 | MOV [SRCHCNT],CX | ||
| 330 | |||
| 331 | FNDNEXT: | ||
| 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] | ||
| 348 | SCAN: | ||
| 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 | ||
| 353 | if kanji | ||
| 354 | call kanji_check ;see if the found byte is on a character boundary | ||
| 355 | jnz scan | ||
| 356 | endif | ||
| 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 | ||
| 375 | GETLIN: | ||
| 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 | |||
| 386 | if 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 | ||
| 395 | kanji_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 | ||
| 401 | srch_loop: | ||
| 402 | lodsb | ||
| 403 | cmp al,40H | ||
| 404 | jae srch_loop | ||
| 405 | inc si ;point to first non-kanji | ||
| 406 | cld ;forward search | ||
| 407 | kan_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 | ||
| 412 | passed_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 | ; | ||
| 421 | next_char: | ||
| 422 | push ax | ||
| 423 | lodsb | ||
| 424 | call testkanj | ||
| 425 | jz not_kanj | ||
| 426 | inc si | ||
| 427 | not_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 | |||
| 442 | testkanj: | ||
| 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 | ||
| 448 | ktlop: | ||
| 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 | ||
| 458 | notl_exit: | ||
| 459 | pop si | ||
| 460 | pop ds | ||
| 461 | pop ax | ||
| 462 | ret | ||
| 463 | notlead: | ||
| 464 | cmp al,al | ||
| 465 | jmp notl_exit | ||
| 466 | |||
| 467 | endif | ||
| 468 | |||
| 469 | GETTEXT: | ||
| 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 | |||
| 485 | GETIT: | ||
| 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 | ;----------------------------------------------------------------------- | ||
| 494 | sj101: | ||
| 495 | CMP AL,1AH | ||
| 496 | JZ DEFCHK | ||
| 497 | sj102: | ||
| 498 | CMP AL,0DH | ||
| 499 | JZ DEFCHK | ||
| 500 | STOSB | ||
| 501 | INC CX | ||
| 502 | JMP SHORT GETIT | ||
| 503 | |||
| 504 | DEFCHK: | ||
| 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 | |||
| 513 | OLDTXT: | ||
| 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 | |||
| 519 | sj11: | ||
| 520 | MOV CL,BYTE PTR [DI-1] | ||
| 521 | ADD DI,CX | ||
| 522 | return | ||
| 523 | |||
| 524 | REPLACE: | ||
| 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 | ||
| 557 | DOMOV: | ||
| 558 | INC CX | ||
| 559 | |||
| 560 | REP MOVSB | ||
| 561 | CLD | ||
| 562 | POP CX | ||
| 563 | POP DI | ||
| 564 | POP SI | ||
| 565 | COPYIN: | ||
| 566 | REP MOVSB | ||
| 567 | return | ||
| 568 | |||
| 569 | MEMERR: | ||
| 570 | MOV DX,OFFSET DG:MEMFUL_ptr | ||
| 571 | call std_printf | ||
| 572 | JMP COMMAND | ||
| 573 | |||
| 574 | |||
| 575 | LOADBUF: | ||
| 576 | MOV DI,2 + OFFSET DG:EDITBUF | ||
| 577 | MOV CX,255 | ||
| 578 | MOV DX,-1 | ||
| 579 | LOADLP: | ||
| 580 | LODSB | ||
| 581 | STOSB | ||
| 582 | INC DX | ||
| 583 | CMP AL,13 | ||
| 584 | LOOPNZ LOADLP | ||
| 585 | MOV [EDITBUF+1],DL | ||
| 586 | retz | ||
| 587 | TRUNCLP: | ||
| 588 | LODSB | ||
| 589 | INC DX | ||
| 590 | CMP AL,13 | ||
| 591 | JNZ TRUNCLP | ||
| 592 | DEC DI | ||
| 593 | STOSB | ||
| 594 | return | ||
| 595 | |||
| 596 | SCANEOF: | ||
| 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 | ||
| 607 | sj51: | ||
| 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 | ||
| 616 | sj51b: | ||
| 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 | |||
| 623 | sj52: | ||
| 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 | ||
| 634 | not_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 | |||
| 650 | check_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 | ||
| 660 | check_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 | ||
| 665 | check_done: | ||
| 666 | pop di | ||
| 667 | popf | ||
| 668 | not_end: | ||
| 669 | return | ||
| 670 | |||
| 671 | CRLF: | ||
| 672 | push dx | ||
| 673 | mov dx,offset dg:crlf_ptr | ||
| 674 | call std_printf | ||
| 675 | pop dx | ||
| 676 | return | ||
| 677 | LF: | ||
| 678 | MOV dx,offset dg:lf_ptr | ||
| 679 | call std_printf | ||
| 680 | return | ||
| 681 | |||
| 682 | ABORTCOM: | ||
| 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 | |||
| 693 | DELBAK: | ||
| 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 | |||
| 749 | unquote: | ||
| 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 | ||
| 758 | unq_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 | ||
| 777 | sj13: 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 | |||
| 782 | unq_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 | |||
| 794 | make_cntrl: | ||
| 795 | push ax | ||
| 796 | and ax,11100000b | ||
| 797 | cmp ax,01000000b | ||
| 798 | pop ax | ||
| 799 | jne sj14 | ||
| 800 | and ax,00011111b | ||
| 801 | sj14: | ||
| 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 | ;========================================================================= | ||
| 811 | kill_bl: | ||
| 812 | |||
| 813 | push bx ;an000;save affected reg. | ||
| 814 | kill_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 | |||
| 863 | MAKE_CAPS: | ||
| 864 | CMP AL,"a" | ||
| 865 | JB CAPS1 | ||
| 866 | CMP AL,"z" | ||
| 867 | if KANJI | ||
| 868 | JA CAPS1 ; M003 MSKK TAR 476, kana chars | ||
| 869 | else | ||
| 870 | JG CAPS1 | ||
| 871 | endif | ||
| 872 | AND AL,0DFH | ||
| 873 | CAPS1: | ||
| 874 | return | ||
| 875 | |||
| 876 | QUIT: | ||
| 877 | CMP ParamCt,1 | ||
| 878 | JZ Quit1 | ||
| 879 | CERR: JMP ComErr | ||
| 880 | Quit1: CMP Param1,0 | ||
| 881 | JNZ CERR | ||
| 882 | MOV DX,OFFSET DG:QMES_ptr | ||
| 883 | call std_printf | ||
| 884 | |||
| 885 | IF 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 | ||
| 891 | ASCII: | ||
| 892 | ENDIF | ||
| 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 | |||
| 923 | NOCRLF: | ||
| 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 | |||
| 934 | QUERY: | ||
| 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 | ||
| 942 | IF 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 | ||
| 952 | ASCII1: | ||
| 953 | ENDIF | ||
| 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 | ||
| 972 | Query_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 | |||
| 1006 | EDLIN_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 | |||
| 1040 | EDLIN_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 | |||
| 1059 | EDLIN_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 | |||
| 1113 | EDLIN_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 | |||
| 1128 | EDLIN_PG_PROMPT proc near ;an000;ask user to continue? | ||
| 1129 | |||
| 1130 | push dx ;an000;save affected regs. | ||
| 1131 | push ax ;an000; | ||
| 1132 | |||
| 1133 | EPP_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 | |||
| 1150 | EPP_True_Exit: | ||
| 1151 | |||
| 1152 | mov Continue,True ;an000;flag Y found | ||
| 1153 | jmp EPP_Exit ;an000;exit routine | ||
| 1154 | |||
| 1155 | EPP_False_Exit: | ||
| 1156 | |||
| 1157 | mov Continue,False ;an000;flag N found | ||
| 1158 | |||
| 1159 | EPP_Exit: | ||
| 1160 | |||
| 1161 | pop ax ;an000;restore affected regs. | ||
| 1162 | pop dx ;an000; | ||
| 1163 | |||
| 1164 | ret ;an000;return to caller | ||
| 1165 | |||
| 1166 | EDLIN_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 | |||
| 1179 | val_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 | |||
| 1197 | val_yn endp ;an000;end proc | ||
| 1198 | |||
| 1199 | |||
| 1200 | |||
| 1201 | code ends | ||
| 1202 | end | ||
| 1203 | \ No newline at end of file | ||
diff --git a/v4.0/src/CMD/EDLIN/EDLEQU.ASM b/v4.0/src/CMD/EDLIN/EDLEQU.ASM new file mode 100644 index 0000000..d60796d --- /dev/null +++ b/v4.0/src/CMD/EDLIN/EDLEQU.ASM | |||
| @@ -0,0 +1,156 @@ | |||
| 1 | page 60,132 ; | ||
| 2 | |||
| 3 | .xlist | ||
| 4 | include DOSSYM.INC | ||
| 5 | include EDLSTDSW.INC | ||
| 6 | .list | ||
| 7 | |||
| 8 | ;======================= START OF SPECIFICATIONS ========================= | ||
| 9 | ; | ||
| 10 | ; MODULE NAME: EDLEQU.SAL | ||
| 11 | ; | ||
| 12 | ; DESCRIPTIVE NAME: EQUATES FOR EDLIN | ||
| 13 | ; | ||
| 14 | ; FUNCTION: PROVIDES EQUATES FOR EDLIN. IT ALSO PROVIDES THE MACRO | ||
| 15 | ; VAL_YN. | ||
| 16 | ; | ||
| 17 | ; ENTRY POINT: NA | ||
| 18 | ; | ||
| 19 | ; INPUT: NA | ||
| 20 | ; | ||
| 21 | ; EXIT NORMAL: NA | ||
| 22 | ; | ||
| 23 | ; EXIT ERROR: NA | ||
| 24 | ; | ||
| 25 | ; INTERNAL REFERENCES: | ||
| 26 | ; | ||
| 27 | ; ROUTINE: VAL_YN - VALIDATES Y/N RESPONSES FROM THE KEYBOARD | ||
| 28 | ; | ||
| 29 | ; EXTERNAL REFERENCES: | ||
| 30 | ; | ||
| 31 | ; ROUTINE: NA | ||
| 32 | ; | ||
| 33 | ; NOTES: THIS MODULE IS TO BE PREPPED BY SALUT WITH THE "PR" OPTIONS. | ||
| 34 | ; LINK EDLIN+EDLCMD1+EDLCMD2+EDLMES+EDLPARSE | ||
| 35 | ; | ||
| 36 | ; REVISION HISTORY: | ||
| 37 | ; | ||
| 38 | ; AN000 VERSION 4.00 - REVISIONS MADE RELATE TO THE FOLLOWING: | ||
| 39 | ; | ||
| 40 | ; - IMPLEMENT SYSPARSE | ||
| 41 | ; - IMPLEMENT MESSAGE RETRIEVER | ||
| 42 | ; - IMPLEMENT DBCS ENABLING | ||
| 43 | ; - ENHANCED VIDEO SUPPORT | ||
| 44 | ; - EXTENDED OPENS | ||
| 45 | ; - SCROLLING ERROR | ||
| 46 | ; | ||
| 47 | ; COPYRIGHT: "MS DOS EDLIN UTILITY" | ||
| 48 | ; "VERSION 4.00 (C) COPYRIGHT 1988 Microsoft" | ||
| 49 | ; | ||
| 50 | ;======================= END OF SPECIFICATIONS =========================== | ||
| 51 | |||
| 52 | |||
| 53 | |||
| 54 | |||
| 55 | |||
| 56 | |||
| 57 | COMAND_LINE_LENGTH EQU 128 | ||
| 58 | QUOTE_CHAR EQU 16H ;Quote character = ^V | ||
| 59 | CR EQU 13 | ||
| 60 | STKSIZ EQU 200h | ||
| 61 | STACK equ stksiz | ||
| 62 | |||
| 63 | asian_blk equ 40h ;an000;asian blank 2nd. byte | ||
| 64 | dbcs_lead_byte equ 81h ;an000;asian blank lead byte | ||
| 65 | nul equ 00h ;an000;nul character | ||
| 66 | Access_Denied equ 0005h ;an000;extended error code for access denied | ||
| 67 | |||
| 68 | ;======== Y/N validation equates ========================================= | ||
| 69 | |||
| 70 | yn_chk equ 23h ;an000;check for Y/N response | ||
| 71 | max_len equ 01h ;an000;max. len. for Y/N char. | ||
| 72 | yes equ 01h ;an000;boolean yes value | ||
| 73 | no equ 00h ;an000;boolean no value | ||
| 74 | |||
| 75 | ;======== text display values for initialization ========================= | ||
| 76 | |||
| 77 | video_get equ 0fh ;an000;int 10 get video attributes | ||
| 78 | video_set equ 00h ;an000;int 10 set video attributes | ||
| 79 | video_text equ 03h ;an000;80 X 25 color monitor | ||
| 80 | |||
| 81 | ;======== code page values for functions ================================= | ||
| 82 | |||
| 83 | get_set_cp equ 66h ;an000;get or set code page | ||
| 84 | get_cp equ 01h ;an000;get active code page | ||
| 85 | set_cp equ 02h ;an000;set active code page | ||
| 86 | |||
| 87 | ;======== screen length & width defaults ================================= | ||
| 88 | |||
| 89 | std_out equ 01h ;an000;console output | ||
| 90 | display_attr equ 03h ;an000;display for IOCTL | ||
| 91 | Get_Display equ 7fh ;an000;Get display for IOCTL | ||
| 92 | Def_Disp_Len equ 25 ;an000;default display length | ||
| 93 | Def_Disp_Width equ 80 ;an000;default display width | ||
| 94 | |||
| 95 | ;======== extended open equates ========================================== | ||
| 96 | |||
| 97 | rw equ 0082h ;an000;read/write | ||
| 98 | ; compatibility | ||
| 99 | ; noinherit | ||
| 100 | ; int 24h handler | ||
| 101 | ; no commit | ||
| 102 | |||
| 103 | ext_read equ 0080h ;an000;read | ||
| 104 | ; compatibility | ||
| 105 | ; noinherit | ||
| 106 | ; int 24h handler | ||
| 107 | ; no commit | ||
| 108 | |||
| 109 | rw_flag equ 0101h ;an000;fail if file not exist | ||
| 110 | ; open if file exists | ||
| 111 | ; don't validate code page | ||
| 112 | |||
| 113 | creat_flag equ 0110h ;an000;create if file does not exist | ||
| 114 | ; fail if file exists | ||
| 115 | ; don't validate code page | ||
| 116 | |||
| 117 | open_flag equ 0101h ;an000;fail if file not exist | ||
| 118 | ; open if file exists | ||
| 119 | ; don't validate code page | ||
| 120 | |||
| 121 | creat_open_flag equ 0112h ;an000;create if file does not exist | ||
| 122 | ; open/replace if file exists | ||
| 123 | ; don't validate code page | ||
| 124 | |||
| 125 | attr equ 00h ;an000;attributes set to 0 | ||
| 126 | |||
| 127 | ;======== parse value equates ============================================ | ||
| 128 | |||
| 129 | nrm_parse_exit equ 0ffffh ;an000;normal exit from sysparse | ||
| 130 | too_many equ 01h ;an000;too many parms entered | ||
| 131 | op_missing equ 02h ;an000;required operand missing | ||
| 132 | sw_missing equ 03h ;an000;not a valid switch | ||
| 133 | |||
| 134 | |||
| 135 | ;======== Strucs ========================================================= | ||
| 136 | |||
| 137 | Display_Buffer_Struc Struc ;an000;dms; | ||
| 138 | |||
| 139 | Display_Info_Level db ? ;an000;dms; | ||
| 140 | Display_Reserved db ? ;an000;dms; | ||
| 141 | Display_Buffer_Size dw ? ;an000;dms; | ||
| 142 | Display_Flags dw ? ;an000;dms; | ||
| 143 | Display_Mode db ? ;an000;dms; | ||
| 144 | ; TEXT=01 | ||
| 145 | ; APA =02 | ||
| 146 | Display_Mode_Reserved db ? ;an000;dms; | ||
| 147 | Display_Colors dw ? ;an000;dms;# of colors | ||
| 148 | Display_Width_Pixels dw ? ;an000;dms;# of pixels in width | ||
| 149 | Display_Length_Pixels dw ? ;an000;dms;# of pixels in len. | ||
| 150 | Display_Width_Char dw ? ;an000;dms;# of chars in width | ||
| 151 | Display_Length_Char dw ? ;an000;dms;# of chars in length | ||
| 152 | |||
| 153 | Display_Buffer_Struc ends ;an000;dms; | ||
| 154 | |||
| 155 | |||
| 156 | \ No newline at end of file | ||
diff --git a/v4.0/src/CMD/EDLIN/EDLIN.ASM b/v4.0/src/CMD/EDLIN/EDLIN.ASM new file mode 100644 index 0000000..5368db0 --- /dev/null +++ b/v4.0/src/CMD/EDLIN/EDLIN.ASM | |||
| @@ -0,0 +1,1843 @@ | |||
| 1 | PAGE 60,132; | ||
| 2 | TITLE EDLIN | ||
| 3 | |||
| 4 | ;======================= START OF SPECIFICATIONS ========================= | ||
| 5 | ; | ||
| 6 | ; MODULE NAME: EDLIN.SAL | ||
| 7 | ; | ||
| 8 | ; DESCRIPTIVE NAME: LINE TEXT EDITOR | ||
| 9 | ; | ||
| 10 | ; FUNCTION: EDLIN IS A SIMPLE, LINE ORIENTED TEXT EDITOR. IT PROVIDES | ||
| 11 | ; USERS OF DOS THE ABILITY TO CREATE AND EDIT TEXT FILES. | ||
| 12 | ; | ||
| 13 | ; ENTRY POINT: EDLIN | ||
| 14 | ; | ||
| 15 | ; INPUT: DOS COMMAND LINE | ||
| 16 | ; EDLIN COMMANDS | ||
| 17 | ; TEXT | ||
| 18 | ; | ||
| 19 | ; EXIT NORMAL: NA | ||
| 20 | ; | ||
| 21 | ; EXIT ERROR: NA | ||
| 22 | ; | ||
| 23 | ; INTERNAL REFERENCES: | ||
| 24 | ; | ||
| 25 | ; EXTERNAL REFERENCES: | ||
| 26 | ; | ||
| 27 | ; ROUTINE: EDLCMD1 - CONTAINS ROUTINES CALLED BY EDLIN | ||
| 28 | ; EDLCMD1 - CONTAINS ROUTINES CALLED BY EDLIN | ||
| 29 | ; EDLMES - CONTAINS ROUTINES CALLED BY EDLIN | ||
| 30 | ; | ||
| 31 | ; NOTES: THIS MODULE IS TO BE PREPPED BY SALUT WITH THE "PR" OPTIONS. | ||
| 32 | ; LINK EDLIN+EDLCMD1+EDLCMD2+EDLMES+EDLPARSE | ||
| 33 | ; | ||
| 34 | ; REVISION HISTORY: | ||
| 35 | ; | ||
| 36 | ; AN000 VERSION 4.00 - REVISIONS MADE RELATE TO THE FOLLOWING: | ||
| 37 | ; | ||
| 38 | ; - IMPLEMENT SYSPARSE | ||
| 39 | ; - IMPLEMENT MESSAGE RETRIEVER | ||
| 40 | ; - IMPLEMENT DBCS ENABLING | ||
| 41 | ; - ENHANCED VIDEO SUPPORT | ||
| 42 | ; - EXTENDED OPENS | ||
| 43 | ; - SCROLLING ERROR | ||
| 44 | ; | ||
| 45 | ; COPYRIGHT: "MS DOS EDLIN UTILITY" | ||
| 46 | ; "VERSION 4.00 (C) COPYRIGHT 1988 Microsoft" | ||
| 47 | ; "LICENSED MATERIAL - PROPERTY OF Microsoft" | ||
| 48 | ; | ||
| 49 | ; | ||
| 50 | ; MICROSOFT REVISION HISTORY: | ||
| 51 | ; ; | ||
| 52 | ; V1.02 ; | ||
| 53 | ; ; | ||
| 54 | ; V2.00 9/13/82 M.A.U ; | ||
| 55 | ; ; | ||
| 56 | ; 2/23/82 Rev. 13 N. P ; | ||
| 57 | ; Changed to 2.0 system calls. ; | ||
| 58 | ; Added an error message for READ-ONLY files ; | ||
| 59 | ; ; | ||
| 60 | ; 11/7/83 Rev. 14 N. P ; | ||
| 61 | ; Changed to .EXE format and added Printf ; | ||
| 62 | ; ; | ||
| 63 | ; V2.50 11/15/83 Rev. 1 M.A. U ; | ||
| 64 | ; Official dos 2.50 version. Some random bug ; | ||
| 65 | ; fixes and message changes. ; | ||
| 66 | ; ; | ||
| 67 | ; 11/30/83 Rev. 2 MZ ; | ||
| 68 | ; Close input file before rename. ; | ||
| 69 | ; Jmp to replace after line edit ; | ||
| 70 | ; ; | ||
| 71 | ; 02/01/84 Rev. 3 M.A. U ; | ||
| 72 | ; Now it is called 3.00 dos. Repaired problem ; | ||
| 73 | ; with using printf and having %'s as data. ; | ||
| 74 | ; ; | ||
| 75 | ; 02/15/84 MZ make out of space a fatal error with output; | ||
| 76 | ; ; | ||
| 77 | ; 03/28/84 MZ fixes bogus (totally) code in MOVE/COPY ; | ||
| 78 | ; ; | ||
| 79 | ; 04/02/84 MZ fixes DELETE and changes MOVE/COPY/EDIT ; | ||
| 80 | ; ; | ||
| 81 | ; V3.20 08/29/86 Rev. 1 S.M. G ; | ||
| 82 | ; ; | ||
| 83 | ; 08/29/86 M001 MSKK TAR 593, TAB MOVEMENT ; | ||
| 84 | ; ; | ||
| 85 | ; 08/29/86 M002 MSKK TAR 157, BLKMOVE 1,1,1m, 1,3,1m ; | ||
| 86 | ; ; | ||
| 87 | ; 08/29/86 M003 MSKK TAR 476, EDLCMD2,MAKECAPS,kana char; | ||
| 88 | ; ; | ||
| 89 | ; 08/29/86 M004 MSKK TAR 191, Append load size ; | ||
| 90 | ; ; | ||
| 91 | ; 08/29/86 M005 IBMJ TAR Transfer Load command ; | ||
| 92 | ; | ||
| 93 | ; | ||
| 94 | ;======================= END OF SPECIFICATIONS =========================== ; | ||
| 95 | |||
| 96 | include edlequ.asm | ||
| 97 | |||
| 98 | SUBTTL Contants and Data areas | ||
| 99 | PAGE | ||
| 100 | extrn parser_command:near ;an000;SYSPARSE | ||
| 101 | |||
| 102 | CODE SEGMENT PUBLIC | ||
| 103 | CODE ENDS | ||
| 104 | |||
| 105 | CONST SEGMENT PUBLIC WORD | ||
| 106 | CONST ENDS | ||
| 107 | |||
| 108 | cstack segment stack | ||
| 109 | cstack ends | ||
| 110 | |||
| 111 | DATA SEGMENT PUBLIC WORD | ||
| 112 | DATA ENDS | ||
| 113 | |||
| 114 | DG GROUP CODE,CONST,cstack,DATA | ||
| 115 | |||
| 116 | CONST SEGMENT PUBLIC WORD | ||
| 117 | |||
| 118 | public bak,$$$file,delflg,loadmod,txt1,txt2 | ||
| 119 | |||
| 120 | EXTRN BADDRV_ptr:word,NDNAME_ptr:word,bad_vers_err:byte,opt_err_ptr:word | ||
| 121 | EXTRN NOBAK_ptr:word,BADCOM_ptr:word,NEWFIL_ptr:word,DEST_ptr:word,MRGERR_ptr:word | ||
| 122 | EXTRN NODIR_ptr:word,FILENM_ptr:word,ro_err_ptr:word,bcreat_ptr:word | ||
| 123 | EXTRN TOO_MANY_ptr:word,lf_ptr:word,prompt_ptr:word | ||
| 124 | EXTRN MemFul_Ptr:word | ||
| 125 | |||
| 126 | BAK DB ".BAK",0 | ||
| 127 | |||
| 128 | $$$FILE DB ".$$$",0 | ||
| 129 | |||
| 130 | fourth db 0 ;fourth parameter flag | ||
| 131 | |||
| 132 | loadmod db 0 ;Load mode flag, 0 = ^Z marks the | ||
| 133 | ; end of a file, 1 = viceversa. | ||
| 134 | optchar db "-" | ||
| 135 | |||
| 136 | TXT1 DB 0,80H DUP (?) | ||
| 137 | TXT2 DB 0,80H DUP (?) | ||
| 138 | DELFLG DB 0 | ||
| 139 | fNew DB 0 ; old file | ||
| 140 | HAVEOF DB 0 | ||
| 141 | |||
| 142 | CONST ENDS | ||
| 143 | |||
| 144 | cstack segment stack | ||
| 145 | db stksiz dup (?) | ||
| 146 | cstack ends | ||
| 147 | |||
| 148 | DATA SEGMENT PUBLIC WORD | ||
| 149 | |||
| 150 | extrn arg_buf_ptr:word ;an000; | ||
| 151 | extrn line_num_buf_ptr:word ;an000; | ||
| 152 | |||
| 153 | public path_name,ext_ptr,start,line_num,line_flag | ||
| 154 | public arg_buf,wrt_handle,temp_path | ||
| 155 | public current,pointer,qflg,editbuf,amnt_req,fname_len,delflg,lastlin | ||
| 156 | public olddat,oldlen,newlen,srchflg,srchmod | ||
| 157 | public comline,lstfnd,numpos,lstnum,last,srchcnt | ||
| 158 | public rd_handle,haveof,ending,three4th,one4th | ||
| 159 | |||
| 160 | public lc_adj ;an000;page length adj. factor | ||
| 161 | public lc_flag ;an000;display cont. flag | ||
| 162 | public pg_count ;an000;lines left on screen | ||
| 163 | public Disp_Len ;an000;display length | ||
| 164 | public Disp_Width ;an000;display width | ||
| 165 | public continue ;an000;boolean T/F | ||
| 166 | public temp_path ;an000;pointer to filespec buf | ||
| 167 | |||
| 168 | Video_Buffer label word ;an000;buffer for video attr | ||
| 169 | db 0 ;an000;dms; | ||
| 170 | db 0 ;an000;dms; | ||
| 171 | dw 14 ;an000;dms; | ||
| 172 | dw 0 ;an000;dms; | ||
| 173 | db ? ;an000;dms; | ||
| 174 | db 0 ;an000;dms; | ||
| 175 | dw ? ;an000;dms;# of colors | ||
| 176 | dw ? ;an000;dms;# of pixels in width | ||
| 177 | dw ? ;an000;dms;# of pixels in len. | ||
| 178 | dw ? ;an000;dms;# of chars in width | ||
| 179 | dw ? ;an000;dms;# of chars in length | ||
| 180 | |||
| 181 | |||
| 182 | video_org db ? ;an000;original video mode on | ||
| 183 | ; entry to EDLIN. | ||
| 184 | lc_adj db ? ;an000;page length adj. factor | ||
| 185 | lc_flag db ? ;an000;display cont. flag | ||
| 186 | pg_count db ? ;an000;lines left on screen | ||
| 187 | Disp_Len db ? ;an000;display length | ||
| 188 | Disp_Width db ? ;an000;display width | ||
| 189 | continue db ? ;an000;boolean T/F | ||
| 190 | |||
| 191 | |||
| 192 | ;-----------------------------------------------------------------------; | ||
| 193 | ; This is a table that is sequentially filled via GetNum. Any additions to it | ||
| 194 | ; must be placed in the correct position. Currently Param4 is known to be a | ||
| 195 | ; count and thus is treated specially. | ||
| 196 | |||
| 197 | public param1,param2,Param3,param4,ParamCt | ||
| 198 | PARAM1 DW ? | ||
| 199 | PARAM2 DW ? | ||
| 200 | PARAM3 DW ? | ||
| 201 | PARAM4 DW ? | ||
| 202 | ParamCt DW ? ; count of passed parameters | ||
| 203 | if kanji ; Used in TESTKANJ: | ||
| 204 | LBTbl dd ? ; long pointer to lead byte table | ||
| 205 | endif ; in the dos (from syscall 63H) | ||
| 206 | |||
| 207 | ;-----------------------------------------------------------------------; | ||
| 208 | |||
| 209 | PUBLIC PTR_1, PTR_2, PTR_3, OLDLEN, NEWLEN, LSTFND, LSTNUM, NUMPOS, SRCHCNT | ||
| 210 | PUBLIC CURRENT, POINTER, ONE4TH, THREE4TH, LAST, ENDTXT, COPYSIZ | ||
| 211 | PUBLIC COMLINE, LASTLIN, COMBUF, EDITBUF, EOL, QFLG, ENDING, SRCHFLG | ||
| 212 | PUBLIC PATH_NAME, FNAME_LEN, RD_HANDLE, TEMP_PATH, WRT_HANDLE, EXT_PTR | ||
| 213 | PUBLIC MRG_PATH_NAME, MRG_HANDLE, amnt_req, olddat, srchmod, MOVFLG, org_ds | ||
| 214 | if kanji | ||
| 215 | public lbtbl | ||
| 216 | endif | ||
| 217 | |||
| 218 | ; | ||
| 219 | ; These comprise the known state of the internal buffer. All editing | ||
| 220 | ; functions must preserve these values. | ||
| 221 | ; | ||
| 222 | CURRENT DW ? ; the 1-based index of the current line | ||
| 223 | POINTER DW ? ; pointer to the current line | ||
| 224 | ENDTXT DW ? ; pointer to end of buffer. (at ^Z) | ||
| 225 | LAST DW ? ; offset of last byte of memory | ||
| 226 | ; | ||
| 227 | ; The label Start is the beginning of the in-core buffer. | ||
| 228 | ; | ||
| 229 | |||
| 230 | ; | ||
| 231 | ; Internal temporary pointers | ||
| 232 | ; | ||
| 233 | PTR_1 DW ? | ||
| 234 | PTR_2 DW ? | ||
| 235 | PTR_3 DW ? | ||
| 236 | |||
| 237 | QFLG DB ? ; TRUE => query for replacement | ||
| 238 | OLDLEN DW ? | ||
| 239 | NEWLEN DW ? | ||
| 240 | LSTFND DW ? | ||
| 241 | LSTNUM DW ? | ||
| 242 | NUMPOS DW ? | ||
| 243 | SRCHCNT DW ? | ||
| 244 | ONE4TH DW ? | ||
| 245 | THREE4TH DW ? | ||
| 246 | COPYSIZ DW ? ; total length to copy | ||
| 247 | COPYLEN DW ? ; single copy length | ||
| 248 | COMLINE DW ? | ||
| 249 | LASTLIN DW ? | ||
| 250 | COMBUF DB 82H DUP (?) | ||
| 251 | EDITBUF DB 258 DUP (?) | ||
| 252 | EOL DB ? | ||
| 253 | ENDING DB ? | ||
| 254 | SRCHFLG DB ? | ||
| 255 | PATH_NAME DB 128 DUP(0) | ||
| 256 | FNAME_LEN DW ? | ||
| 257 | RD_HANDLE DW ? | ||
| 258 | TEMP_PATH DB 128 DUP(?) | ||
| 259 | WRT_HANDLE DW ? | ||
| 260 | EXT_PTR DW ? | ||
| 261 | MRG_PATH_NAME DB 128 DUP(?) | ||
| 262 | MRG_HANDLE DW ? | ||
| 263 | amnt_req dw ? ; amount of bytes requested to read | ||
| 264 | olddat db ? ; Used in replace and search, replace | ||
| 265 | ; by old data flag (1=yes) | ||
| 266 | srchmod db ? ; Search mode: 1=from current+1 to | ||
| 267 | ; end of buffer, 0=from beg. of | ||
| 268 | ; buffer to the end (old way). | ||
| 269 | MOVFLG DB ? | ||
| 270 | org_ds dw ? ;Orginal ds points to header block | ||
| 271 | |||
| 272 | arg_buf db 258 dup (?) | ||
| 273 | |||
| 274 | EA_Flag db False ;an000; dms;set to false | ||
| 275 | |||
| 276 | EA_Buffer_Size dw ? ;an000; dms;EA buffer's size | ||
| 277 | |||
| 278 | EA_Parm_List label word ;an000; dms;EA parms | ||
| 279 | dd dg:Start ;an000; dms;ptr to EA's | ||
| 280 | dw 0001h ;an000; dms;additional parms | ||
| 281 | db 06h ;an000; dms; | ||
| 282 | dw 0002h ;an000; dms;iomode | ||
| 283 | |||
| 284 | |||
| 285 | line_num dw ? | ||
| 286 | |||
| 287 | line_flag db ?,0 | ||
| 288 | EVEN ;align on word boundaries | ||
| 289 | ; | ||
| 290 | ; Byte before start of data buffer must be < 40H !!!!!! | ||
| 291 | ; | ||
| 292 | dw 0 ;we scan backwards looking for | ||
| 293 | ;a character which can't be part | ||
| 294 | ;of a two-byte seqence. This | ||
| 295 | ;double byte sequence will cause the back | ||
| 296 | ;scan to stop here. | ||
| 297 | START LABEL WORD | ||
| 298 | |||
| 299 | DATA ENDS | ||
| 300 | |||
| 301 | |||
| 302 | CODE SEGMENT PUBLIC | ||
| 303 | |||
| 304 | ASSUME CS:DG,DS:NOTHING,ES:NOTHING,SS:CStack | ||
| 305 | |||
| 306 | |||
| 307 | |||
| 308 | extrn pre_load_message:near ;an000;message loader | ||
| 309 | extrn disp_fatal:near ;an000;fatal message | ||
| 310 | extrn printf:near ;an000;new PRINTF routine | ||
| 311 | |||
| 312 | extrn findlin:near,shownum:near,loadbuf:near,crlf:near,lf:near | ||
| 313 | extrn abortcom:near,delbak:near,unquote:near,kill_bl:near | ||
| 314 | extrn make_caps:near,dispone:near,display:near,query:near | ||
| 315 | extrn quit:near,make_cntrl:near,scanln:near,scaneof:near | ||
| 316 | extrn fndfirst:near,fndnext:near,replace:near,memerr:near | ||
| 317 | extrn xerror:near,bad_read:near,append:near | ||
| 318 | extrn nocom:near,pager:near,list:near,search_from_curr:near | ||
| 319 | extrn replac_from_curr:near,ewrite:near,wrt:near,delete:near | ||
| 320 | |||
| 321 | |||
| 322 | extrn filespec:byte ;an000;parser's filespec | ||
| 323 | extrn parse_switch_b:byte ;an000;result of switch scan | ||
| 324 | |||
| 325 | public std_printf,command,chkrange,comerr | ||
| 326 | ; exit from EDLIN | ||
| 327 | |||
| 328 | IF KANJI | ||
| 329 | extrn testkanj:near | ||
| 330 | ENDIF | ||
| 331 | |||
| 332 | EDLIN: | ||
| 333 | JMP SHORT SIMPED | ||
| 334 | |||
| 335 | std_printf proc near ;ac000;convert to proc | ||
| 336 | |||
| 337 | push dx | ||
| 338 | call printf | ||
| 339 | pop dx ;an000;balance the push | ||
| 340 | ret | ||
| 341 | |||
| 342 | std_printf endp ;ac000;end proc | ||
| 343 | |||
| 344 | NONAME: | ||
| 345 | MOV DX,OFFSET DG:NDNAME_ptr | ||
| 346 | JMP XERROR | ||
| 347 | |||
| 348 | SIMPED: | ||
| 349 | mov org_ds,DS | ||
| 350 | push ax ;ac000;save for drive compare | ||
| 351 | |||
| 352 | push cs ;an000;exchange cs/es | ||
| 353 | pop es ;an000; | ||
| 354 | |||
| 355 | push cs ;an000;exchange cs/ds | ||
| 356 | pop ds ;an000; | ||
| 357 | assume ds:dg,es:dg ;an000;establish addressibility | ||
| 358 | |||
| 359 | MOV dg:ENDING,0 | ||
| 360 | mov sp,stack | ||
| 361 | call EDLIN_DISP_GET ;an000;get current video | ||
| 362 | ; mode & set it to | ||
| 363 | ; text | ||
| 364 | |||
| 365 | ;========================================================================= | ||
| 366 | ; invoke PRE_LOAD_MESSAGE here. If the messages were not loaded we will | ||
| 367 | ; exit with an appropriate error message. | ||
| 368 | ; | ||
| 369 | ; Date : 6/14/87 | ||
| 370 | ;========================================================================= | ||
| 371 | |||
| 372 | call PRE_LOAD_MESSAGE ;an000;invoke SYSLOADMSG | ||
| 373 | ; $if c ;an000;if the load was unsuccessful | ||
| 374 | JNC $$IF1 | ||
| 375 | mov ah,exit ;an000;exit EDLIN. PRE_LOAD_MESSAGE | ||
| 376 | ; has said why we are exiting | ||
| 377 | mov al,00h ;an000 | ||
| 378 | int 21h ;an000;exit | ||
| 379 | ; $endif ;an000; | ||
| 380 | $$IF1: | ||
| 381 | |||
| 382 | |||
| 383 | |||
| 384 | VERS_OK: | ||
| 385 | ;----- Check for valid drive specifier --------------------------------; | ||
| 386 | |||
| 387 | pop ax | ||
| 388 | OR AL,AL | ||
| 389 | JZ get_switch_char | ||
| 390 | MOV DX,OFFSET DG:BADDRV_ptr | ||
| 391 | JMP xerror | ||
| 392 | get_switch_char: | ||
| 393 | MOV AX,(CHAR_OPER SHL 8) ;GET SWITCH CHARACTER | ||
| 394 | INT 21H | ||
| 395 | CMP DL,"/" | ||
| 396 | JNZ CMD_LINE ;IF NOT / , THEN NOT PC | ||
| 397 | MOV OPTCHAR,"/" ;IN PC, OPTION CHAR = / | ||
| 398 | |||
| 399 | IF KANJI | ||
| 400 | push ds ; SAVE! all regs destroyed on this | ||
| 401 | push es | ||
| 402 | push si ; call !! | ||
| 403 | mov ax,(ECS_call shl 8) or 00h ; get kanji lead tbl | ||
| 404 | int 21h | ||
| 405 | assume ds:nothing | ||
| 406 | assume es:nothing | ||
| 407 | mov word ptr [LBTbl],si | ||
| 408 | mov word ptr [LBTbl+2],ds | ||
| 409 | pop si | ||
| 410 | pop es | ||
| 411 | pop ds | ||
| 412 | assume ds:dg | ||
| 413 | assume es:dg | ||
| 414 | ENDIF | ||
| 415 | |||
| 416 | |||
| 417 | CMD_LINE: | ||
| 418 | push cs | ||
| 419 | pop es | ||
| 420 | ASSUME ES:DG | ||
| 421 | |||
| 422 | ;----- Process any options ------------------------------------------; | ||
| 423 | |||
| 424 | ;========================================================================= | ||
| 425 | ; The system parser, called through PARSER_COMMAND, parses external | ||
| 426 | ; command lines. In the case of EDLIN we are looking for two parameters | ||
| 427 | ; on the command line. | ||
| 428 | ; | ||
| 429 | ; Parameter 1 - Filespec (REQUIRED) | ||
| 430 | ; Parameter 2 - \B switch (OPTIONAL) | ||
| 431 | ; | ||
| 432 | ; PARSER_COMMAND - exit_normal : ffffh | ||
| 433 | ; exit_error : not = ffffh | ||
| 434 | ;========================================================================= | ||
| 435 | |||
| 436 | |||
| 437 | call PARSER_COMMAND ;an000;invoke sysparse | ||
| 438 | ; DMS:6/11/87 | ||
| 439 | cmp ax,nrm_parse_exit ;an000;was it a good parse | ||
| 440 | ; $if z ;an000;it was a good parse | ||
| 441 | JNZ $$IF3 | ||
| 442 | call EDLIN_COMMAND ;an000;interface results | ||
| 443 | ; into EDLIN | ||
| 444 | ; $else ;an000; | ||
| 445 | JMP SHORT $$EN3 | ||
| 446 | $$IF3: | ||
| 447 | cmp ax,too_many ;an000;too many operands | ||
| 448 | ; $if z ;an000;we have too many | ||
| 449 | JNZ $$IF5 | ||
| 450 | jmp badopt ;an000;say why and exit | ||
| 451 | ; $endif | ||
| 452 | $$IF5: | ||
| 453 | |||
| 454 | cmp ax,op_missing ;an000;required parm missing | ||
| 455 | ; $if z ;an000;missing parm | ||
| 456 | JNZ $$IF7 | ||
| 457 | jmp noname ;an000;say why and exit | ||
| 458 | ; $endif ;an000; | ||
| 459 | $$IF7: | ||
| 460 | |||
| 461 | cmp ax,sw_missing ;an000;is it an invalid switch | ||
| 462 | ; $if z ;an000;invalid switch | ||
| 463 | JNZ $$IF9 | ||
| 464 | jmp badopt ;an000;say why and exit | ||
| 465 | ; $endif ;an000; | ||
| 466 | $$IF9: | ||
| 467 | |||
| 468 | ; $endif ;an000; | ||
| 469 | $$EN3: | ||
| 470 | |||
| 471 | ;========================================================================= | ||
| 472 | ;======================= begin .BAK check ================================ | ||
| 473 | ; Check for .BAK extension on the filename | ||
| 474 | |||
| 475 | push ds ;an000;save reg. | ||
| 476 | push cs ;an000;set up addressibility | ||
| 477 | pop ds ;an000; | ||
| 478 | assume ds:dg ;an000; | ||
| 479 | |||
| 480 | push ax ;an000;save reg. | ||
| 481 | mov ax,offset dg:path_name ;an000;point to path_name | ||
| 482 | add ax,[fname_len] ;an000;calculate end of path_name | ||
| 483 | mov si,ax ;an000;point to end of path_name | ||
| 484 | pop ax ;an000;restore reg. | ||
| 485 | |||
| 486 | MOV CX,4 ;compare 4 bytes | ||
| 487 | SUB SI,4 ;Point 4th to last char | ||
| 488 | MOV DI,OFFSET DG:BAK ;Point to string ".BAK" | ||
| 489 | REPE CMPSB ;Compare the two strings | ||
| 490 | pop ds | ||
| 491 | ASSUME DS:NOTHING | ||
| 492 | JNZ NOTBAK | ||
| 493 | JMP HAVBAK | ||
| 494 | |||
| 495 | ;======================= end .BAK check ================================== | ||
| 496 | |||
| 497 | ;======================= begin NOTBAK ==================================== | ||
| 498 | ; we have a file without a .BAK extension, try to open it | ||
| 499 | |||
| 500 | NOTBAK: | ||
| 501 | push ds | ||
| 502 | push cs | ||
| 503 | pop ds | ||
| 504 | ASSUME DS:DG | ||
| 505 | |||
| 506 | ;========================================================================= | ||
| 507 | ; implement EXTENDED OPEN | ||
| 508 | ;========================================================================= | ||
| 509 | |||
| 510 | push es ;an000;save reg. | ||
| 511 | mov bx,RW ;an000;open for read/write | ||
| 512 | mov cx,ATTR ;an000;file attributes | ||
| 513 | mov dx,RW_FLAG ;an000;action to take on open | ||
| 514 | mov di,0ffffh ;an000;nul parm list | ||
| 515 | |||
| 516 | call EXT_OPEN1 ;an000;open for R/W;DMS:6/10/87 | ||
| 517 | pop es ;an000;restore reg. | ||
| 518 | |||
| 519 | ;========================================================================= | ||
| 520 | pop ds | ||
| 521 | ASSUME DS:NOTHING | ||
| 522 | JC CHK_OPEN_ERR ;an open error occurred | ||
| 523 | MOV RD_HANDLE,AX ;Save the handle | ||
| 524 | |||
| 525 | call Calc_Memory_Avail ;an000; dms;enough memory? | ||
| 526 | |||
| 527 | mov bx,RD_Handle ;an000; dms;set up for call | ||
| 528 | call Query_Extend_Attrib ;an000; dms;memory required? | ||
| 529 | |||
| 530 | cmp dx,cx ;an000; dms;enough memory for EA's? | ||
| 531 | ; $if b ;an000; dms;no | ||
| 532 | JNB $$IF12 | ||
| 533 | call EA_Fail_Exit ;an000; dms;say why and exit | ||
| 534 | ; $endif ;an000; dms; | ||
| 535 | $$IF12: | ||
| 536 | |||
| 537 | mov bx,RD_Handle ;an000; dms;set up for call | ||
| 538 | mov EA_Flag,True ;an000; dms; | ||
| 539 | call Get_Extended_Attrib ;an000; dms;get attribs | ||
| 540 | |||
| 541 | Jmp HavFil ;work with the opened file | ||
| 542 | |||
| 543 | ;======================= end NOTBAK ====================================== | ||
| 544 | |||
| 545 | Badopt: | ||
| 546 | MOV DX,OFFSET DG:OPT_ERR_ptr;Bad option specified | ||
| 547 | JMP XERROR | ||
| 548 | |||
| 549 | ;========================================================================= | ||
| 550 | ; | ||
| 551 | ; The open of the file failed. We need to figure out why and report the | ||
| 552 | ; correct message. The circumstances we can handle are: | ||
| 553 | ; | ||
| 554 | ; open returns pathnotfound => bad drive or file name | ||
| 555 | ; open returns toomanyopenfiles => too many open files | ||
| 556 | ; open returns access denied => | ||
| 557 | ; chmod indicates read-only => cannot edit read only file | ||
| 558 | ; else => file creation error | ||
| 559 | ; open returns filenotfound => | ||
| 560 | ; creat ok => close, delete, new file | ||
| 561 | ; creat fails => file creation error | ||
| 562 | ; else => file cre | ||
| 563 | ; | ||
| 564 | |||
| 565 | CHK_OPEN_ERR: | ||
| 566 | cmp ax,error_path_not_found | ||
| 567 | jz BadDriveError | ||
| 568 | cmp ax,error_too_many_open_files | ||
| 569 | jz TooManyError | ||
| 570 | cmp ax,error_access_denied | ||
| 571 | jnz CheckFNF | ||
| 572 | push ds | ||
| 573 | push cs | ||
| 574 | pop ds | ||
| 575 | assume ds:dg | ||
| 576 | mov ax,(chmod shl 8) | ||
| 577 | MOV DX,OFFSET DG:PATH_NAME | ||
| 578 | int 21h | ||
| 579 | jc FileCreationError | ||
| 580 | test cx,attr_read_only | ||
| 581 | jz FileCreationError | ||
| 582 | jmp ReadOnlyError | ||
| 583 | |||
| 584 | CheckFNF: | ||
| 585 | cmp ax,error_file_not_found | ||
| 586 | jnz FileCreationError | ||
| 587 | ; | ||
| 588 | ; Try to create the file to see if it is OK. | ||
| 589 | ; | ||
| 590 | push ds | ||
| 591 | push cs | ||
| 592 | pop ds | ||
| 593 | assume ds:dg | ||
| 594 | ;========================================================================= | ||
| 595 | ; implement EXTENDED OPEN | ||
| 596 | ;========================================================================= | ||
| 597 | |||
| 598 | mov bx,RW ;an000;open for read/write | ||
| 599 | mov cx,ATTR ;an000;file attributes | ||
| 600 | mov dx,CREAT_FLAG ;an000;action to take on open | ||
| 601 | mov di,0ffffh ;an000;null parm list | ||
| 602 | call EXT_OPEN1 ;an000;create file;DMS:6/10/87 | ||
| 603 | |||
| 604 | ;========================================================================= | ||
| 605 | |||
| 606 | pop ds | ||
| 607 | assume ds:nothing | ||
| 608 | jc CreateCheck | ||
| 609 | mov bx,ax | ||
| 610 | mov ah,close | ||
| 611 | int 21h | ||
| 612 | push ds | ||
| 613 | push cs | ||
| 614 | pop ds | ||
| 615 | assume ds:dg | ||
| 616 | mov ah,unlink | ||
| 617 | MOV DX,OFFSET DG:PATH_NAME | ||
| 618 | int 21h | ||
| 619 | pop ds | ||
| 620 | assume ds:nothing | ||
| 621 | jc FileCreationError ; This should NEVER be taken!!! | ||
| 622 | MOV HAVEOF,0FFH ; Flag from a system 1.xx call | ||
| 623 | MOV fNew,-1 | ||
| 624 | JMP HAVFIL | ||
| 625 | |||
| 626 | CreateCheck: | ||
| 627 | cmp ax,error_access_denied | ||
| 628 | jnz BadDriveError | ||
| 629 | DiskFull: | ||
| 630 | MOV DX,OFFSET DG:nodir_ptr | ||
| 631 | jmp xerror | ||
| 632 | |||
| 633 | FileCreationError: | ||
| 634 | mov dx,offset dg:BCreat_PTR | ||
| 635 | jmp xerror | ||
| 636 | |||
| 637 | ReadOnlyError: | ||
| 638 | MOV DX,OFFSET DG:RO_ERR_ptr | ||
| 639 | jmp xerror | ||
| 640 | |||
| 641 | BadDriveError: | ||
| 642 | MOV DX,OFFSET DG:BADDRV_PTR | ||
| 643 | jmp xerror | ||
| 644 | |||
| 645 | TooManyError: | ||
| 646 | MOV DX,OFFSET DG:TOO_MANY_ptr | ||
| 647 | jmp xerror | ||
| 648 | |||
| 649 | |||
| 650 | CREAT_ERR: | ||
| 651 | CMP DELFLG,0 | ||
| 652 | JNZ DiskFull | ||
| 653 | push cs | ||
| 654 | pop ds | ||
| 655 | CALL DELBAK | ||
| 656 | JMP MAKFIL | ||
| 657 | |||
| 658 | HAVBAK: | ||
| 659 | MOV DX,OFFSET DG:NOBAK_ptr | ||
| 660 | JMP XERROR | ||
| 661 | |||
| 662 | HAVFIL: | ||
| 663 | push cs | ||
| 664 | pop ds | ||
| 665 | ASSUME DS:DG | ||
| 666 | CMP fNew,0 | ||
| 667 | JZ MakeBak | ||
| 668 | MOV DX,OFFSET DG:NEWFIL_ptr ; Print new file message | ||
| 669 | call std_printf | ||
| 670 | MakeBak: | ||
| 671 | MOV SI,OFFSET DG:PATH_NAME | ||
| 672 | MOV CX,[FNAME_LEN] | ||
| 673 | PUSH CX | ||
| 674 | MOV DI,OFFSET DG:TEMP_PATH | ||
| 675 | REP MOVSB | ||
| 676 | DEC DI | ||
| 677 | MOV DX,DI | ||
| 678 | POP CX | ||
| 679 | MOV AL,"." | ||
| 680 | STD | ||
| 681 | REPNE SCASB | ||
| 682 | JZ FOUND_EXT | ||
| 683 | MOV DI,DX ;Point to last char in filename | ||
| 684 | FOUND_EXT: | ||
| 685 | CLD | ||
| 686 | INC DI | ||
| 687 | MOV [EXT_PTR],DI | ||
| 688 | MOV SI,OFFSET DG:$$$FILE | ||
| 689 | MOV CX,5 | ||
| 690 | REP MOVSB | ||
| 691 | |||
| 692 | ;Create .$$$ file to make sure directory has room | ||
| 693 | MAKFIL: | ||
| 694 | |||
| 695 | ;========================================================================= | ||
| 696 | ; implement EXTENDED OPEN | ||
| 697 | ;========================================================================= | ||
| 698 | |||
| 699 | mov bx,RW ;an000;open for read/write | ||
| 700 | mov cx,ATTR ;an000;file attributes | ||
| 701 | mov dx,Creat_Open_Flag ;an000;action to take on open | ||
| 702 | cmp EA_Flag,True ;an000;EA_Buffer used? | ||
| 703 | ; $if e ;an000;yes | ||
| 704 | JNE $$IF14 | ||
| 705 | mov di,offset dg:EA_Parm_List ;an000; point to buffer | ||
| 706 | ; $else ;an000; | ||
| 707 | JMP SHORT $$EN14 | ||
| 708 | $$IF14: | ||
| 709 | mov di,0ffffh ;an000;nul parm list | ||
| 710 | ; $endif ;an000; | ||
| 711 | $$EN14: | ||
| 712 | call EXT_OPEN2 ;an000;create file;DMS:6/10/87 | ||
| 713 | |||
| 714 | ;========================================================================= | ||
| 715 | |||
| 716 | JC CREAT_ERR | ||
| 717 | MOV [WRT_HANDLE],AX | ||
| 718 | ; | ||
| 719 | ; We determine the size of the available memory. Use the word in the PDB at | ||
| 720 | ; [2] to determine the number of paragraphs. Then truncate this to 64K at | ||
| 721 | ; most. | ||
| 722 | ; | ||
| 723 | push ds ;save ds for size calc | ||
| 724 | mov ds,[org_ds] | ||
| 725 | MOV CX,DS:[2] | ||
| 726 | MOV DI,CS | ||
| 727 | SUB CX,DI | ||
| 728 | CMP CX,1000h | ||
| 729 | JBE GotSize | ||
| 730 | MOV CX,0FFFh | ||
| 731 | GotSize: | ||
| 732 | SHL CX,1 | ||
| 733 | SHL CX,1 | ||
| 734 | SHL CX,1 | ||
| 735 | SHL CX,1 | ||
| 736 | pop ds ;restore ds after size calc | ||
| 737 | DEC CX | ||
| 738 | MOV [LAST],CX | ||
| 739 | MOV DI,OFFSET DG:START | ||
| 740 | TEST fNew,-1 | ||
| 741 | JNZ SAVEND | ||
| 742 | SUB CX,OFFSET DG:START ;Available memory | ||
| 743 | SHR CX,1 ;1/2 of available memory | ||
| 744 | MOV AX,CX | ||
| 745 | SHR CX,1 ;1/4 of available memory | ||
| 746 | MOV [ONE4TH],CX ;Save amount of 1/4 full | ||
| 747 | ADD CX,AX ;3/4 of available memory | ||
| 748 | MOV DX,CX | ||
| 749 | ADD DX,OFFSET DG:START | ||
| 750 | MOV [THREE4TH],DX ;Save pointer to 3/4 full | ||
| 751 | MOV DX,OFFSET DG:START | ||
| 752 | SAVEND: | ||
| 753 | CLD | ||
| 754 | MOV BYTE PTR [DI],1AH | ||
| 755 | MOV [ENDTXT],DI | ||
| 756 | MOV BYTE PTR [COMBUF],128 | ||
| 757 | MOV BYTE PTR [EDITBUF],255 | ||
| 758 | MOV BYTE PTR [EOL],10 | ||
| 759 | MOV [POINTER],OFFSET DG:START | ||
| 760 | MOV [CURRENT],1 | ||
| 761 | MOV ParamCt,1 | ||
| 762 | MOV [PARAM1],0 ;M004 Leave room in memory, was -1 | ||
| 763 | TEST fNew,-1 | ||
| 764 | JNZ COMMAND | ||
| 765 | ; | ||
| 766 | ; The above setting of PARAM1 to -1 causes this call to APPEND to try to read | ||
| 767 | ; in as many lines that will fit, BUT.... What we are doing is simulating | ||
| 768 | ; the user issuing an APPEND command, and if the user asks for more lines | ||
| 769 | ; than we get then an "Insufficient memory" error occurs. In this case we | ||
| 770 | ; DO NOT want this error, we just want as many lines as possible read in. | ||
| 771 | ; The twiddle of ENDING suppresses the memory error | ||
| 772 | ; | ||
| 773 | MOV BYTE PTR [ENDING],1 ;Suppress memory errors | ||
| 774 | CALL APPEND | ||
| 775 | MOV ENDING,0 ; restore correct initial value | ||
| 776 | |||
| 777 | Break <Main command loop> | ||
| 778 | |||
| 779 | ; | ||
| 780 | ; Main read/parse/execute loop. We reset the stack all the time as there | ||
| 781 | ; are routines that JMP back here. Don't blame me; Tim Paterson write this. | ||
| 782 | ; | ||
| 783 | COMMAND: | ||
| 784 | push cs ;an000;set up addressibility | ||
| 785 | pop ds ;an000; | ||
| 786 | push cs ;an000; | ||
| 787 | pop es ;an000; | ||
| 788 | assume ds:dg,es:dg ;an000; | ||
| 789 | |||
| 790 | MOV SP, STACK | ||
| 791 | MOV AX,(SET_INTERRUPT_VECTOR SHL 8) OR 23H | ||
| 792 | MOV DX,OFFSET DG:ABORTCOM | ||
| 793 | INT 21H | ||
| 794 | mov dx,offset dg:prompt_ptr | ||
| 795 | call std_printf | ||
| 796 | MOV DX,OFFSET DG:COMBUF | ||
| 797 | MOV AH,STD_CON_STRING_INPUT | ||
| 798 | INT 21H | ||
| 799 | MOV [COMLINE],OFFSET DG:COMBUF + 2 | ||
| 800 | mov dx,offset dg:lf_ptr | ||
| 801 | call std_printf | ||
| 802 | PARSE: | ||
| 803 | MOV [PARAM2],0 | ||
| 804 | MOV [PARAM3],0 | ||
| 805 | MOV [PARAM4],0 | ||
| 806 | mov [fourth],0 ;reset the fourth parameter flag | ||
| 807 | MOV QFLG,0 | ||
| 808 | MOV SI,[COMLINE] | ||
| 809 | MOV BP,OFFSET DG:PARAM1 | ||
| 810 | XOR DI,DI | ||
| 811 | CHKLP: | ||
| 812 | CALL GETNUM | ||
| 813 | ; | ||
| 814 | ; AL has first char after arg | ||
| 815 | ; | ||
| 816 | MOV ds:[BP+DI],DX | ||
| 817 | ADD DI,2 | ||
| 818 | |||
| 819 | MOV ParamCt,DI ; set up count of parameters | ||
| 820 | SHR ParamCt,1 ; convert to index (1-based) | ||
| 821 | |||
| 822 | CALL SKIP1 ; skip to next parameter | ||
| 823 | CMP AL,"," ; is there a comma? | ||
| 824 | JZ CHKLP ; if so, then get another arg | ||
| 825 | DEC SI ; point at char next | ||
| 826 | CALL Kill_BL ; skip all blanks | ||
| 827 | CMP AL,"?" ; is there a ? | ||
| 828 | JNZ DISPATCH ; no, got command letter | ||
| 829 | MOV QFLG,-1 ; signal query | ||
| 830 | CALL Kill_BL | ||
| 831 | DISPATCH: | ||
| 832 | CMP AL,5FH | ||
| 833 | JBE UPCASE | ||
| 834 | cmp al,"z" | ||
| 835 | ja upcase | ||
| 836 | AND AL,5FH | ||
| 837 | UPCASE: | ||
| 838 | MOV DI,OFFSET DG:COMTAB | ||
| 839 | MOV CX,NUMCOM | ||
| 840 | REPNE SCASB | ||
| 841 | JNZ COMERR | ||
| 842 | SUB DI,1+OFFSET DG:COMTAB ; convert to index | ||
| 843 | MOV BX,DI | ||
| 844 | MOV AX,[PARAM2] | ||
| 845 | OR AX,AX | ||
| 846 | JZ PARMOK | ||
| 847 | CMP AX,[PARAM1] | ||
| 848 | JB COMERR ; Param. 2 must be >= param 1 | ||
| 849 | PARMOK: | ||
| 850 | MOV [COMLINE],SI | ||
| 851 | SHL BX,1 | ||
| 852 | CALL [BX+TABLE] | ||
| 853 | COMOVER: | ||
| 854 | MOV SI,[COMLINE] | ||
| 855 | CALL Kill_BL | ||
| 856 | CMP AL,0DH | ||
| 857 | JZ COMMANDJ | ||
| 858 | CMP AL,1AH | ||
| 859 | JZ DELIM | ||
| 860 | CMP AL,";" | ||
| 861 | JNZ NODELIM | ||
| 862 | DELIM: | ||
| 863 | INC SI | ||
| 864 | NODELIM: | ||
| 865 | DEC SI | ||
| 866 | MOV [COMLINE],SI | ||
| 867 | JMP PARSE | ||
| 868 | |||
| 869 | COMMANDJ: | ||
| 870 | JMP COMMAND | ||
| 871 | |||
| 872 | SKIP1: | ||
| 873 | DEC SI | ||
| 874 | CALL Kill_BL | ||
| 875 | ret1: return | ||
| 876 | |||
| 877 | Break <Range Checking and argument parsing> | ||
| 878 | |||
| 879 | ; | ||
| 880 | ; People call here. we need to reset the stack. | ||
| 881 | ; Inputs: BX has param1 | ||
| 882 | ; Outputs: Returns if BX <= Param2 | ||
| 883 | ; | ||
| 884 | |||
| 885 | CHKRANGE: | ||
| 886 | CMP [PARAM2],0 | ||
| 887 | retz | ||
| 888 | CMP BX,[PARAM2] | ||
| 889 | JBE RET1 | ||
| 890 | POP DX ; clean up return address | ||
| 891 | COMERR: | ||
| 892 | MOV DX,OFFSET DG:BADCOM_ptr | ||
| 893 | COMERR1: | ||
| 894 | call std_printf | ||
| 895 | JMP COMMAND | ||
| 896 | |||
| 897 | ; | ||
| 898 | ; GetNum parses off 1 argument from the command line. Argument forms are: | ||
| 899 | ; nnn a number < 65536 | ||
| 900 | ; +nnn current line + number | ||
| 901 | ; -nnn current line - number | ||
| 902 | ; . current line | ||
| 903 | ; # lastline + 1 | ||
| 904 | ; | ||
| 905 | ; | ||
| 906 | |||
| 907 | GETNUM: | ||
| 908 | CALL Kill_BL | ||
| 909 | cmp di,6 ;Is this the fourth parameter? | ||
| 910 | jne sk1 | ||
| 911 | mov [fourth],1 ;yes, set the flag | ||
| 912 | sk1: | ||
| 913 | CMP AL,"." | ||
| 914 | JZ CURLIN | ||
| 915 | CMP AL,"#" | ||
| 916 | JZ MAXLIN | ||
| 917 | CMP AL,"+" | ||
| 918 | JZ FORLIN | ||
| 919 | CMP AL,"-" | ||
| 920 | JZ BACKLIN | ||
| 921 | MOV DX,0 | ||
| 922 | MOV CL,0 ;Flag no parameter seen yet | ||
| 923 | NUMLP: | ||
| 924 | CMP AL,"0" | ||
| 925 | JB NUMCHK | ||
| 926 | CMP AL,"9" | ||
| 927 | JA NUMCHK | ||
| 928 | CMP DX,6553 ;Max line/10 | ||
| 929 | JAE COMERR ;Ten times this is too big | ||
| 930 | MOV CL,1 ;Parameter digit has been found | ||
| 931 | SUB AL,"0" | ||
| 932 | MOV BX,DX | ||
| 933 | SHL DX,1 | ||
| 934 | SHL DX,1 | ||
| 935 | ADD DX,BX | ||
| 936 | SHL DX,1 | ||
| 937 | CBW | ||
| 938 | ADD DX,AX | ||
| 939 | LODSB | ||
| 940 | JMP SHORT NUMLP | ||
| 941 | NUMCHK: | ||
| 942 | CMP CL,0 | ||
| 943 | retz | ||
| 944 | OR DX,DX | ||
| 945 | JZ COMERR ;Don't allow zero as a parameter | ||
| 946 | return | ||
| 947 | |||
| 948 | CURLIN: | ||
| 949 | cmp [fourth],1 ;the fourth parameter? | ||
| 950 | je comerra ;yes, an error | ||
| 951 | MOV DX,[CURRENT] | ||
| 952 | LODSB | ||
| 953 | return | ||
| 954 | MAXLIN: | ||
| 955 | cmp [fourth],1 ;the fourth parameter? | ||
| 956 | je comerra ;yes, an error | ||
| 957 | MOV DX,1 | ||
| 958 | MOV AL,0Ah | ||
| 959 | PUSH DI | ||
| 960 | MOV DI,OFFSET DG:START | ||
| 961 | MOV CX,EndTxt | ||
| 962 | SUB CX,DI | ||
| 963 | MLoop: | ||
| 964 | JCXZ MDone | ||
| 965 | REPNZ SCASB | ||
| 966 | JNZ MDone | ||
| 967 | INC DX | ||
| 968 | JMP MLoop | ||
| 969 | MDone: | ||
| 970 | POP DI | ||
| 971 | LODSB | ||
| 972 | return | ||
| 973 | FORLIN: | ||
| 974 | cmp [fourth],1 ;the fourth parameter? | ||
| 975 | je comerra ;yes, an error | ||
| 976 | CALL GETNUM | ||
| 977 | ADD DX,[CURRENT] | ||
| 978 | return | ||
| 979 | BACKLIN: | ||
| 980 | cmp [fourth],1 ;the fourth parameter? | ||
| 981 | je comerra ;yes, an error | ||
| 982 | CALL GETNUM | ||
| 983 | MOV BX,[CURRENT] | ||
| 984 | SUB BX,DX | ||
| 985 | JA OkLin ; if negative or zero | ||
| 986 | MOV BX,1 ; use first line | ||
| 987 | OkLin: | ||
| 988 | MOV DX,BX | ||
| 989 | return | ||
| 990 | |||
| 991 | comerra: | ||
| 992 | jmp comerr | ||
| 993 | |||
| 994 | Break <Dispatch Table> | ||
| 995 | |||
| 996 | ;-----------------------------------------------------------------------; | ||
| 997 | ; Careful changing the order of the next two tables. They are linked and | ||
| 998 | ; changes should be be to both. | ||
| 999 | |||
| 1000 | COMTAB DB 13,";ACDEILMPQRSTW" | ||
| 1001 | NUMCOM EQU $-COMTAB | ||
| 1002 | |||
| 1003 | TABLE DW NOCOM ; Blank line | ||
| 1004 | DW NOCOM ; ; | ||
| 1005 | DW APPEND ; A(ppend) | ||
| 1006 | DW COPY ; C(opy) | ||
| 1007 | DW DELETE ; D(elete) | ||
| 1008 | DW ENDED ; E(xit) | ||
| 1009 | DW INSERT ; I(nsert) | ||
| 1010 | DW LIST ; L(ist) | ||
| 1011 | DW MOVE ; M(ove) | ||
| 1012 | DW PAGER ; P(age) | ||
| 1013 | DW QUIT ; Q(uit) | ||
| 1014 | dw replac_from_curr ; R(eplace) | ||
| 1015 | dw search_from_curr ; S(earch) | ||
| 1016 | DW MERGE ; T(merge) | ||
| 1017 | DW EWRITE ; W(rite) | ||
| 1018 | |||
| 1019 | ERRORJ: | ||
| 1020 | JMP COMERR | ||
| 1021 | ERROR1J: | ||
| 1022 | JMP COMERR1 | ||
| 1023 | |||
| 1024 | Break <Move and Copy commands> | ||
| 1025 | |||
| 1026 | PUBLIC MOVE | ||
| 1027 | MOVE: | ||
| 1028 | CMP ParamCt,3 | ||
| 1029 | JNZ ERRORJ | ||
| 1030 | MOV BYTE PTR [MOVFLG],1 | ||
| 1031 | JMP SHORT BLKMOVE | ||
| 1032 | |||
| 1033 | PUBLIC COPY | ||
| 1034 | COPY: | ||
| 1035 | CMP ParamCt,3 | ||
| 1036 | JB ERRORJ | ||
| 1037 | MOV BYTE PTR [MOVFLG],0 | ||
| 1038 | ; | ||
| 1039 | ; We are to move/copy a number of lines from one range to another. | ||
| 1040 | ; | ||
| 1041 | ; Memory looks like this: | ||
| 1042 | ; | ||
| 1043 | ; START: line 1 | ||
| 1044 | ; ... | ||
| 1045 | ; pointer-> line n Current has n in it | ||
| 1046 | ; ... | ||
| 1047 | ; line m | ||
| 1048 | ; endtxt-> ^Z | ||
| 1049 | ; | ||
| 1050 | ; The algoritm is: | ||
| 1051 | ; | ||
| 1052 | ; Bounds check on args. | ||
| 1053 | ; set ptr1 and ptr2 to range before move | ||
| 1054 | ; set copysiz to number to move | ||
| 1055 | ; open up copysize * count for destination | ||
| 1056 | ; if destination is before ptr1 then | ||
| 1057 | ; add copysize * count to both ptrs | ||
| 1058 | ; while count > 0 do | ||
| 1059 | ; move from ptr1 to destination for copysize bytes | ||
| 1060 | ; count -- | ||
| 1061 | ; if moving then | ||
| 1062 | ; move from ptr2 through end to ptr1 | ||
| 1063 | ; set endtxt to last byte moved. | ||
| 1064 | ; set current, pointer to original destination | ||
| 1065 | ; | ||
| 1066 | |||
| 1067 | BLKMOVE: | ||
| 1068 | ; | ||
| 1069 | ; Make sure that all correct arguments are specified. | ||
| 1070 | ; | ||
| 1071 | MOV BX,[PARAM3] ; get destination of move/copy | ||
| 1072 | OR BX,BX ; must be specified (non-0) | ||
| 1073 | MOV DX,OFFSET DG:DEST_ptr | ||
| 1074 | JZ ERROR1J ; is 0 => error | ||
| 1075 | ; | ||
| 1076 | ; get arg 1 (defaulting if necessary) and range check it. | ||
| 1077 | ; | ||
| 1078 | MOV BX,[PARAM1] ; get first argument | ||
| 1079 | OR BX,BX ; do we default it? | ||
| 1080 | JNZ NXTARG ; no, assume it is OK. | ||
| 1081 | MOV BX,[CURRENT] ; Defaults to the current line | ||
| 1082 | CALL CHKRANGE ; Make sure it is good. | ||
| 1083 | MOV [PARAM1],BX ; set it | ||
| 1084 | NXTARG: | ||
| 1085 | CALL FINDLIN ; find first argument line | ||
| 1086 | JNZ ErrorJ ; line not found | ||
| 1087 | MOV [PTR_1],DI | ||
| 1088 | ; | ||
| 1089 | ; get arg 2 (defaulting if necessary) and range check it. | ||
| 1090 | ; | ||
| 1091 | MOV BX,[PARAM2] ; Get the second parameter | ||
| 1092 | OR BX,BX ; do we default it too? | ||
| 1093 | JNZ HAVARGS ; Nope. | ||
| 1094 | MOV BX,[CURRENT] ; Defaults to the current line | ||
| 1095 | MOV [PARAM2],BX ; Stash it away | ||
| 1096 | HAVARGS: | ||
| 1097 | CALL FindLin | ||
| 1098 | JNZ ErrorJ ; line not found | ||
| 1099 | MOV BX,Param2 | ||
| 1100 | INC BX ;Get pointer to line Param2+1 | ||
| 1101 | CALL FINDLIN | ||
| 1102 | MOV [PTR_2],DI ;Save it | ||
| 1103 | ; | ||
| 1104 | ; We now have true line number arguments and pointers to the relevant places. | ||
| 1105 | ; ptr_1 points to beginning of region and ptr_2 points to first byte beyond | ||
| 1106 | ; that region. | ||
| 1107 | ; | ||
| 1108 | ; Check args for correct ordering of first two arguments | ||
| 1109 | ; | ||
| 1110 | mov dx,[param1] | ||
| 1111 | cmp dx,[param2] | ||
| 1112 | jbe havargs1 ; first must be <= second | ||
| 1113 | jmp comerr | ||
| 1114 | havargs1: | ||
| 1115 | ; | ||
| 1116 | ; make sure that the third argument is not contained in the first range | ||
| 1117 | ; | ||
| 1118 | MOV DX,[PARAM3] | ||
| 1119 | CMP DX,[PARAM1] ; third must be <= first or | ||
| 1120 | JBE NOERROR | ||
| 1121 | CMP DX,[PARAM2] | ||
| 1122 | JA NoError ; third must be > last | ||
| 1123 | JMP ComErr | ||
| 1124 | NOERROR: | ||
| 1125 | ; | ||
| 1126 | ; Determine number to move | ||
| 1127 | ; | ||
| 1128 | MOV CX,Ptr_2 | ||
| 1129 | SUB CX,Ptr_1 ; Calculate number of bytes to copy | ||
| 1130 | MOV CopySiz,CX | ||
| 1131 | MOV CopyLen,CX ; Save for individual move. | ||
| 1132 | MOV AX,[PARAM4] ; Was count defaulted? | ||
| 1133 | OR AX,AX | ||
| 1134 | JZ SizeOk ; yes, CX has correct value | ||
| 1135 | MUL [COPYSIZ] ; convert to true size | ||
| 1136 | MOV CX,AX ; move to count register | ||
| 1137 | OR DX,DX ; overflow? | ||
| 1138 | JZ SizeOK ; no | ||
| 1139 | JMP MEMERR ; yes, bomb. | ||
| 1140 | SizeOK: | ||
| 1141 | MOV [COPYSIZ],CX | ||
| 1142 | ; | ||
| 1143 | ; Check to see that we have room to grow by copysiz | ||
| 1144 | ; | ||
| 1145 | MOV AX,[ENDTXT] ; get pointer to last byte | ||
| 1146 | MOV DI,[LAST] ; get offset of last location in memory | ||
| 1147 | SUB DI,AX ; remainder of space | ||
| 1148 | CMP DI,CX ; is there at least copysiz room? | ||
| 1149 | JAE HAV_ROOM ; yes | ||
| 1150 | JMP MEMERR | ||
| 1151 | HAV_ROOM: | ||
| 1152 | ; | ||
| 1153 | ; Find destination of move/copy | ||
| 1154 | ; | ||
| 1155 | MOV BX,[PARAM3] | ||
| 1156 | CALL FINDLIN | ||
| 1157 | MOV [PTR_3],DI | ||
| 1158 | ; | ||
| 1159 | ; open up copysiz bytes of space at destination | ||
| 1160 | ; | ||
| 1161 | ; move (p3, p3+copysiz, endtxt-p3); | ||
| 1162 | ; | ||
| 1163 | MOV SI,EndTxt ; get source pointer to end | ||
| 1164 | MOV CX,SI | ||
| 1165 | SUB CX,DI ; number of bytes from here to end | ||
| 1166 | INC CX ; remember ^Z at end | ||
| 1167 | MOV DI,SI ; destination starts at end | ||
| 1168 | ADD DI,[COPYSIZ] ; plus size we are opening | ||
| 1169 | MOV [ENDTXT],DI ; new end point | ||
| 1170 | STD ; go backwards | ||
| 1171 | REP MOVSB ; and store everything | ||
| 1172 | CLD ; go forward | ||
| 1173 | ; | ||
| 1174 | ; relocate ptr_1 and ptr_2 if we moved them | ||
| 1175 | ; | ||
| 1176 | MOV BX,Ptr_3 | ||
| 1177 | CMP BX,Ptr_1 ; was dest before source? | ||
| 1178 | JA NoReloc ; no, above. no relocation | ||
| 1179 | MOV BX,CopySiz | ||
| 1180 | ADD Ptr_1,BX | ||
| 1181 | ADD Ptr_2,BX ; relocate pointers | ||
| 1182 | NoReloc: | ||
| 1183 | ; | ||
| 1184 | ; Now we copy for count times copylen bytes from ptr_1 to ptr_3 | ||
| 1185 | ; | ||
| 1186 | ; move (ptr_1, ptr_3, copylen); | ||
| 1187 | ; | ||
| 1188 | MOV BX,Param4 ; count (0 and 1 are both 1) | ||
| 1189 | MOV DI,Ptr_3 ; destination | ||
| 1190 | CopyText: | ||
| 1191 | MOV CX,CopyLen ; number to move | ||
| 1192 | MOV SI,Ptr_1 ; start point | ||
| 1193 | REP MOVSB ; move the bytes | ||
| 1194 | SUB BX,1 ; exhaust count? | ||
| 1195 | JG CopyText ; no, go for more | ||
| 1196 | ; | ||
| 1197 | ; If we are moving | ||
| 1198 | ; | ||
| 1199 | CMP BYTE PTR MovFlg,0 | ||
| 1200 | JZ CopyDone | ||
| 1201 | ; | ||
| 1202 | ; Delete the source text between ptr_1 and ptr_2 | ||
| 1203 | ; | ||
| 1204 | ; move (ptr_2, ptr_1, endtxt-ptr_2); | ||
| 1205 | ; | ||
| 1206 | MOV DI,Ptr_1 ; destination | ||
| 1207 | MOV SI,Ptr_2 ; source | ||
| 1208 | MOV CX,EndTxt ; pointer to end | ||
| 1209 | SUB CX,SI ; number of bytes to move | ||
| 1210 | CLD ; forwards | ||
| 1211 | REP MOVSB | ||
| 1212 | MOV BYTE PTR ES:[DI],1Ah ; remember ^Z terminate | ||
| 1213 | MOV EndTxt,DI ; new end of file | ||
| 1214 | ; | ||
| 1215 | ; May need to relocate current line (parameter 3). | ||
| 1216 | ; | ||
| 1217 | MOV BX,Param3 ; get new current line | ||
| 1218 | CMP BX,Param1 ; do we need to relocate | ||
| 1219 | JBE CopyDone ; no, current line is before removed M002 | ||
| 1220 | ADD BX,Param1 ; add in first | ||
| 1221 | SUB BX,Param2 ; current += first-last - 1; | ||
| 1222 | DEC BX | ||
| 1223 | MOV Param3,BX | ||
| 1224 | CopyDone: | ||
| 1225 | ; | ||
| 1226 | ; we are done. Make current line the destination | ||
| 1227 | ; | ||
| 1228 | MOV BX,Param3 ; set parameter 3 to be current | ||
| 1229 | CALL FINDLIN | ||
| 1230 | MOV [POINTER],DI | ||
| 1231 | MOV [CURRENT],BX | ||
| 1232 | return | ||
| 1233 | |||
| 1234 | Break <MoveFile - open up a hole in the internal file> | ||
| 1235 | |||
| 1236 | ; | ||
| 1237 | ; MoveFile moves the text in the buffer to create a hole | ||
| 1238 | ; | ||
| 1239 | ; Inputs: DX is spot in buffer for destination | ||
| 1240 | ; DI is spot in buffer for source | ||
| 1241 | MOVEFILE: | ||
| 1242 | MOV CX,[ENDTXT] ;Get End-of-text marker | ||
| 1243 | MOV SI,CX | ||
| 1244 | SUB CX,DI ;Calculate number of bytes to copy | ||
| 1245 | INC CX ; remember ^Z | ||
| 1246 | MOV DI,DX | ||
| 1247 | STD | ||
| 1248 | REP MOVSB ;Copy CX bytes | ||
| 1249 | XCHG SI,DI | ||
| 1250 | CLD | ||
| 1251 | INC DI | ||
| 1252 | MOV BP,SI | ||
| 1253 | SETPTS: | ||
| 1254 | MOV [POINTER],DI ;Current line is first free loc | ||
| 1255 | MOV [CURRENT],BX ; in the file | ||
| 1256 | MOV [ENDTXT],BP ;End-of-text is last free loc before | ||
| 1257 | return | ||
| 1258 | |||
| 1259 | NAMERR: | ||
| 1260 | cmp ax,error_file_not_found | ||
| 1261 | jne otherMergeErr | ||
| 1262 | MOV DX,OFFSET DG:FILENM_ptr | ||
| 1263 | JMP COMERR1 | ||
| 1264 | |||
| 1265 | otherMergeErr: | ||
| 1266 | MOV DX,OFFSET DG:BADDRV_ptr | ||
| 1267 | JMP COMERR1 | ||
| 1268 | |||
| 1269 | PUBLIC MERGE | ||
| 1270 | MERGE: | ||
| 1271 | CMP ParamCt,1 | ||
| 1272 | JZ MergeOK | ||
| 1273 | JMP Comerr | ||
| 1274 | MergeOK: | ||
| 1275 | CALL KILL_BL | ||
| 1276 | DEC SI | ||
| 1277 | MOV DI,OFFSET DG:MRG_PATH_NAME | ||
| 1278 | XOR CX,CX | ||
| 1279 | CLD | ||
| 1280 | MRG1: | ||
| 1281 | LODSB | ||
| 1282 | CMP AL," " | ||
| 1283 | JE MRG2 | ||
| 1284 | CMP AL,9 | ||
| 1285 | JE MRG2 | ||
| 1286 | CMP AL,CR | ||
| 1287 | JE MRG2 | ||
| 1288 | CMP AL,";" | ||
| 1289 | JE MRG2 | ||
| 1290 | STOSB | ||
| 1291 | JMP SHORT MRG1 | ||
| 1292 | MRG2: | ||
| 1293 | MOV BYTE PTR[DI],0 | ||
| 1294 | DEC SI | ||
| 1295 | MOV [COMLINE],SI | ||
| 1296 | |||
| 1297 | ;========================================================================= | ||
| 1298 | ; implement EXTENDED OPEN | ||
| 1299 | ;========================================================================= | ||
| 1300 | |||
| 1301 | push es ;an000;save reg. | ||
| 1302 | mov bx,ext_read ;an000;open for read | ||
| 1303 | mov cx,ATTR ;an000;file attributes | ||
| 1304 | mov dx,OPEN_FLAG ;an000;action to take on open | ||
| 1305 | mov di,0ffffh ;an000;null parm list | ||
| 1306 | call EXT_OPEN3 ;an000;create file;DMS:6/10/87 | ||
| 1307 | pop es ;an000;restore reg. | ||
| 1308 | |||
| 1309 | ;========================================================================= | ||
| 1310 | |||
| 1311 | JC NAMERR | ||
| 1312 | |||
| 1313 | MOV [MRG_HANDLE],AX | ||
| 1314 | MOV AX,(SET_INTERRUPT_VECTOR SHL 8) OR 23H | ||
| 1315 | MOV DX,OFFSET DG:ABORTMERGE | ||
| 1316 | INT 21H | ||
| 1317 | MOV BX,[PARAM1] | ||
| 1318 | OR BX,BX | ||
| 1319 | JNZ MRG | ||
| 1320 | MOV BX,[CURRENT] | ||
| 1321 | CALL CHKRANGE | ||
| 1322 | MRG: | ||
| 1323 | CALL FINDLIN | ||
| 1324 | MOV BX,DX | ||
| 1325 | MOV DX,[LAST] | ||
| 1326 | CALL MOVEFILE | ||
| 1327 | MOV DX,[POINTER] | ||
| 1328 | MOV CX,[ENDTXT] | ||
| 1329 | SUB CX,[POINTER] | ||
| 1330 | PUSH CX | ||
| 1331 | MOV BX,[MRG_HANDLE] | ||
| 1332 | MOV AH,READ | ||
| 1333 | INT 21H | ||
| 1334 | POP DX | ||
| 1335 | MOV CX,AX | ||
| 1336 | CMP DX,CX | ||
| 1337 | JA FILEMRG ; M005 | ||
| 1338 | MOV DX,OFFSET DG:MRGERR_ptr | ||
| 1339 | call std_printf | ||
| 1340 | MOV CX,[POINTER] | ||
| 1341 | JMP SHORT RESTORE | ||
| 1342 | FILEMRG: | ||
| 1343 | ADD CX,[POINTER] | ||
| 1344 | MOV SI,CX | ||
| 1345 | dec si | ||
| 1346 | LODSB | ||
| 1347 | CMP AL,1AH | ||
| 1348 | JNZ RESTORE | ||
| 1349 | dec cx | ||
| 1350 | RESTORE: | ||
| 1351 | MOV DI,CX | ||
| 1352 | MOV SI,[ENDTXT] | ||
| 1353 | INC SI | ||
| 1354 | MOV CX,[LAST] | ||
| 1355 | SUB CX,SI | ||
| 1356 | inc cx ; remember ^Z | ||
| 1357 | REP MOVSB | ||
| 1358 | dec di ; unremember ^Z | ||
| 1359 | MOV [ENDTXT],DI | ||
| 1360 | MOV BX,[MRG_HANDLE] | ||
| 1361 | MOV AH,CLOSE | ||
| 1362 | INT 21H | ||
| 1363 | return | ||
| 1364 | |||
| 1365 | PUBLIC INSERT | ||
| 1366 | INSERT: | ||
| 1367 | CMP ParamCt,1 | ||
| 1368 | JBE OKIns | ||
| 1369 | JMP ComErr | ||
| 1370 | OKIns: | ||
| 1371 | MOV AX,(SET_INTERRUPT_VECTOR SHL 8) OR 23H ;Set vector 23H | ||
| 1372 | MOV DX,OFFSET DG:ABORTINS | ||
| 1373 | INT 21H | ||
| 1374 | MOV BX,[PARAM1] | ||
| 1375 | OR BX,BX | ||
| 1376 | JNZ INS | ||
| 1377 | MOV BX,[CURRENT] | ||
| 1378 | CALL CHKRANGE | ||
| 1379 | INS: | ||
| 1380 | CALL FINDLIN | ||
| 1381 | MOV BX,DX | ||
| 1382 | MOV DX,[LAST] | ||
| 1383 | CALL MOVEFILE | ||
| 1384 | INLP: | ||
| 1385 | CALL SETPTS ;Update the pointers into file | ||
| 1386 | CALL SHOWNUM | ||
| 1387 | MOV DX,OFFSET DG:EDITBUF | ||
| 1388 | MOV AH,STD_CON_STRING_INPUT | ||
| 1389 | INT 21H | ||
| 1390 | CALL LF | ||
| 1391 | MOV SI,2 + OFFSET DG:EDITBUF | ||
| 1392 | CMP BYTE PTR [SI],1AH | ||
| 1393 | JZ ENDINS | ||
| 1394 | ;----------------------------------------------------------------------- | ||
| 1395 | call unquote ;scan for quote chars if any | ||
| 1396 | ;----------------------------------------------------------------------- | ||
| 1397 | MOV CL,[SI-1] | ||
| 1398 | MOV CH,0 | ||
| 1399 | MOV DX,DI | ||
| 1400 | INC CX | ||
| 1401 | ADD DX,CX | ||
| 1402 | JC MEMERRJ1 | ||
| 1403 | JZ MEMERRJ1 | ||
| 1404 | CMP DX,BP | ||
| 1405 | JB MEMOK | ||
| 1406 | MEMERRJ1: | ||
| 1407 | CALL END_INS | ||
| 1408 | JMP MEMERR | ||
| 1409 | MEMOK: | ||
| 1410 | REP MOVSB | ||
| 1411 | MOV AL,10 | ||
| 1412 | STOSB | ||
| 1413 | INC BX | ||
| 1414 | JMP SHORT INLP | ||
| 1415 | |||
| 1416 | ABORTMERGE: | ||
| 1417 | MOV DX,OFFSET DG:START | ||
| 1418 | MOV AH,SET_DMA | ||
| 1419 | INT 21H | ||
| 1420 | |||
| 1421 | ABORTINS: | ||
| 1422 | MOV AX,CS ;Restore segment registers | ||
| 1423 | MOV DS,AX | ||
| 1424 | MOV ES,AX | ||
| 1425 | MOV AX,CSTACK | ||
| 1426 | MOV SS,AX | ||
| 1427 | MOV SP,STACK | ||
| 1428 | STI | ||
| 1429 | CALL CRLF | ||
| 1430 | CALL ENDINS | ||
| 1431 | JMP COMOVER | ||
| 1432 | |||
| 1433 | ENDINS: | ||
| 1434 | CALL END_INS | ||
| 1435 | return | ||
| 1436 | |||
| 1437 | END_INS: | ||
| 1438 | MOV BP,[ENDTXT] | ||
| 1439 | MOV DI,[POINTER] | ||
| 1440 | MOV SI,BP | ||
| 1441 | INC SI | ||
| 1442 | MOV CX,[LAST] | ||
| 1443 | SUB CX,BP | ||
| 1444 | REP MOVSB | ||
| 1445 | DEC DI | ||
| 1446 | MOV [ENDTXT],DI | ||
| 1447 | MOV AX,(SET_INTERRUPT_VECTOR SHL 8) OR 23H | ||
| 1448 | MOV DX,OFFSET DG:ABORTCOM | ||
| 1449 | INT 21H | ||
| 1450 | return | ||
| 1451 | |||
| 1452 | |||
| 1453 | FILLBUF: | ||
| 1454 | MOV [PARAM1],-1 ;Read in max. no of lines | ||
| 1455 | MOV ParamCt,1 | ||
| 1456 | CALL APPEND | ||
| 1457 | MOV Param1,0 | ||
| 1458 | PUBLIC ENDED | ||
| 1459 | ENDED: | ||
| 1460 | |||
| 1461 | ;Write text out to .$$$ file | ||
| 1462 | |||
| 1463 | CMP ParamCt,1 | ||
| 1464 | JZ ENDED1 | ||
| 1465 | CERR: JMP ComErr | ||
| 1466 | Ended1: | ||
| 1467 | CMP Param1,0 | ||
| 1468 | JNZ Cerr | ||
| 1469 | MOV BYTE PTR [ENDING],1 ;Suppress memory errors | ||
| 1470 | MOV BX,-1 ;Write max. no of lines | ||
| 1471 | CALL WRT | ||
| 1472 | TEST BYTE PTR [HAVEOF],-1 | ||
| 1473 | JZ FILLBUF | ||
| 1474 | MOV DX,[ENDTXT] | ||
| 1475 | MOV CX,1 | ||
| 1476 | MOV BX,[WRT_HANDLE] | ||
| 1477 | MOV AH,WRITE | ||
| 1478 | INT 21H ;Write end-of-file byte | ||
| 1479 | |||
| 1480 | ;Close input file ; MZ 11/30 | ||
| 1481 | ; MZ 11/30 | ||
| 1482 | MOV BX,[RD_HANDLE] ; MZ 11/30 | ||
| 1483 | MOV AH,CLOSE ; MZ 11/30 | ||
| 1484 | INT 21H ; MZ 11/30 | ||
| 1485 | |||
| 1486 | ;Close .$$$ file | ||
| 1487 | |||
| 1488 | MOV BX,[WRT_HANDLE] | ||
| 1489 | MOV AH,CLOSE | ||
| 1490 | INT 21H | ||
| 1491 | |||
| 1492 | ;Rename original file .BAK | ||
| 1493 | |||
| 1494 | MOV DI,[EXT_PTR] | ||
| 1495 | MOV SI,OFFSET DG:BAK | ||
| 1496 | MOVSW | ||
| 1497 | MOVSW | ||
| 1498 | MOVSB | ||
| 1499 | MOV DX,OFFSET DG:PATH_NAME | ||
| 1500 | MOV DI,OFFSET DG:TEMP_PATH | ||
| 1501 | MOV AH,RENAME | ||
| 1502 | INT 21H | ||
| 1503 | MOV DI,[EXT_PTR] | ||
| 1504 | MOV SI,OFFSET DG:$$$FILE | ||
| 1505 | MOVSW | ||
| 1506 | MOVSW | ||
| 1507 | MOVSB | ||
| 1508 | |||
| 1509 | ;Rename .$$$ file to original name | ||
| 1510 | |||
| 1511 | MOV DX,OFFSET DG:TEMP_PATH | ||
| 1512 | MOV DI,OFFSET DG:PATH_NAME | ||
| 1513 | MOV AH,RENAME | ||
| 1514 | INT 21H | ||
| 1515 | ; mode | ||
| 1516 | mov ah,exit | ||
| 1517 | xor al,al | ||
| 1518 | int 21h | ||
| 1519 | |||
| 1520 | ;========================================================================= | ||
| 1521 | ; EDLIN_DISP_GET: This routine will give us the attributes of the | ||
| 1522 | ; current display, which are to be used to restore the screen | ||
| 1523 | ; back to its original state on exit from EDLIN. We also | ||
| 1524 | ; set the screen to a text mode here with an 80 X 25 color | ||
| 1525 | ; format. | ||
| 1526 | ; | ||
| 1527 | ; Inputs : VIDEO_GET - 0fH (get current video mode) | ||
| 1528 | ; VIDEO_SET - 00h (set video mode) | ||
| 1529 | ; VIDEO_TEXT- 03h (80 X 25 color mode) | ||
| 1530 | ; | ||
| 1531 | ; Outputs : VIDEO_ORG - Original video attributes on entry to EDLIN | ||
| 1532 | ; | ||
| 1533 | ;========================================================================= | ||
| 1534 | |||
| 1535 | EDLIN_DISP_GET proc near ;an000;video attributes | ||
| 1536 | |||
| 1537 | push ax ;an000;save affected regs. | ||
| 1538 | push bx ;an000; | ||
| 1539 | push cx ;an000; | ||
| 1540 | push dx ;an000; | ||
| 1541 | push si ;an000; | ||
| 1542 | push ds ;an000; | ||
| 1543 | |||
| 1544 | push cs ;an000;exchange cs/ds | ||
| 1545 | pop ds ;an000; | ||
| 1546 | |||
| 1547 | mov ax,440Ch ;an000;generic ioctl | ||
| 1548 | mov bx,Std_Out ;an000;Console | ||
| 1549 | mov cx,(Display_Attr shl 8) or Get_Display ;an000;get display | ||
| 1550 | mov dx,offset dg:Video_Buffer ;an000;buffer for video attr. | ||
| 1551 | int 21h ;an000; | ||
| 1552 | ; $if nc ;an000;function returned a | ||
| 1553 | JC $$IF17 | ||
| 1554 | ; buffer | ||
| 1555 | mov si,dx ;an000;get pointer | ||
| 1556 | mov ax,word ptr dg:[si].Display_Length_Char ;an000;get video len. | ||
| 1557 | dec ax ;an000;allow room for message | ||
| 1558 | mov dg:Disp_Len,al ;an000;put it into var. | ||
| 1559 | mov ax,word ptr dg:[si].Display_Width_Char ;an000;get video width | ||
| 1560 | mov dg:Disp_Width,al ;an000;put it into var. | ||
| 1561 | ; $else ;an000;function failed use | ||
| 1562 | JMP SHORT $$EN17 | ||
| 1563 | $$IF17: | ||
| 1564 | ; default values | ||
| 1565 | mov al,Def_Disp_Len ;an000;get default length | ||
| 1566 | dec al ;an000;leave room for messages | ||
| 1567 | mov dg:Disp_Len,al ;an000;use default length | ||
| 1568 | mov dg:Disp_Width,Def_Disp_Width;an000;use default width | ||
| 1569 | ; $endif ;an000; | ||
| 1570 | $$EN17: | ||
| 1571 | |||
| 1572 | pop ds ;an000;restore affected regs. | ||
| 1573 | pop si ;an000; | ||
| 1574 | pop dx ;an000; | ||
| 1575 | pop cx ;an000; | ||
| 1576 | pop bx ;an000; | ||
| 1577 | pop ax ;an000; | ||
| 1578 | |||
| 1579 | ret ;an000;return to caller | ||
| 1580 | |||
| 1581 | EDLIN_DISP_GET endp ;an000;end proc. | ||
| 1582 | |||
| 1583 | |||
| 1584 | ;========================================================================= | ||
| 1585 | ; EXT_OPEN1 : This routine opens a file for read/write access. If the file | ||
| 1586 | ; if not present for opening the open will fail and return with a | ||
| 1587 | ; carry set. | ||
| 1588 | ; | ||
| 1589 | ; Inputs : BX - Open mode | ||
| 1590 | ; CX - File attributes | ||
| 1591 | ; DX - Open action | ||
| 1592 | ; | ||
| 1593 | ; Outputs: CY - If error | ||
| 1594 | ; | ||
| 1595 | ; Date : 6/10/87 | ||
| 1596 | ;========================================================================= | ||
| 1597 | |||
| 1598 | EXT_OPEN1 proc near ;an000;open for R/W | ||
| 1599 | |||
| 1600 | assume ds:dg | ||
| 1601 | push ds ;an000;save regs | ||
| 1602 | push si ;an000; | ||
| 1603 | |||
| 1604 | mov ah,ExtOpen ;an000;extended open | ||
| 1605 | mov al,0 ;an000;reserved by system | ||
| 1606 | mov si,offset dg:path_name ;an000;point to PATH_NAME | ||
| 1607 | |||
| 1608 | int 21h ;an000;invoke function | ||
| 1609 | pop si ;an000;restore regs | ||
| 1610 | pop ds ;an000; | ||
| 1611 | |||
| 1612 | ret ;an000;return to caller | ||
| 1613 | |||
| 1614 | EXT_OPEN1 endp ;an000;end proc. | ||
| 1615 | |||
| 1616 | ;========================================================================= | ||
| 1617 | ; EXT_OPEN2 : This routine will attempt to create a file for read/write | ||
| 1618 | ; access. If the files exists the create will fail and return | ||
| 1619 | ; with the carry set. | ||
| 1620 | ; | ||
| 1621 | ; Inputs : BX - Open mode | ||
| 1622 | ; CX - File attributes | ||
| 1623 | ; DX - Open action | ||
| 1624 | ; | ||
| 1625 | ; Outputs: CY - If error | ||
| 1626 | ; | ||
| 1627 | ; Date : 6/10/87 | ||
| 1628 | ;========================================================================= | ||
| 1629 | |||
| 1630 | EXT_OPEN2 proc near ;an000;create a file | ||
| 1631 | |||
| 1632 | assume ds:dg | ||
| 1633 | push ds ;an000;save regs | ||
| 1634 | push si ;an000; | ||
| 1635 | |||
| 1636 | mov ah,ExtOpen ;an000;extended open | ||
| 1637 | mov al,0 ;an000;reserved by system | ||
| 1638 | mov si,offset dg:temp_path ;an000;point to TEMP_PATH | ||
| 1639 | |||
| 1640 | int 21h ;an000;invoke function | ||
| 1641 | |||
| 1642 | pop si ;an000;restore regs | ||
| 1643 | pop ds ;an000; | ||
| 1644 | |||
| 1645 | ret ;an000;return to caller | ||
| 1646 | |||
| 1647 | EXT_OPEN2 endp ;an000;end proc. | ||
| 1648 | |||
| 1649 | ;========================================================================= | ||
| 1650 | ; EXT_OPEN3 : This routine will attempt to create a file for read | ||
| 1651 | ; access. If the files exists the create will fail and return | ||
| 1652 | ; with the carry set. | ||
| 1653 | ; | ||
| 1654 | ; Inputs : BX - Open mode | ||
| 1655 | ; CX - File attributes | ||
| 1656 | ; DX - Open action | ||
| 1657 | ; | ||
| 1658 | ; Outputs: CY - If error | ||
| 1659 | ; | ||
| 1660 | ; Date : 6/10/87 | ||
| 1661 | ;========================================================================= | ||
| 1662 | |||
| 1663 | EXT_OPEN3 proc near ;an000;create a file | ||
| 1664 | |||
| 1665 | assume ds:dg | ||
| 1666 | push ds ;an000;save regs | ||
| 1667 | push si ;an000; | ||
| 1668 | |||
| 1669 | mov ah,ExtOpen ;an000;extended open | ||
| 1670 | mov al,0 ;an000;reserved by system | ||
| 1671 | mov si,offset dg:mrg_path_name ;an000;point to mrg_path_name | ||
| 1672 | |||
| 1673 | int 21h ;an000;invoke function | ||
| 1674 | |||
| 1675 | pop si ;an000;restore regs | ||
| 1676 | pop ds ;an000; | ||
| 1677 | |||
| 1678 | ret ;an000;return to caller | ||
| 1679 | |||
| 1680 | EXT_OPEN3 endp ;an000;end proc. | ||
| 1681 | |||
| 1682 | |||
| 1683 | ;========================================================================= | ||
| 1684 | ; EDLIN_COMMAND : This routine provides an interface between the new | ||
| 1685 | ; parser and the existing logic of EDLIN. We will be | ||
| 1686 | ; interfacing the parser with three existing variables. | ||
| 1687 | ; | ||
| 1688 | ; Inputs : FILESPEC - Filespec entered by the user and passed by | ||
| 1689 | ; the parser. | ||
| 1690 | ; | ||
| 1691 | ; PARSE_SWITCH_B - Contains the result of the parse for the | ||
| 1692 | ; /B switch. This is passed by the parser. | ||
| 1693 | ; | ||
| 1694 | ; Outputs: PATH_NAME - Filespec | ||
| 1695 | ; LOADMOD - Flag for /B switch | ||
| 1696 | ; FNAME_LEN - Length of filespec | ||
| 1697 | ; | ||
| 1698 | ; Date : 6/11/87 | ||
| 1699 | ;========================================================================= | ||
| 1700 | |||
| 1701 | EDLIN_COMMAND proc near ;an000;interface parser | ||
| 1702 | |||
| 1703 | push ax ;an000;save regs. | ||
| 1704 | push cx ;an000; | ||
| 1705 | push di ;an000 | ||
| 1706 | push si ;an000; | ||
| 1707 | |||
| 1708 | mov si,offset dg:filespec ;an000;get its offset | ||
| 1709 | mov di,offset dg:path_name ;an000;get its offset | ||
| 1710 | |||
| 1711 | mov cx,00h ;an000;cx will count filespec | ||
| 1712 | ; length | ||
| 1713 | cmp parse_switch_b,true ;an000;do we have /B switch | ||
| 1714 | ; $if z ;an000;we have the switch | ||
| 1715 | JNZ $$IF20 | ||
| 1716 | mov [LOADMOD],01h ;an000;signal switch found | ||
| 1717 | ; $endif ;an000 | ||
| 1718 | $$IF20: | ||
| 1719 | |||
| 1720 | ; $do ;an000;while we have filespec | ||
| 1721 | $$DO22: | ||
| 1722 | lodsb ;an000;move byte to al | ||
| 1723 | cmp al,nul ;an000;see if we are at | ||
| 1724 | ; the end of the | ||
| 1725 | ; filespec | ||
| 1726 | ; $leave e ;an000;exit while loop | ||
| 1727 | JE $$EN22 | ||
| 1728 | stosb ;an000;move byte to path_name | ||
| 1729 | inc cx ;an000;increment the length | ||
| 1730 | ; of the filespec | ||
| 1731 | ; $enddo ;an000;end do while | ||
| 1732 | JMP SHORT $$DO22 | ||
| 1733 | $$EN22: | ||
| 1734 | |||
| 1735 | mov [FNAME_LEN],cx ;an000;save filespec's length | ||
| 1736 | |||
| 1737 | pop si ;an000; restore regs | ||
| 1738 | pop di ;an000; | ||
| 1739 | pop cx ;an000; | ||
| 1740 | pop ax ;an000; | ||
| 1741 | |||
| 1742 | ret ;an000;return to caller | ||
| 1743 | |||
| 1744 | EDLIN_COMMAND endp ;an000;end proc | ||
| 1745 | |||
| 1746 | ;========================================================================= | ||
| 1747 | ; Get_Extended_Attrib : This routine gets the extended attributes of | ||
| 1748 | ; the file that was opened. | ||
| 1749 | ; | ||
| 1750 | ;========================================================================= | ||
| 1751 | |||
| 1752 | Get_Extended_Attrib proc near ;an000; dms; | ||
| 1753 | |||
| 1754 | mov ax,5702h ;an000; dms;get extended attrib | ||
| 1755 | mov si,0ffffh ;an000; dms;all attribs | ||
| 1756 | mov cx,dg:EA_Buffer_Size ;an000; dms;buffer size | ||
| 1757 | mov di,offset dg:Start ;an000; dms;point to buffer | ||
| 1758 | int 21h ;an000; dms; | ||
| 1759 | ret ;an000; dms; | ||
| 1760 | |||
| 1761 | Get_Extended_Attrib endp ;an000; dms; | ||
| 1762 | |||
| 1763 | |||
| 1764 | ;========================================================================= | ||
| 1765 | ; Query_Extend_Attrib : This routine gets the extended attributes of | ||
| 1766 | ; the file that was opened. | ||
| 1767 | ; | ||
| 1768 | ; Inputs : Start - Buffer for extended attributes | ||
| 1769 | ; | ||
| 1770 | ; Outputs : CX - size in paras | ||
| 1771 | ; | ||
| 1772 | ;========================================================================= | ||
| 1773 | |||
| 1774 | Query_Extend_Attrib proc near ;an000; dms; | ||
| 1775 | |||
| 1776 | mov ax,5702h ;an000; dms;get extended attrib | ||
| 1777 | mov si,0ffffh ;an000; dms;all attribs | ||
| 1778 | mov cx,0000h ;an000; dms;get buffer size | ||
| 1779 | mov di,offset dg:Start ;an000; dms;point to buffer | ||
| 1780 | int 21h ;an000; dms; | ||
| 1781 | mov dg:EA_Buffer_Size,cx ;an000; dms;save buffer size | ||
| 1782 | ret ;an000; dms; | ||
| 1783 | |||
| 1784 | Query_Extend_Attrib endp ;an000; dms; | ||
| 1785 | |||
| 1786 | |||
| 1787 | ;========================================================================= | ||
| 1788 | ; Calc_Memory_Avail : This routine will calculate the memory | ||
| 1789 | ; available for use by EDLIN. | ||
| 1790 | ; | ||
| 1791 | ; Inputs : ORG_DS - DS of PSP | ||
| 1792 | ; | ||
| 1793 | ; Outputs : DX - paras available | ||
| 1794 | ;========================================================================= | ||
| 1795 | |||
| 1796 | Calc_Memory_Avail proc near ;an000; dms; | ||
| 1797 | |||
| 1798 | push ds ;save ds for size calc | ||
| 1799 | push cx ;an000; dms; | ||
| 1800 | push di ;an000; dms; | ||
| 1801 | |||
| 1802 | mov ds,cs:[org_ds] | ||
| 1803 | MOV CX,DS:[2] | ||
| 1804 | MOV DI,CS | ||
| 1805 | SUB CX,DI | ||
| 1806 | mov dx,cx ;an000; dms;put paras in DX | ||
| 1807 | |||
| 1808 | pop di ;an000; dms; | ||
| 1809 | pop cx ;an000; dms; | ||
| 1810 | pop ds ;an000; dms; | ||
| 1811 | |||
| 1812 | ret ;an000; dms; | ||
| 1813 | |||
| 1814 | Calc_Memory_Avail endp ;an000; dms; | ||
| 1815 | |||
| 1816 | ;========================================================================= | ||
| 1817 | ; EA_Fail_Exit : This routine tells the user that there was | ||
| 1818 | ; Insufficient memory and exits EDLIN. | ||
| 1819 | ; | ||
| 1820 | ; Inputs : MemFul_Ptr - "Insufficient memory" | ||
| 1821 | ; | ||
| 1822 | ; Outputs : message | ||
| 1823 | ;========================================================================= | ||
| 1824 | |||
| 1825 | EA_Fail_Exit proc near ;an000; dms; | ||
| 1826 | |||
| 1827 | mov dx,offset dg:MemFul_Ptr ;an000; dms;"Insufficient | ||
| 1828 | |||
| 1829 | push cs ;an000; dms;xchange ds/cs | ||
| 1830 | pop ds ;an000; dms; | ||
| 1831 | ; memory" | ||
| 1832 | call Std_Printf ;an000; dms;print message | ||
| 1833 | mov ah,exit ;an000; dms;exit | ||
| 1834 | xor al,al ;an000; dms;clear al | ||
| 1835 | int 21h ;an000; dms; | ||
| 1836 | ret ;an000; dms; | ||
| 1837 | |||
| 1838 | EA_Fail_Exit endp ;an000; dms; | ||
| 1839 | |||
| 1840 | CODE ENDS | ||
| 1841 | END EDLIN | ||
| 1842 | |||
| 1843 | \ No newline at end of file | ||
diff --git a/v4.0/src/CMD/EDLIN/EDLIN.LNK b/v4.0/src/CMD/EDLIN/EDLIN.LNK new file mode 100644 index 0000000..8b90da5 --- /dev/null +++ b/v4.0/src/CMD/EDLIN/EDLIN.LNK | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | EDLIN+ | ||
| 2 | EDLCMD1+ | ||
| 3 | EDLCMD2+ | ||
| 4 | EDLMES+ | ||
| 5 | EDLPARSE | ||
| 6 | EDLIN.EXE; | ||
| 7 | \ No newline at end of file | ||
diff --git a/v4.0/src/CMD/EDLIN/EDLIN.SKL b/v4.0/src/CMD/EDLIN/EDLIN.SKL new file mode 100644 index 0000000..ff5109e --- /dev/null +++ b/v4.0/src/CMD/EDLIN/EDLIN.SKL | |||
| @@ -0,0 +1,75 @@ | |||
| 1 | ;======================= START OF SPECIFICATIONS ========================= | ||
| 2 | ; | ||
| 3 | ; MODULE NAME: EDLMES.FIL | ||
| 4 | ; | ||
| 5 | ; DESCRIPTIVE NAME: EDLIN MESSAGES | ||
| 6 | ; | ||
| 7 | ; FUNCTION: PROVIDES A SET OF MESSAGES FOR EDLIN. | ||
| 8 | ; | ||
| 9 | ; ENTRY POINT: NA | ||
| 10 | ; | ||
| 11 | ; INPUT: NA | ||
| 12 | ; | ||
| 13 | ; EXIT NORMAL: NA | ||
| 14 | ; | ||
| 15 | ; EXIT ERROR: NA | ||
| 16 | ; | ||
| 17 | ; INTERNAL REFERENCES: NA | ||
| 18 | ; | ||
| 19 | ; EXTERNAL REFERENCES: NA | ||
| 20 | ; | ||
| 21 | ; | ||
| 22 | ; NOTES: THIS MODULE IS TO BE PREPPED BY FASTBLD.EXE. | ||
| 23 | ; | ||
| 24 | ; REVISION HISTORY: | ||
| 25 | ; | ||
| 26 | ; VERSION 4.00 - CREATED FOR DOS 4.00 | ||
| 27 | ; | ||
| 28 | ;======================= END OF SPECIFICATIONS =========================== | ||
| 29 | |||
| 30 | ;========================================================================= | ||
| 31 | ; edlin utility message file | ||
| 32 | ;========================================================================= | ||
| 33 | |||
| 34 | :util EDLIN ;utility name | ||
| 35 | :class 1 | ||
| 36 | |||
| 37 | :class A ;system messages | ||
| 38 | :use 1 COMMON1 ;"Incorrect DOS version",CR,LF | ||
| 39 | :use 2 COMMON2 ;"Insufficient memory",CR,LF | ||
| 40 | :use 3 COMMON3 ;"Error loading messages",CR,LF | ||
| 41 | |||
| 42 | :class B ;utility messages | ||
| 43 | :def 6 "*" ;prompt_ptr | ||
| 44 | :def 7 "Invalid drive or file name",CR,LF ;baddrv_ptr | ||
| 45 | :def 8 "File name must be specified",CR,LF ;ndname_ptr | ||
| 46 | :def 10 "File is READ-ONLY",CR,LF ;ro_err_ptr | ||
| 47 | :def 11 "File Creation Error",CR,LF ;bcreat_ptr | ||
| 48 | :def 12 "Too many files open",CR,LF ;too_many_ptr | ||
| 49 | :def 13 "Read error in:",CR,LF,"%1",CR,LF ;read_err_ptr | ||
| 50 | :def 14 "Cannot edit .BAK file--rename file",CR,LF ;nobak_ptr | ||
| 51 | :def 15 "No room in directory for file",CR,LF ;nodir_ptr | ||
| 52 | :def 16 "Disk full. Edits lost.",CR,LF ;dskful_ptr | ||
| 53 | :def 18 "Entry error",CR,LF ;badcom_ptr | ||
| 54 | :def 19 "New file",CR,LF ;newfil_ptr | ||
| 55 | :def 20 "Not found",CR,LF ;nosuch_ptr | ||
| 56 | |||
| 57 | :class C ;utility messages | ||
| 58 | :def 21 "O.K.? " ;ask_ptr | ||
| 59 | :def 22 "Line too long",CR,LF ;toolng_ptr | ||
| 60 | :def 23 "End of input file",CR,LF ;eof_ptr | ||
| 61 | :def 24 "Abort edit (Y/N)? " ;qmes_ptr | ||
| 62 | :def 25 "Must specify destination line number",CR,LF ;dest_ptr | ||
| 63 | :def 26 "Not enough room to merge the entire file",CR,LF ;mrgerr_ptr | ||
| 64 | :def 27 CR,LF ;crlf_ptr | ||
| 65 | :def 28 LF ;lf_ptr | ||
| 66 | :def 29 "Continue (Y/N)?" ;cont_ptr | ||
| 67 | :def 30 "Unable to print message",CR,LF ;fatal_error | ||
| 68 | :def 31 "%1" ;arg_buf_ptr | ||
| 69 | :def 32 "%1:%2" ;line_num_buf_ptr | ||
| 70 | :def 33 "Cannot merge - Code page mismatch",CR,LF ;cp_err_ptr | ||
| 71 | |||
| 72 | :end | ||
| 73 | |||
| 74 | ;========================================================================= | ||
| 75 | ;========================================================================= | ||
diff --git a/v4.0/src/CMD/EDLIN/EDLMES.ASM b/v4.0/src/CMD/EDLIN/EDLMES.ASM new file mode 100644 index 0000000..889a044 --- /dev/null +++ b/v4.0/src/CMD/EDLIN/EDLMES.ASM | |||
| @@ -0,0 +1,665 @@ | |||
| 1 | PAGE 60,132; | ||
| 2 | title EDLIN Messages | ||
| 3 | ;======================= START OF SPECIFICATIONS ========================= | ||
| 4 | ; | ||
| 5 | ; MODULE NAME: EDLMES.SAL | ||
| 6 | ; | ||
| 7 | ; DESCRIPTIVE NAME: MESSAGE RETRIEVER INTERFACE MODULE | ||
| 8 | ; | ||
| 9 | ; FUNCTION: THIS MODULE PROVIDES AN INTERFACE FOR THE MODULES THAT ARE | ||
| 10 | ; NEEDED TO INVOKE THE MESSAGE RETRIEVER. | ||
| 11 | ; | ||
| 12 | ; ENTRY POINT: PRINTF | ||
| 13 | ; | ||
| 14 | ; INPUT: OFFSET CARRIED IN DX TO APPLICABLE MESSAGE TABLE | ||
| 15 | ; | ||
| 16 | ; EXIT NORMAL: NO CARRY | ||
| 17 | ; | ||
| 18 | ; EXIT ERROR : CARRY | ||
| 19 | ; | ||
| 20 | ; INTERNAL REFERENCES: | ||
| 21 | ; | ||
| 22 | ; ROUTINE: PRINTF - PROVIDES THE ORIGINAL INTERFACE FOR THE ORIGINAL | ||
| 23 | ; PRINTF USED PRIOR TO VERSION 4.00. PRINTS MESSAGES. | ||
| 24 | ; | ||
| 25 | ; DISP_MESSAGE - BUILDS THE REGISTERS NECESSARY FOR INVOCATION | ||
| 26 | ; OF THE MESSAGE RETRIEVER, BASED ON THE TABLE | ||
| 27 | ; POINTED TO BY DX. | ||
| 28 | ; | ||
| 29 | ; DISP_FATAL - INVOKED IF AN ERROR OCCURS (CARRY) IN THE | ||
| 30 | ; MESSAGE RETRIEVER. IT DISPLAYS THE APPROPRIATE | ||
| 31 | ; MESSAGE. | ||
| 32 | ; | ||
| 33 | ; EXTERNAL REFERENCES: | ||
| 34 | ; | ||
| 35 | ; ROUTINE: SYSLOADMSG - LOAD MESSAGES FOR THE MESSAGE RETRIEVER | ||
| 36 | ; SYSDISPMSG - DISPLAYS THE REQUESTED MESSAGE | ||
| 37 | ; | ||
| 38 | ; NOTES: THIS MODULE IS TO BE PREPPED BY SALUT WITH THE "PR" OPTIONS | ||
| 39 | ; LINK EDLIN+EDLCMD1+EDLCMD2+EDLMES+EDLPARSE | ||
| 40 | ; | ||
| 41 | ; REVISION HISTORY: | ||
| 42 | ; | ||
| 43 | ; AN000 VERSION DOS 4.00 - IMPLEMENTATION OF MESSAGE RETRIEVER | ||
| 44 | ; | ||
| 45 | ; COPYRIGHT: "MS DOS EDLIN UTILITY" | ||
| 46 | ; "VERSION 4.00 (C) COPYRIGHT 1988 Microsoft" | ||
| 47 | ; "LICENSED MATERIAL - PROPERTY OF Microsoft " | ||
| 48 | ; | ||
| 49 | ; MICROSOFT REVISION HISTORY | ||
| 50 | ; | ||
| 51 | ; MODIFIED BY: AARON R | ||
| 52 | ; M.A. U | ||
| 53 | ; N. P | ||
| 54 | ;======================= END OF SPECIFICATIONS =========================== | ||
| 55 | |||
| 56 | .xlist | ||
| 57 | |||
| 58 | include sysmsg.inc ;an000;message retriever | ||
| 59 | |||
| 60 | msg_utilname <EDLIN> ;an000;EDLIN messages | ||
| 61 | .list | ||
| 62 | ;-----------------------------------------------------------------------; | ||
| 63 | ; ; | ||
| 64 | ; Done for Vers 2.00 (rev 9) by Aaron R ; | ||
| 65 | ; Update for rev. 11 by M.A. U ; | ||
| 66 | ; Printf for 2.5 by Nancy P ; | ||
| 67 | ; ; | ||
| 68 | ;-----------------------------------------------------------------------; | ||
| 69 | |||
| 70 | ;========================================================================= | ||
| 71 | ; revised edlmes.asm | ||
| 72 | ;========================================================================= | ||
| 73 | |||
| 74 | fatal_error equ 30 ;an000;fatal message handler | ||
| 75 | unlim_width equ 00h ;an000;unlimited output width | ||
| 76 | pad_blank equ 20h ;an000;blank pad | ||
| 77 | pre_load equ 00h ;an000;normal pre-load | ||
| 78 | |||
| 79 | |||
| 80 | |||
| 81 | message_table struc ;an000;struc for message table | ||
| 82 | |||
| 83 | entry1 dw 0 ;an000;message number | ||
| 84 | entry2 db 0 ;an000;message type | ||
| 85 | entry3 dw 0 ;an000;display handle | ||
| 86 | entry4 dw 0 ;an000;pointer to sublist | ||
| 87 | entry5 dw 0 ;an000;substitution count | ||
| 88 | entry6 db 0 ;an000;use keyb input? | ||
| 89 | entry7 dw 0 ;an000;keyb buffer to use | ||
| 90 | |||
| 91 | message_table ends ;an000;end struc | ||
| 92 | |||
| 93 | ;========================================================================= | ||
| 94 | ; macro disp_message: this macro takes a pointer to a message table | ||
| 95 | ; and displays the applicable message based on | ||
| 96 | ; the table's contents. | ||
| 97 | ; this is to provide an interface into the module | ||
| 98 | ; of the message retriever, SYSDISPMSG. | ||
| 99 | ; | ||
| 100 | ; Date : 6/11/87 | ||
| 101 | ;========================================================================= | ||
| 102 | |||
| 103 | disp_message macro tbl ;an000;display message macro | ||
| 104 | |||
| 105 | push bx ;an000; | ||
| 106 | push cx ;an000; | ||
| 107 | push dx ;an000; | ||
| 108 | push di ;an000; | ||
| 109 | push si ;an000; | ||
| 110 | |||
| 111 | push tbl ;an000;exchange tbl with si | ||
| 112 | pop si ;an000;exchanged | ||
| 113 | |||
| 114 | mov ax,[si].entry1 ;an000;move message number | ||
| 115 | mov bx,[si].entry3 ;an000;display handle | ||
| 116 | mov cx,[si].entry5 ;an000;number of subs | ||
| 117 | mov dl,[si].entry6 ;an000;function type | ||
| 118 | mov di,[si].entry7 ;an000;input buffer if appl. | ||
| 119 | mov dh,[si].entry2 ;an000;message type | ||
| 120 | mov si,[si].entry4 ;an000;sublist | ||
| 121 | |||
| 122 | call sysdispmsg ;an000;display the message | ||
| 123 | |||
| 124 | pop si ;an000;restore affected regs | ||
| 125 | pop di ;an000; | ||
| 126 | pop dx ;an000; | ||
| 127 | pop cx ;an000; | ||
| 128 | pop bx ;an000; | ||
| 129 | |||
| 130 | endm ;an000;end macro disp_message | ||
| 131 | |||
| 132 | ;========================================================================= | ||
| 133 | ; macro disp_message: end macro | ||
| 134 | ;========================================================================= | ||
| 135 | |||
| 136 | CODE SEGMENT PUBLIC BYTE | ||
| 137 | CODE ENDS | ||
| 138 | |||
| 139 | CONST SEGMENT PUBLIC BYTE | ||
| 140 | CONST ENDS | ||
| 141 | |||
| 142 | cstack segment stack | ||
| 143 | cstack ends | ||
| 144 | |||
| 145 | DATA SEGMENT PUBLIC BYTE | ||
| 146 | |||
| 147 | extrn path_name:byte | ||
| 148 | |||
| 149 | DATA ENDS | ||
| 150 | |||
| 151 | DG GROUP CODE,CONST,cstack,DATA | ||
| 152 | |||
| 153 | code segment public byte ;an000;code segment | ||
| 154 | assume cs:dg,ds:dg,es:dg,ss:CStack ;an000; | ||
| 155 | |||
| 156 | public printf ;an000;share printf | ||
| 157 | public disp_fatal ;an000;fatal error display | ||
| 158 | public pre_load_message ;an000;message loader | ||
| 159 | |||
| 160 | .xlist | ||
| 161 | msg_services <MSGDATA> ;an000; | ||
| 162 | .list | ||
| 163 | |||
| 164 | ;======================= sysmsg.inc invocation =========================== | ||
| 165 | ; | ||
| 166 | ; include sysmsg.inc - message retriever services | ||
| 167 | ; | ||
| 168 | ; | ||
| 169 | ; options selected: | ||
| 170 | ; NEARmsg | ||
| 171 | ; DISPLAYmsg | ||
| 172 | ; LOADmsg | ||
| 173 | ; CHARmsg | ||
| 174 | ; NUMmsg | ||
| 175 | ; CLSAmsg | ||
| 176 | ; CLSBmsg | ||
| 177 | ; CLSCmsg | ||
| 178 | ; | ||
| 179 | ;========================================================================= | ||
| 180 | |||
| 181 | .xlist | ||
| 182 | |||
| 183 | msg_services <LOADmsg> ;an000;no version check | ||
| 184 | msg_services <DISPLAYmsg,CHARmsg,NUMmsg,INPUTmsg> ;an000;display messages | ||
| 185 | msg_services <EDLIN.CLA,EDLIN.CLB,EDLIN.CLC> ;an000;message types | ||
| 186 | msg_services <EDLIN.CL1,EDLIN.CL2> ;an000;message types | ||
| 187 | msg_services <EDLIN.CTL> ;an000; | ||
| 188 | |||
| 189 | .list | ||
| 190 | |||
| 191 | ;========================================================================= | ||
| 192 | ; printf: printf is a replacement of the printf procedure used in DOS | ||
| 193 | ; releases prior to 4.00. printf invokes the macro disp_message | ||
| 194 | ; to display a message through the new message handler. the | ||
| 195 | ; interface into printf will continue to be a pointer to a message | ||
| 196 | ; passed in DX. the pointer is pointing to more than a message | ||
| 197 | ; now. it is pointing to a table for that message containing | ||
| 198 | ; all relevant information for printing the message. the macro | ||
| 199 | ; disp_message operates on these tables. | ||
| 200 | ; | ||
| 201 | ; Date : 6/11/87 | ||
| 202 | ;========================================================================= | ||
| 203 | |||
| 204 | printf proc near ;an000;printf procedure | ||
| 205 | |||
| 206 | disp_message dx ;an000;display a message | ||
| 207 | ; $if c ;an000;if an error occurred | ||
| 208 | JNC $$IF1 | ||
| 209 | call disp_fatal ;an000;display the fatal error | ||
| 210 | ; $endif ;an000; | ||
| 211 | $$IF1: | ||
| 212 | |||
| 213 | ret ;an000;return to caller | ||
| 214 | |||
| 215 | printf endp ;an000;end printf proc | ||
| 216 | |||
| 217 | |||
| 218 | ;========================================================================= | ||
| 219 | ; disp_fatal: this routine displays a fatal error message in the event | ||
| 220 | ; an error occurred in disp_message. | ||
| 221 | ; | ||
| 222 | ; Date : 6/11/87 | ||
| 223 | ;========================================================================= | ||
| 224 | |||
| 225 | disp_fatal proc near ;an000;fatal error message | ||
| 226 | |||
| 227 | mov ax,fatal_error ;an000;fatal_error number | ||
| 228 | mov bx,stdout ;an000;print to console | ||
| 229 | mov cx,0 ;an000;no parameters | ||
| 230 | mov dl,no_input ;an000;no keyboard input | ||
| 231 | mov dh,UTILITY_MSG_CLASS ;an000;utility messages | ||
| 232 | |||
| 233 | call sysdispmsg ;an000;display fatal error | ||
| 234 | |||
| 235 | ret ;an000;return to caller | ||
| 236 | |||
| 237 | disp_fatal endp ;an000;end disp_fatal proc | ||
| 238 | |||
| 239 | ;========================================================================= | ||
| 240 | ; PRE_LOAD_MESSAGE : This routine provides access to the messages required | ||
| 241 | ; by EDLIN. This routine will report if the load was | ||
| 242 | ; successful. An unsuccessful load will cause EDLIN | ||
| 243 | ; to terminate with an appropriate error message. | ||
| 244 | ; | ||
| 245 | ; Date : 6/11/87 | ||
| 246 | ;========================================================================= | ||
| 247 | |||
| 248 | PRE_LOAD_MESSAGE proc near ;an000;pre-load messages | ||
| 249 | |||
| 250 | |||
| 251 | call SYSLOADMSG ;an000;invoke loader | ||
| 252 | |||
| 253 | ; $if c ;an000;if an error | ||
| 254 | JNC $$IF3 | ||
| 255 | pushf ;an000;save flags | ||
| 256 | call SYSDISPMSG ;an000;let him say why | ||
| 257 | popf ;an000;restore flags | ||
| 258 | ; $endif ;an000; | ||
| 259 | $$IF3: | ||
| 260 | |||
| 261 | ret ;an000;return to caller | ||
| 262 | |||
| 263 | PRE_LOAD_MESSAGE endp ;an000;end proc | ||
| 264 | |||
| 265 | include msgdcl.inc | ||
| 266 | |||
| 267 | code ends ;an000;end code segment | ||
| 268 | |||
| 269 | |||
| 270 | |||
| 271 | |||
| 272 | CONST SEGMENT PUBLIC BYTE | ||
| 273 | |||
| 274 | extrn arg_buf:byte ;an000; | ||
| 275 | extrn line_num:byte ;an000; | ||
| 276 | extrn line_flag:byte ;an000; | ||
| 277 | extrn Temp_Path:byte ;an000; | ||
| 278 | |||
| 279 | public baddrv_ptr,bad_vers_err,opt_err_ptr,nobak_ptr | ||
| 280 | public too_many_ptr,dskful_ptr,memful_ptr,badcom_ptr | ||
| 281 | public nodir_ptr,filenm_ptr,newfil_ptr,read_err_ptr | ||
| 282 | public nosuch_ptr,toolng_ptr,eof_ptr,dest_ptr | ||
| 283 | public mrgerr_ptr,ro_err_ptr,bcreat_ptr,ndname_ptr | ||
| 284 | public ask_ptr,qmes_ptr,crlf_ptr,lf_ptr,yes_byte | ||
| 285 | public prompt_ptr | ||
| 286 | public line_num_buf_ptr ;an000;DMS:6/15/87 | ||
| 287 | public arg_buf_ptr ;an000;DMS:6/15/87 | ||
| 288 | public cont_ptr ;an000;DMS:6/18/87 | ||
| 289 | public cp_err_ptr ;an000;DMS:6/22/87 | ||
| 290 | public Del_Bak_Ptr ;an000;dms; | ||
| 291 | |||
| 292 | yes_byte db "y" | ||
| 293 | |||
| 294 | ;============== REPLACEABLE PARAMETER SUBLIST STRUCTURE ================== | ||
| 295 | ; | ||
| 296 | ; byte 1 - substitution list size, always 11 | ||
| 297 | ; byte 2 - reserved for use by message handler | ||
| 298 | ; byte 3 - pointer to parameter to be used as a substitution | ||
| 299 | ; byte 7 - which parameter is this to replace, %1, %2, etc. | ||
| 300 | ; byte 8 - determines how the parameter is to be output | ||
| 301 | ; byte 9 - determines the maximum width of the parameter string | ||
| 302 | ; byte 10 - determines the minimum width of the parameter string | ||
| 303 | ; byte 11 - define what is to be used as a pad character | ||
| 304 | ; | ||
| 305 | ;========================================================================= | ||
| 306 | |||
| 307 | ;========================================================================= | ||
| 308 | ; replaceable parameter sublists | ||
| 309 | ;========================================================================= | ||
| 310 | |||
| 311 | ed_read_sub label dword ;an000;a read error occurred | ||
| 312 | |||
| 313 | db 11 ;an000;sublist size | ||
| 314 | db 00 ;an000;reserved | ||
| 315 | dd dg:path_name ;an000;pointer to parameter | ||
| 316 | db 01 ;an000;parm 1 | ||
| 317 | db Char_Field_ASCIIZ ;an000;left align/asciiz/char. | ||
| 318 | db unlim_width ;an000;unlimited width | ||
| 319 | db 00 ;an000;minimum width of 0 | ||
| 320 | db pad_blank ;an000;pad with blanks | ||
| 321 | |||
| 322 | arg_sub label dword ;an000;line output buffer | ||
| 323 | |||
| 324 | db 11 ;an000;sublist size | ||
| 325 | db 00 ;an000;reserved | ||
| 326 | dd dg:arg_buf ;an000;pointer to parameter | ||
| 327 | db 01 ;an000;parm 1 | ||
| 328 | db Char_Field_ASCIIZ ;an000;left align/asciiz/char. | ||
| 329 | db unlim_width ;an000;unlimited width | ||
| 330 | db 00 ;an000;minimum width of 0 | ||
| 331 | db pad_blank ;an000;pad with blank | ||
| 332 | |||
| 333 | num_sub label dword ;an000;line number | ||
| 334 | |||
| 335 | db 11 ;an000;sublist size | ||
| 336 | db 00 ;an000;reserved | ||
| 337 | dd dg:line_num ;an000;pointer to parameter | ||
| 338 | db 01 ;an000;parm 1 | ||
| 339 | db Right_Align+Unsgn_Bin_Word ;an000;right align/decimal | ||
| 340 | db 08 ;an000;maximum width | ||
| 341 | db 08 ;an000;minimum width of 0 | ||
| 342 | db pad_blank ;an000;pad with blank | ||
| 343 | |||
| 344 | db 11 ;an000;optional flag | ||
| 345 | db 00 ;an000;reserved | ||
| 346 | dd dg:line_flag ;an000;pointer to parameter | ||
| 347 | db 02 ;an000;parm 2 | ||
| 348 | db Char_Field_Char ;an000;character | ||
| 349 | db 01 ;an000;minimum width of 1 | ||
| 350 | db 01 ;an000;maximum width of 1 | ||
| 351 | db pad_blank ;an000;pad with blank | ||
| 352 | |||
| 353 | BAK_Sub label dword ;an000;line output buffer | ||
| 354 | |||
| 355 | db 11 ;an000;sublist size | ||
| 356 | db 00 ;an000;reserved | ||
| 357 | dd dg:Temp_Path ;an000;pointer to parameter | ||
| 358 | db 00 ;an000;parm 0 | ||
| 359 | db Char_Field_ASCIIZ ;an000;left align/asciiz/char. | ||
| 360 | db unlim_width ;an000;unlimited width | ||
| 361 | db 00 ;an000;minimum width of 0 | ||
| 362 | db pad_blank ;an000;pad with blank | ||
| 363 | |||
| 364 | |||
| 365 | ;========================================================================= | ||
| 366 | ; end replaceable parameter sublists | ||
| 367 | ;========================================================================= | ||
| 368 | |||
| 369 | ;======================= TABLE STRUCTURE ================================= | ||
| 370 | ; | ||
| 371 | ; bute 1-2 : message number of message to be displayed | ||
| 372 | ; byte 3 : message type to be used, i.e.;class 1, utility, etc. | ||
| 373 | ; byte 4-5 : display handle, i.e.; console, printer, etc. | ||
| 374 | ; byte 6-7 : pointer to substitution list, if any. | ||
| 375 | ; byte 8-9 : number of replaceable parameters, if any. | ||
| 376 | ; byte 10 : type of input from keyboard, if any. | ||
| 377 | ; byte 11-12: pointer to buffer for keyboard input, if any. | ||
| 378 | ; | ||
| 379 | ;========================================================================= | ||
| 380 | |||
| 381 | |||
| 382 | bad_vers_err label word ;an000;"Incorrect DOS version" | ||
| 383 | dw 0001 ;an000;message number | ||
| 384 | db UTILITY_MSG_CLASS ;an000;utility message | ||
| 385 | dw stdout ;an000;display handle | ||
| 386 | dw 00 ;an000;no sublist | ||
| 387 | dw 00 ;an000;no sub | ||
| 388 | db no_input ;an000;no keyboard input | ||
| 389 | dw 00 ;an000;no keyboard buffer | ||
| 390 | |||
| 391 | prompt_ptr label word ;an000;"*",0 | ||
| 392 | dw 0006 ;an000;message number | ||
| 393 | db UTILITY_MSG_CLASS ;an000;utility message | ||
| 394 | dw stdout ;an000;display handle | ||
| 395 | dw 00 ;an000;no sublist | ||
| 396 | dw 00 ;an000;no sub | ||
| 397 | db no_input ;an000;no keyboard input | ||
| 398 | dw 00 ;an000;no keyboard buffer | ||
| 399 | |||
| 400 | |||
| 401 | baddrv_ptr label word ;an000;"Invalid drive or file name" | ||
| 402 | ;an000;,0d,0a,0 | ||
| 403 | dw 0007 ;an000;message number | ||
| 404 | db UTILITY_MSG_CLASS ;an000;utility message | ||
| 405 | dw stdout ;an000;display handle | ||
| 406 | dw 00 ;an000;no sublist | ||
| 407 | dw 00 ;an000;no sub | ||
| 408 | db no_input ;an000;no keyboard input | ||
| 409 | dw 00 ;an000;no keyboard buffer | ||
| 410 | |||
| 411 | ndname_ptr label word ;an000;"File name must be | ||
| 412 | ;an000;specified",0d,0a,0 | ||
| 413 | dw 0008 ;an000;message number | ||
| 414 | db UTILITY_MSG_CLASS ;an000;utility message | ||
| 415 | dw stdout ;an000;display handle | ||
| 416 | dw 00 ;an000;no sublist | ||
| 417 | dw 00 ;an000;no sub | ||
| 418 | db no_input ;an000;no keyboard input | ||
| 419 | dw 00 ;an000;no keyboard buffer | ||
| 420 | |||
| 421 | opt_err_ptr label word ;an000;"Invalid parameter",0d,0a,0 | ||
| 422 | dw 0010 ;an000;message number | ||
| 423 | db Parse_Err_Class ;an000;utility message | ||
| 424 | dw StdErr ;an000;display handle | ||
| 425 | dw 00 ;an000;no sublist | ||
| 426 | dw 00 ;an000;no sub | ||
| 427 | db no_input ;an000;no keyboard input | ||
| 428 | dw 00 ;an000;no keyboard buffer | ||
| 429 | |||
| 430 | ro_err_ptr label word ;an000;"File is READ-ONLY",0d,0a,0 | ||
| 431 | dw 0010 ;an000;message number | ||
| 432 | db UTILITY_MSG_CLASS ;an000;utility message | ||
| 433 | dw stdout ;an000;display handle | ||
| 434 | dw 00 ;an000;no sublist | ||
| 435 | dw 00 ;an000;no sub | ||
| 436 | db no_input ;an000;no keyboard input | ||
| 437 | dw 00 ;an000;no keyboard buffer | ||
| 438 | |||
| 439 | bcreat_ptr label word ;an000;"File Creation Error",0d,0a,0 | ||
| 440 | dw 0011 ;an000;message number | ||
| 441 | db UTILITY_MSG_CLASS ;an000;utility message | ||
| 442 | dw stdout ;an000;display handle | ||
| 443 | dw 00 ;an000;no sublist | ||
| 444 | dw 00 ;an000;no sub | ||
| 445 | db no_input ;an000;no keyboard input | ||
| 446 | dw 00 ;an000;no keyboard buffer | ||
| 447 | |||
| 448 | too_many_ptr label word ;an000;"Too many files open",0d,0a,0 | ||
| 449 | dw 0012 ;an000;message number | ||
| 450 | db UTILITY_MSG_CLASS ;an000;utility message | ||
| 451 | dw stdout ;an000;display handle | ||
| 452 | dw 00 ;an000;no sublist | ||
| 453 | dw 00 ;an000;no sub | ||
| 454 | db no_input ;an000;no keyboard input | ||
| 455 | dw 00 ;an000;no keyboard buffer | ||
| 456 | |||
| 457 | read_err_ptr label word ;an000;"Read error in:", | ||
| 458 | ;an000;0d,0a,"%1",0d,0a,0 | ||
| 459 | dw 0013 ;an000;message number | ||
| 460 | db UTILITY_MSG_CLASS ;an000;utility message | ||
| 461 | dw stdout ;an000;display handle | ||
| 462 | dw dg:ed_read_sub ;an000;point to sublist | ||
| 463 | dw 0001 ;an000;1 sub | ||
| 464 | db no_input ;an000;no keyboard input | ||
| 465 | dw 00 ;an000;no keyboard buffer | ||
| 466 | |||
| 467 | |||
| 468 | nobak_ptr label word ;an000;"Cannot edit .BAK file | ||
| 469 | ;an000;--rename file",0d,0a,0 | ||
| 470 | dw 0014 ;an000;message number | ||
| 471 | db UTILITY_MSG_CLASS ;an000;utility message | ||
| 472 | dw stdout ;an000;display handle | ||
| 473 | dw 00 ;an000;no sublist | ||
| 474 | dw 00 ;an000;no sub | ||
| 475 | db no_input ;an000;no keyboard input | ||
| 476 | dw 00 ;an000;no keyboard buffer | ||
| 477 | |||
| 478 | nodir_ptr label word ;an000;"No room in directory | ||
| 479 | ;an000;for file",0d,0d,0 | ||
| 480 | dw 0015 ;an000;message number | ||
| 481 | db UTILITY_MSG_CLASS ;an000;utility message | ||
| 482 | dw stdout ;an000;display handle | ||
| 483 | dw 00 ;an000;no sublist | ||
| 484 | dw 00 ;an000;no sub | ||
| 485 | db no_input ;an000;no keyboard input | ||
| 486 | dw 00 ;an000;no keyboard buffer | ||
| 487 | |||
| 488 | dskful_ptr label word ;an000;"Disk full. Edits lost.",0d,0a,0 | ||
| 489 | dw 0016 ;an000;message number | ||
| 490 | db UTILITY_MSG_CLASS ;an000;utility message | ||
| 491 | dw stdout ;an000;display handle | ||
| 492 | dw 00 ;an000;no sublist | ||
| 493 | dw 00 ;an000;no sub | ||
| 494 | db no_input ;an000;no keyboard input | ||
| 495 | dw 00 ;an000;no keyboard buffer | ||
| 496 | |||
| 497 | memful_ptr label word ;an000;"Insufficient memory",0d,0a,0 | ||
| 498 | dw 0008 ;an000;message number | ||
| 499 | db Ext_Err_Class ;an000;extended error | ||
| 500 | dw stderr ;an000;display handle | ||
| 501 | dw 00 ;an000;no sublist | ||
| 502 | dw 00 ;an000;no sub | ||
| 503 | db no_input ;an000;no keyboard input | ||
| 504 | dw 00 ;an000;no keyboard buffer | ||
| 505 | |||
| 506 | filenm_ptr label word ;an000;"File not found",0d,0a | ||
| 507 | dw 0002 ;an000;message number | ||
| 508 | db Ext_Err_Class ;an000;utility message | ||
| 509 | dw stderr ;an000;display handle | ||
| 510 | dw 00 ;an000;no sublist | ||
| 511 | dw 00 ;an000;no sub | ||
| 512 | db no_input ;an000;no keyboard input | ||
| 513 | dw 00 ;an000;no keyboard buffer | ||
| 514 | |||
| 515 | badcom_ptr label word ;an000;"Entry error",0d,0a,0 | ||
| 516 | dw 0018 ;an000;message number | ||
| 517 | db UTILITY_MSG_CLASS ;an000;utility message | ||
| 518 | dw stdout ;an000;display handle | ||
| 519 | dw 00 ;an000;no sublist | ||
| 520 | dw 00 ;an000;no sub | ||
| 521 | db no_input ;an000;no keyboard input | ||
| 522 | dw 00 ;an000;no keyboard buffer | ||
| 523 | |||
| 524 | newfil_ptr label word ;an000;"New file",0d,0a,0 | ||
| 525 | dw 0019 ;an000;message number | ||
| 526 | db UTILITY_MSG_CLASS ;an000;utility message | ||
| 527 | dw stdout ;an000;display handle | ||
| 528 | dw 00 ;an000;no sublist | ||
| 529 | dw 00 ;an000;no sub | ||
| 530 | db no_input ;an000;no keyboard input | ||
| 531 | dw 00 ;an000;no keyboard buffer | ||
| 532 | |||
| 533 | nosuch_ptr label word ;an000;"Not found",0d,0a,0 | ||
| 534 | dw 0020 ;an000;message number | ||
| 535 | db UTILITY_MSG_CLASS ;an000;utility message | ||
| 536 | dw stdout ;an000;display handle | ||
| 537 | dw 00 ;an000;no sublist | ||
| 538 | dw 00 ;an000;no sub | ||
| 539 | db no_input ;an000;no keyboard input | ||
| 540 | dw 00 ;an000;no keyboard buffer | ||
| 541 | |||
| 542 | ask_ptr label word ;an000;"O.K.? ",0 | ||
| 543 | dw 0021 ;an000;message number | ||
| 544 | db UTILITY_MSG_CLASS ;an000;utility message | ||
| 545 | dw stdout ;an000;display handle | ||
| 546 | dw 00 ;an000;no sublist | ||
| 547 | dw 00 ;an000;no sub | ||
| 548 | db DOS_KEYB_INP ;an000;keyboard input - AX | ||
| 549 | dw 00 ;an000;no keyboard buffer | ||
| 550 | |||
| 551 | toolng_ptr label word ;an000;"Line too long",0d,0a,0 | ||
| 552 | dw 0022 ;an000;message number | ||
| 553 | db UTILITY_MSG_CLASS ;an000;utility message | ||
| 554 | dw stdout ;an000;display handle | ||
| 555 | dw 00 ;an000;no sublist | ||
| 556 | dw 00 ;an000;no sub | ||
| 557 | db no_input ;an000;no keyboard input | ||
| 558 | dw 00 ;an000;no keyboard buffer | ||
| 559 | |||
| 560 | eof_ptr label word ;an000;"End of input file",0d,0a,0 | ||
| 561 | dw 0023 ;an000;message number | ||
| 562 | db UTILITY_MSG_CLASS ;an000;utility message | ||
| 563 | dw stdout ;an000;display handle | ||
| 564 | dw 00 ;an000;no sublist | ||
| 565 | dw 00 ;an000;no sub | ||
| 566 | db no_input ;an000;no keyboard input | ||
| 567 | dw 00 ;an000;no keyboard buffer | ||
| 568 | |||
| 569 | qmes_ptr label word ;an000;"Abort edit (Y/N)? ",0 | ||
| 570 | dw 0024 ;an000;message number | ||
| 571 | db UTILITY_MSG_CLASS ;an000;utility message | ||
| 572 | dw stdout ;an000;display handle | ||
| 573 | dw 00 ;an000;no sublist | ||
| 574 | dw 00 ;an000;no sub | ||
| 575 | db DOS_KEYB_INP ;an000;keyboard input - AX | ||
| 576 | dw 00 ;an000;no keyboard buffer | ||
| 577 | |||
| 578 | dest_ptr label word ;an000;"Must specify destination | ||
| 579 | ;an000;line number",0d,0a,0 | ||
| 580 | dw 0025 ;an000;message number | ||
| 581 | db UTILITY_MSG_CLASS ;an000;utility message | ||
| 582 | dw stdout ;an000;display handle | ||
| 583 | dw 00 ;an000;no sublist | ||
| 584 | dw 00 ;an000;no sub | ||
| 585 | db no_input ;an000;no keyboard input | ||
| 586 | dw 00 ;an000;no keyboard buffer | ||
| 587 | |||
| 588 | mrgerr_ptr label word ;an000;"Not enough room to | ||
| 589 | ;an000;merge the entire file",0d,0a,0 | ||
| 590 | dw 0026 ;an000;message number | ||
| 591 | db UTILITY_MSG_CLASS ;an000;utility message | ||
| 592 | dw stdout ;an000;display handle | ||
| 593 | dw 00 ;an000;no sublist | ||
| 594 | dw 00 ;an000;no sub | ||
| 595 | db no_input ;an000;no keyboard input | ||
| 596 | dw 00 ;an000;no keyboard buffer | ||
| 597 | |||
| 598 | crlf_ptr label word ;an000;0d,0a,0 | ||
| 599 | dw 0027 ;an000;message number | ||
| 600 | db UTILITY_MSG_CLASS ;an000;utility message | ||
| 601 | dw stdout ;an000;display handle | ||
| 602 | dw 00 ;an000;no sublist | ||
| 603 | dw 00 ;an000;no sub | ||
| 604 | db no_input ;an000;no keyboard input | ||
| 605 | dw 00 ;an000;no keyboard buffer | ||
| 606 | |||
| 607 | lf_ptr label word ;an000;0a,0 | ||
| 608 | dw 0028 ;an000;message number | ||
| 609 | db UTILITY_MSG_CLASS ;an000;utility message | ||
| 610 | dw stdout ;an000;display handle | ||
| 611 | dw 00 ;an000;no sublist | ||
| 612 | dw 00 ;an000;no sub | ||
| 613 | db no_input ;an000;no keyboard input | ||
| 614 | dw 00 ;an000;no keyboard buffer | ||
| 615 | |||
| 616 | cont_ptr label word ;an000;"Continue (Y/N)?" | ||
| 617 | dw 0029 ;an000;message number | ||
| 618 | db UTILITY_MSG_CLASS ;an000;utility message | ||
| 619 | dw stdout ;an000;display handle | ||
| 620 | dw 00 ;an000;no sublist | ||
| 621 | dw 00 ;an000;no sub | ||
| 622 | db DOS_KEYB_INP ;an000;keyboard input | ||
| 623 | dw 00 ;an000;no keyboard buffer | ||
| 624 | |||
| 625 | arg_buf_ptr label word ;an000;argument buffer for | ||
| 626 | ; line output | ||
| 627 | dw 0031 ;an000;message number | ||
| 628 | db UTILITY_MSG_CLASS ;an000;utility message | ||
| 629 | dw stdout ;an000;display handle | ||
| 630 | dw dg:arg_sub ;an000;argument sublist | ||
| 631 | dw 01 ;an000;1 sub | ||
| 632 | db no_input ;an000;no keyboard input | ||
| 633 | dw 00 ;an000;no keyboard buffer | ||
| 634 | |||
| 635 | line_num_buf_ptr label word ;an000;holds line numbers | ||
| 636 | dw 0032 ;an000;message number | ||
| 637 | db UTILITY_MSG_CLASS ;an000;utility message | ||
| 638 | dw stdout ;an000;display handle | ||
| 639 | dw dg:num_sub ;an000;argument sublist | ||
| 640 | dw 02 ;an000;2 subs | ||
| 641 | db no_input ;an000;no keyboard input | ||
| 642 | dw 00 ;an000;no keyboard buffer | ||
| 643 | |||
| 644 | cp_err_ptr label word ;an000;"Cannot merge - Code page | ||
| 645 | ; mismatch",0d,0a | ||
| 646 | dw 0033 ;an000;message number | ||
| 647 | db UTILITY_MSG_CLASS ;an000;utility message | ||
| 648 | dw stdout ;an000;display handle | ||
| 649 | dw 00 ;an000;no sublist | ||
| 650 | dw 00 ;an000;no subs | ||
| 651 | db no_input ;an000;no keyboard input | ||
| 652 | dw 00 ;an000;no keyboard buffer | ||
| 653 | |||
| 654 | del_bak_ptr label word ;an000;"Access Denied - xxxxxxxx.BAK" | ||
| 655 | dw 0005 ;an000;message number | ||
| 656 | db Ext_Err_Class ;an000;utility message | ||
| 657 | dw stderr ;an000;display handle | ||
| 658 | dw dg:BAK_Sub ;an000;no sublist | ||
| 659 | dw 01 ;an000;no subs | ||
| 660 | db no_input ;an000;no keyboard input | ||
| 661 | dw 00 ;an000;no keyboard buffer | ||
| 662 | |||
| 663 | CONST ENDS | ||
| 664 | END | ||
| 665 | \ No newline at end of file | ||
diff --git a/v4.0/src/CMD/EDLIN/EDLPARSE.ASM b/v4.0/src/CMD/EDLIN/EDLPARSE.ASM new file mode 100644 index 0000000..32f6f4c --- /dev/null +++ b/v4.0/src/CMD/EDLIN/EDLPARSE.ASM | |||
| @@ -0,0 +1,281 @@ | |||
| 1 | |||
| 2 | page 60,132; | ||
| 3 | title EDLPARSE for EDLIN | ||
| 4 | |||
| 5 | |||
| 6 | ;******************* START OF SPECIFICATIONS ***************************** | ||
| 7 | ; | ||
| 8 | ; MODULE NAME: EDLPARSE.SAL | ||
| 9 | ; | ||
| 10 | ; DESCRIPTIVE NAME: PARSES THE EXTERNAL COMMAND LINE FOR EDLIN | ||
| 11 | ; | ||
| 12 | ; FUNCTION: THIS ROUTINE PROVIDES PARSING CAPABILITIES FOR THE | ||
| 13 | ; EXTERNAL COMMAND LINE OF EDLIN. IT PARSES FOR THE PRESENCE | ||
| 14 | ; OF A REQUIRED FILESPEC AND AN OPTIONAL SWITCH (/B). | ||
| 15 | ; | ||
| 16 | ; ENTRY POINT: PARSER_COMMAND | ||
| 17 | ; | ||
| 18 | ; INPUT: DOS COMMAND LINE | ||
| 19 | ; | ||
| 20 | ; EXIT NORMAL: AX = 0FFH - VALID SWITCH AND FILESPEC SPECIFIED | ||
| 21 | ; | ||
| 22 | ; EXIT ERROR: AX NOT= 0FFH - INVALID SWITCH OR NO FILESPEC SPECIFIED | ||
| 23 | ; | ||
| 24 | ; INTERNAL REFERENCES | ||
| 25 | ; | ||
| 26 | ; ROUTINE: PARSER_COMMAND - THIS ROUTINE PARSES FOR THE PRESENCE | ||
| 27 | ; OF THE /B SWITCH AND A FILESPEC. THE | ||
| 28 | ; FILEPSEC IS REQUIRED, WHILE THE SWITCH | ||
| 29 | ; IS OPTIONAL. | ||
| 30 | ; | ||
| 31 | ; EXTERNAL REFERENCES: | ||
| 32 | ; | ||
| 33 | ; ROUTINE: PARSE.ASM - THIS IS THE PARSER CODE. | ||
| 34 | ; | ||
| 35 | ; NOTES: THIS MODULE IS TO BE PREPPED BY SALUT WITH THE "PR" OPTIONS. | ||
| 36 | ; LINK EDLIN+EDLCMD1+EDLCMD2+EDLMES+EDLPARSE | ||
| 37 | ; | ||
| 38 | ; REVISION HISTORY: | ||
| 39 | ; | ||
| 40 | ; AN000 VERSION 4.00 - IMPLEMENTS THE SYSTEM PARSER (SYSPARSE) | ||
| 41 | ; | ||
| 42 | ; COPYRIGHT: "THE IBM PERSONAL COMPUTER EDLIN UTILITY" | ||
| 43 | ; "VERSION 4.00 (C) COPYRIGHT 1988" | ||
| 44 | ; "LICENSED MATERIAL - PROPERTY OF Microsoft" | ||
| 45 | ; | ||
| 46 | ; | ||
| 47 | ;******************** END OF SPECIFICATIONS ****************************** | ||
| 48 | |||
| 49 | |||
| 50 | ;======================= equates for edlparse ============================ | ||
| 51 | |||
| 52 | parse_ok equ 0 ;an000;good parse return | ||
| 53 | parse_command equ 081h ;an000;offset of command line | ||
| 54 | nul equ 0 ;an000;nul | ||
| 55 | fs_flag equ 05h ;an000;filespec found | ||
| 56 | sw_flag equ 03h ;an000;switch found | ||
| 57 | true equ 0ffffh ;an000;true | ||
| 58 | false equ 00h ;an000;false | ||
| 59 | too_many equ 01h ;an000;too many parms | ||
| 60 | |||
| 61 | ;======================= end equates ===================================== | ||
| 62 | |||
| 63 | |||
| 64 | CODE SEGMENT PUBLIC BYTE | ||
| 65 | CODE ENDS | ||
| 66 | |||
| 67 | CONST SEGMENT PUBLIC BYTE | ||
| 68 | CONST ENDS | ||
| 69 | |||
| 70 | cstack segment stack | ||
| 71 | cstack ends | ||
| 72 | |||
| 73 | DATA SEGMENT PUBLIC BYTE | ||
| 74 | |||
| 75 | extrn path_name:byte | ||
| 76 | extrn org_ds:word ;an000; dms; | ||
| 77 | |||
| 78 | public parse_switch_b ;an000;parse switch result | ||
| 79 | public filespec ;an000;actual filespec | ||
| 80 | |||
| 81 | ;======================= input parameters control blocks ================= | ||
| 82 | ; these control blocks are used by sysparse and must be pointed to by | ||
| 83 | ; es:di on invocation. | ||
| 84 | |||
| 85 | public parms ;an000;share parms | ||
| 86 | parms label byte ;an000;parms control block | ||
| 87 | dw dg:parmsx ;an000;point to parms structure | ||
| 88 | db 00h ;an000;no additional delims. | ||
| 89 | |||
| 90 | parmsx label byte ;an000;parameter types | ||
| 91 | db 1,1 ;an000;must have filespec | ||
| 92 | dw dg:fs_pos ;an000;filespec control block | ||
| 93 | db 1 ;an000;max. number of switches | ||
| 94 | dw dg:sw_b ;an000;\b switch control block | ||
| 95 | db 00h ;an000;no keywords | ||
| 96 | |||
| 97 | ;======================= filespec positional tables ====================== | ||
| 98 | |||
| 99 | fs_pos label byte ;an000;filespec positional | ||
| 100 | dw 0200h ;an000;filespec/not optional | ||
| 101 | dw 0001h ;an000;cap | ||
| 102 | dw dg:filespec_res ;an000;filespec result table | ||
| 103 | dw dg:noval ;an000;value list/none | ||
| 104 | db 0 ;an000;no keyword/switch syns. | ||
| 105 | |||
| 106 | filespec_res label byte ;an000;filespec result table | ||
| 107 | parse_fs_res db ? ;an000;must be filespec (05) | ||
| 108 | parse_fs_tag db ? ;an000;item tag | ||
| 109 | parse_fs_syn dw ? ;an000;synonym pointer | ||
| 110 | parse_fs_off dw ? ;an000;offset to filespec | ||
| 111 | parse_fs_seg dw ? ;an000;segment of filespec | ||
| 112 | |||
| 113 | ;======================= switch tables /b ================================ | ||
| 114 | |||
| 115 | sw_b label byte ;an000;/b switch | ||
| 116 | dw 0000h ;an000;no match flags | ||
| 117 | dw 0000h ;an000;no cap | ||
| 118 | dw dg:switch_res ;an000;result buffer | ||
| 119 | dw dg:noval ;an000;value list/none | ||
| 120 | db 1 ;an000;1 switch | ||
| 121 | sw_b_switch db "/B",0 ;an000;/B means ignore CTL-Z | ||
| 122 | |||
| 123 | switch_res label byte ;an000;switch result table | ||
| 124 | parse_sw_res db ? ;an000;must be string (03) | ||
| 125 | parse_sw_tag db ? ;an000;item tag | ||
| 126 | parse_sw_syn dw ? ;an000;synonym pointer | ||
| 127 | parse_sw_ptr dd ? ;an000;pointer to result | ||
| 128 | |||
| 129 | noval label byte ;an000;value table | ||
| 130 | db 0 ;an000;no values | ||
| 131 | |||
| 132 | |||
| 133 | ;======================= end input parameter control blocks ============== | ||
| 134 | |||
| 135 | filespec db 128 dup (0) ;an000;holds filespec | ||
| 136 | parse_switch_b db ? ;an000;hold boolean result | ||
| 137 | ; of /b parse | ||
| 138 | parse_sw_b db "/B" ;an000;comparison switch | ||
| 139 | |||
| 140 | DATA ENDS | ||
| 141 | |||
| 142 | DG GROUP CODE,CONST,cstack,DATA | ||
| 143 | |||
| 144 | code segment public byte ;an000;code segment | ||
| 145 | assume cs:dg,ds:dg,es:dg,ss:CStack ;an000; | ||
| 146 | |||
| 147 | public parser_command ;an000;share this routine | ||
| 148 | |||
| 149 | |||
| 150 | |||
| 151 | ;======================= begin main routine ============================== | ||
| 152 | .xlist | ||
| 153 | |||
| 154 | include parse.asm ;an000;parser | ||
| 155 | |||
| 156 | .list | ||
| 157 | |||
| 158 | parser_command proc near ;an000;parse routine | ||
| 159 | |||
| 160 | push es ;an000;save registers | ||
| 161 | push ds ;an000; | ||
| 162 | push di ;an000; | ||
| 163 | push si ;an000; | ||
| 164 | |||
| 165 | mov dg:parse_switch_b,false ;an000;init. to false | ||
| 166 | xor cx,cx ;an000;set cx to 0 | ||
| 167 | xor dx,dx ;an000;set dx to 0 | ||
| 168 | mov di,offset dg:parms ;an000;point to parms | ||
| 169 | mov si,parse_command ;an000;point to ds:81h | ||
| 170 | mov ds,dg:org_ds ;an000;get ds at entry | ||
| 171 | assume ds:nothing ;an000; | ||
| 172 | |||
| 173 | parse_continue: ;an000;loop return point | ||
| 174 | |||
| 175 | call sysparse ;an000;invoke parser | ||
| 176 | cmp ax,parse_ok ;an000;is it a good parse | ||
| 177 | jne parse_end ;an000;continue on good parse | ||
| 178 | push si | ||
| 179 | mov si,dx | ||
| 180 | cmp byte ptr es:[si],fs_flag ;an000;do we have a filespec | ||
| 181 | ; $if e ;an000;yes we do | ||
| 182 | JNE $$IF1 | ||
| 183 | call build_fs ;an000;save filespec | ||
| 184 | ; $else ;an000; | ||
| 185 | JMP SHORT $$EN1 | ||
| 186 | $$IF1: | ||
| 187 | cmp parse_switch_b,true ;an000;see if already set | ||
| 188 | ; $if nz ;an000;if not | ||
| 189 | JZ $$IF3 | ||
| 190 | call val_sw ;an000;see which switch | ||
| 191 | ; $else ;an000; | ||
| 192 | JMP SHORT $$EN3 | ||
| 193 | $$IF3: | ||
| 194 | mov ax,too_many ;an000;set error level | ||
| 195 | jmp parse_end ;an000;exit parser | ||
| 196 | ; $endif ;an000; | ||
| 197 | $$EN3: | ||
| 198 | ; $endif ;an000; | ||
| 199 | $$EN1: | ||
| 200 | |||
| 201 | pop si | ||
| 202 | jmp parse_continue ;an000;continue parsing | ||
| 203 | |||
| 204 | parse_end: ;an000;end parse routine | ||
| 205 | |||
| 206 | pop si ;an000;restore registers | ||
| 207 | pop di ;an000; for return to caller | ||
| 208 | pop ds ;an000; | ||
| 209 | assume ds:dg ;an000; | ||
| 210 | pop es ;an000; | ||
| 211 | |||
| 212 | ret ;an000;return to caller | ||
| 213 | |||
| 214 | parser_command endp ;an000;end parser_command | ||
| 215 | |||
| 216 | |||
| 217 | ;======================= subroutine area ================================= | ||
| 218 | |||
| 219 | |||
| 220 | ;========================================================================= | ||
| 221 | ; build_fs: This routine saves the filespec for use by the calling program. | ||
| 222 | ;========================================================================= | ||
| 223 | |||
| 224 | build_fs proc near ;an000;save filespec | ||
| 225 | |||
| 226 | push ax ;an000;save affected regs. | ||
| 227 | push di ;an000; | ||
| 228 | push si ;an000; | ||
| 229 | push ds ;an000; | ||
| 230 | push es ;an000; | ||
| 231 | |||
| 232 | mov di,offset dg:filespec ;an000;point to filespec buffer | ||
| 233 | lds si,dword ptr es:parse_fs_off ;an000;get offset | ||
| 234 | |||
| 235 | build_cont: ;an000;continue routine | ||
| 236 | |||
| 237 | lodsb ;an000;mov ds:si to al | ||
| 238 | cmp al,nul ;an000;is it end of filespec | ||
| 239 | ; $if nz ;an000;if not | ||
| 240 | JZ $$IF7 | ||
| 241 | stosb ;an000;move byte to filespec | ||
| 242 | jmp build_cont ;an000;continue buffer fill | ||
| 243 | ; $endif ;an000; | ||
| 244 | $$IF7: | ||
| 245 | stosb ;an000;save nul | ||
| 246 | |||
| 247 | pop es ;an000;restore regs | ||
| 248 | pop ds ;an000; | ||
| 249 | pop si ;an000; | ||
| 250 | pop di ;an000; | ||
| 251 | pop ax ;an000; | ||
| 252 | |||
| 253 | ret ;an000;return to caller | ||
| 254 | |||
| 255 | build_fs endp ;an000;end proc | ||
| 256 | |||
| 257 | ;========================================================================= | ||
| 258 | ; val_sw : determines which switch we have. | ||
| 259 | ;========================================================================= | ||
| 260 | |||
| 261 | val_sw proc near ;an000;switch determination | ||
| 262 | |||
| 263 | cmp es:parse_sw_syn,offset es:sw_b_switch ;an000;/B switch? | ||
| 264 | ; $if e ;an000;compare good | ||
| 265 | JNE $$IF9 | ||
| 266 | mov dg:parse_switch_b,true ;an000;signal /B found | ||
| 267 | ; $else ;an000; | ||
| 268 | JMP SHORT $$EN9 | ||
| 269 | $$IF9: | ||
| 270 | mov dg:parse_switch_b,false ;an000;signal /B not found | ||
| 271 | ; $endif ;an000; | ||
| 272 | $$EN9: | ||
| 273 | |||
| 274 | ret ;an000;return to caller | ||
| 275 | |||
| 276 | val_sw endp ;an000;end proc | ||
| 277 | |||
| 278 | |||
| 279 | code ends ;an000;end segment | ||
| 280 | end ;an000; | ||
| 281 | \ No newline at end of file | ||
diff --git a/v4.0/src/CMD/EDLIN/EDLSTDSW.INC b/v4.0/src/CMD/EDLIN/EDLSTDSW.INC new file mode 100644 index 0000000..436f09f --- /dev/null +++ b/v4.0/src/CMD/EDLIN/EDLSTDSW.INC | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | ; SCCSID = @(#)stdsw.asm 1.1 85/04/10 | ||
| 2 | ; Use the switches below to produce the standard Microsoft version or the IBM | ||
| 3 | ; version of the operating system | ||
| 4 | |||
| 5 | |||
| 6 | ;include EDLVERS.INC ;IBM/MSVER/JAPVER switches | ||
| 7 | |||
| 8 | |||
| 9 | WANG EQU FALSE | ||
| 10 | Rainbow EQU FALSE | ||
| 11 | |||
| 12 | |||
| 13 | ; Set this switch to cause DOS to move itself to the end of memory | ||
| 14 | HIGHMEM EQU FALSE | ||
| 15 | |||
| 16 | IF IBM | ||
| 17 | ESCCH EQU 0 ; character to begin escape seq. | ||
| 18 | CANCEL EQU 27 ;Cancel with ESCAPE | ||
| 19 | TOGLPRN EQU TRUE ;One key toggles printer echo | ||
| 20 | ZEROEXT EQU TRUE | ||
| 21 | ELSE | ||
| 22 | IF WANG ;Are we assembling for WANG? | ||
| 23 | ESCCH EQU 1FH ;Yes. Use 1FH for escape character | ||
| 24 | ELSE | ||
| 25 | ESCCH EQU 1BH | ||
| 26 | ENDIF | ||
| 27 | CANCEL EQU "X"-"@" ;Cancel with Ctrl-X | ||
| 28 | TOGLPRN EQU FALSE ;Separate keys for printer echo on | ||
| 29 | ;and off | ||
| 30 | ZEROEXT EQU TRUE | ||
| 31 | ENDIF | ||
| 32 | |||
diff --git a/v4.0/src/CMD/EDLIN/MAKEFILE b/v4.0/src/CMD/EDLIN/MAKEFILE new file mode 100644 index 0000000..d01bbb1 --- /dev/null +++ b/v4.0/src/CMD/EDLIN/MAKEFILE | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | #************************** makefile for cmd\append *************************** | ||
| 2 | |||
| 3 | msg =..\..\messages | ||
| 4 | dos =..\..\dos | ||
| 5 | inc =..\..\inc | ||
| 6 | hinc =..\..\h | ||
| 7 | |||
| 8 | # | ||
| 9 | ####################### dependencies begin here. ######################### | ||
| 10 | # | ||
| 11 | |||
| 12 | all: edlin.com | ||
| 13 | |||
| 14 | edlin.ctl: edlin.skl \ | ||
| 15 | $(msg)\$(COUNTRY).msg \ | ||
| 16 | makefile | ||
| 17 | |||
| 18 | |||
| 19 | edlin.obj: edlin.asm edlequ.asm edlstdsw.inc makefile \ | ||
| 20 | $(inc)\dossym.inc \ | ||
| 21 | $(inc)\dosmac.inc $(inc)\bpb.inc $(inc)\buffer.inc \ | ||
| 22 | $(inc)\sysvar.inc $(inc)\mult.inc $(inc)\dirent.inc \ | ||
| 23 | $(inc)\dpb.inc $(inc)\curdir.inc $(inc)\cpmfcb.inc \ | ||
| 24 | $(inc)\find.inc $(inc)\pdb.inc $(inc)\sf.inc $(inc)\arena.inc \ | ||
| 25 | $(inc)\intnat.inc $(inc)\error.inc $(inc)\syscall.inc | ||
| 26 | |||
| 27 | edlcmd1.obj: edlcmd1.asm edlequ.asm edlstdsw.inc makefile \ | ||
| 28 | $(inc)\dossym.inc \ | ||
| 29 | $(inc)\dosmac.inc $(inc)\bpb.inc $(inc)\buffer.inc \ | ||
| 30 | $(inc)\sysvar.inc $(inc)\mult.inc $(inc)\dirent.inc \ | ||
| 31 | $(inc)\dpb.inc $(inc)\curdir.inc $(inc)\cpmfcb.inc \ | ||
| 32 | $(inc)\find.inc $(inc)\pdb.inc $(inc)\sf.inc $(inc)\arena.inc \ | ||
| 33 | $(inc)\intnat.inc $(inc)\error.inc $(inc)\syscall.inc | ||
| 34 | |||
| 35 | edlcmd2.obj: edlcmd2.asm edlequ.asm edlstdsw.inc makefile \ | ||
| 36 | $(inc)\dossym.inc \ | ||
| 37 | $(inc)\dosmac.inc $(inc)\bpb.inc $(inc)\buffer.inc \ | ||
| 38 | $(inc)\sysvar.inc $(inc)\mult.inc $(inc)\dirent.inc \ | ||
| 39 | $(inc)\dpb.inc $(inc)\curdir.inc $(inc)\cpmfcb.inc \ | ||
| 40 | $(inc)\find.inc $(inc)\pdb.inc $(inc)\sf.inc $(inc)\arena.inc \ | ||
| 41 | $(inc)\intnat.inc $(inc)\error.inc $(inc)\syscall.inc | ||
| 42 | |||
| 43 | edlmes.obj: edlmes.asm $(inc)\sysmsg.inc makefile \ | ||
| 44 | edlin.ctl \ | ||
| 45 | edlin.cla \ | ||
| 46 | edlin.clb \ | ||
| 47 | edlin.cl1 \ | ||
| 48 | edlin.cl2 \ | ||
| 49 | |||
| 50 | edlparse.obj: edlparse.asm $(inc)\parse.asm makefile | ||
| 51 | |||
| 52 | edlin.com: edlin.obj edlcmd1.obj edlcmd2.obj edlmes.obj edlparse.obj \ | ||
| 53 | edlin.lnk makefile | ||
| 54 | link @edlin.lnk | ||
| 55 | convert edlin.exe | ||
| 56 | del edlin.exe | ||