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/DOS/KSTRIN.ASM | |
| 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/DOS/KSTRIN.ASM')
| -rw-r--r-- | v4.0/src/DOS/KSTRIN.ASM | 690 |
1 files changed, 690 insertions, 0 deletions
diff --git a/v4.0/src/DOS/KSTRIN.ASM b/v4.0/src/DOS/KSTRIN.ASM new file mode 100644 index 0000000..1eeee39 --- /dev/null +++ b/v4.0/src/DOS/KSTRIN.ASM | |||
| @@ -0,0 +1,690 @@ | |||
| 1 | ; SCCSID = @(#)strin.asm 1.2 85/04/18 | ||
| 2 | ; | ||
| 3 | ; Revision history: | ||
| 4 | ; A000 version 4.00 Jan. 1988 | ||
| 5 | ; | ||
| 6 | Break | ||
| 7 | |||
| 8 | ; Inputs: | ||
| 9 | ; DS:DX Point to an input buffer | ||
| 10 | ; Function: | ||
| 11 | ; Fill buffer from console input until CR | ||
| 12 | ; Returns: | ||
| 13 | ; None | ||
| 14 | |||
| 15 | procedure $STD_CON_STRING_INPUT,NEAR ;System call 10 | ||
| 16 | ASSUME DS:NOTHING,ES:NOTHING | ||
| 17 | |||
| 18 | MOV AX,SS | ||
| 19 | MOV ES,AX | ||
| 20 | MOV SI,DX | ||
| 21 | XOR CH,CH | ||
| 22 | LODSW | ||
| 23 | mov cs:Temp_Var,si ;AN000; ; 3/31/KK | ||
| 24 | ; | ||
| 25 | ; AL is the buffer length | ||
| 26 | ; AH is the template length | ||
| 27 | ; | ||
| 28 | OR AL,AL | ||
| 29 | retz ;Buffer is 0 length!!? | ||
| 30 | MOV BL,AH ;Init template counter | ||
| 31 | MOV BH,CH ;Init template counter | ||
| 32 | ; | ||
| 33 | ; BL is the number of bytes in the template | ||
| 34 | ; | ||
| 35 | CMP AL,BL | ||
| 36 | JBE NOEDIT ;If length of buffer inconsistent with contents | ||
| 37 | CMP BYTE PTR [BX+SI],c_CR | ||
| 38 | JZ EDITON ;If CR correctly placed EDIT is OK | ||
| 39 | ; | ||
| 40 | ; The number of chars in the template is >= the number of chars in buffer or | ||
| 41 | ; there is no CR at the end of the template. This is an inconsistant state | ||
| 42 | ; of affairs. Pretend that the template was empty: | ||
| 43 | ; | ||
| 44 | NOEDIT: | ||
| 45 | MOV BL,CH ;Reset buffer | ||
| 46 | EDITON: | ||
| 47 | MOV DL,AL | ||
| 48 | DEC DX ;DL is # of bytes we can put in the buffer | ||
| 49 | ; | ||
| 50 | ; Top level. We begin to read a line in. | ||
| 51 | ; | ||
| 52 | NEWLIN: | ||
| 53 | MOV AL,[CARPOS] | ||
| 54 | MOV [STARTPOS],AL ;Remember position in raw buffer | ||
| 55 | PUSH SI | ||
| 56 | MOV DI,OFFSET DOSGROUP:INBUF ;Build the new line here | ||
| 57 | MOV [INSMODE],CH ;Insert mode off | ||
| 58 | MOV BH,CH ;No chars from template yet | ||
| 59 | MOV DH,CH ;No chars to new line yet | ||
| 60 | call IntCNE0 ;AN000; Get first char 2/17/KK | ||
| 61 | jz SavCh ;AN000; if ZF set then interim character 2/17/KK | ||
| 62 | CMP AL,c_LF ;Linefeed | ||
| 63 | JNZ GOTCH ;Filter out LF so < works | ||
| 64 | ; | ||
| 65 | ; This is the main loop of reading in a character and processing it. | ||
| 66 | ; | ||
| 67 | ; BH is the index of the next byte in the template | ||
| 68 | ; BL is the length of the template | ||
| 69 | ; DH is the number of bytes in the buffer | ||
| 70 | ; DL is the length of the buffer | ||
| 71 | ; | ||
| 72 | entry GETCH | ||
| 73 | call IntCNE0 ;AN000;; 2/17/KK | ||
| 74 | jz SavCh ;AN000;; if ZF set then interim character 2/17/KK | ||
| 75 | GOTCH: | ||
| 76 | ; | ||
| 77 | ; ^F ignored in case BIOS did not flush the input queue. | ||
| 78 | ; | ||
| 79 | CMP AL,"F"-"@" | ||
| 80 | JZ GETCH | ||
| 81 | ; | ||
| 82 | ; If the leading char is the function-key lead byte | ||
| 83 | ; | ||
| 84 | CMP AL,[ESCCHAR] | ||
| 85 | JNZ ARM03 ;AN000;; 2/17/KK | ||
| 86 | Jmp ESCC ;AN000;; 2/17/KK | ||
| 87 | ARM03: ;AN000;; 2/17/KK | ||
| 88 | ; | ||
| 89 | ; Rubout and ^H are both destructive backspaces. | ||
| 90 | ; | ||
| 91 | CMP AL,c_DEL | ||
| 92 | JZ BACKSPJ0 ;AN000; 2/17/KK | ||
| 93 | CMP AL,c_BS | ||
| 94 | JNZ ARM04 ;AN000;; 2/17/KK | ||
| 95 | BACKSPJ0: ;AN000;; 2/17/KK | ||
| 96 | Jmp BACKSPJ ;AN000;; 2/17/KK | ||
| 97 | ARM04: ;AN000;; 2/17/KK | ||
| 98 | ; | ||
| 99 | ; ^W deletes backward once and then backs up until a letter is before the | ||
| 100 | ; cursor | ||
| 101 | ; | ||
| 102 | CMP AL,"W" - "@" | ||
| 103 | ; The removal of the comment characters before the jump statement will | ||
| 104 | ; cause ^W to backup a word. | ||
| 105 | ;*** JZ WordDel | ||
| 106 | NOP | ||
| 107 | NOP | ||
| 108 | CMP AL,"U" - "@" | ||
| 109 | ; The removal of the comment characters before the jump statement will | ||
| 110 | ; cause ^U to clear a line. | ||
| 111 | ;*** JZ LineDel | ||
| 112 | NOP | ||
| 113 | NOP | ||
| 114 | |||
| 115 | ; | ||
| 116 | ; CR terminates the line. | ||
| 117 | ; | ||
| 118 | CMP AL,c_CR | ||
| 119 | JNZ ARM01 ;AN000;; 2/17/KK | ||
| 120 | Jmp ENDLIN ;AN000;; 2/17/KK | ||
| 121 | ARM01: ;AN000;; 2/17/KK | ||
| 122 | ; | ||
| 123 | ; LF goes to a new line and keeps on reading. | ||
| 124 | ; | ||
| 125 | CMP AL,c_LF | ||
| 126 | JNZ ARM00 ;AN000;; 2/17/KK | ||
| 127 | Jmp PHYCRLF ;AN000;; 2/17/KK | ||
| 128 | ARM00: ;AN000;; 2/17/KK | ||
| 129 | ; | ||
| 130 | ; ^X (or ESC) deletes the line and starts over | ||
| 131 | ; | ||
| 132 | CMP AL,[CANCHAR] | ||
| 133 | JNZ SAVCH ;AN000;; 2/13/KK | ||
| 134 | JMP KILNEW ;AN000;; 2/13/KK | ||
| 135 | InterLoop: ;AN000;; 2/17/KK | ||
| 136 | call IntCNE0 ;AN000;; Get another interim character 2/17/KK | ||
| 137 | ; | ||
| 138 | ; Otherwise, we save the input character. | ||
| 139 | ; | ||
| 140 | SAVCH: | ||
| 141 | pushf ;AN000; 2/17/KK | ||
| 142 | CMP DH,DL | ||
| 143 | JAE BUFFUL ; buffer is full. | ||
| 144 | ;----------------------------- Start of DBCS 2/13/KK | ||
| 145 | |||
| 146 | invoke TESTKANJ ;AN000; | ||
| 147 | JZ ISNORM ;AN000; | ||
| 148 | INC DH ;AN000; | ||
| 149 | CMP DH,DL ;AN000; | ||
| 150 | JB GOTROOM ;AN000; | ||
| 151 | DEC DH ;AN000;; No room for second byte | ||
| 152 | call IntCNE0 ;AN000;; Get second byte | ||
| 153 | JMP SHORT BUFFUL ;AN000; | ||
| 154 | ;AN000; | ||
| 155 | GOTROOM: ;AN000; | ||
| 156 | STOSB ;AN000;; Store first byte | ||
| 157 | popf ;AN000; | ||
| 158 | call outchax ;AN000; | ||
| 159 | call IntCNE0 ;AN000;; Get second byte | ||
| 160 | pushf ;AN000; | ||
| 161 | STOSB ;AN000;; Store second byte | ||
| 162 | INC DH ;AN000; | ||
| 163 | popf ;AN000; | ||
| 164 | call outchax ;AN000; | ||
| 165 | jnz ContIn1 ;AN000;; interim character? | ||
| 166 | call InterCheck ;AN000; | ||
| 167 | call InterCheck ;AN000; | ||
| 168 | jmp short InterLoop ;AN000;; not interim skip another check | ||
| 169 | |||
| 170 | ISNORM: | ||
| 171 | ;----------------------------- End of DBCS 2/13/KK | ||
| 172 | STOSB ;AN000; | ||
| 173 | INC DH ;AN000;; increment count in buffer. | ||
| 174 | popf ;AN000;; 2/17/KK | ||
| 175 | invoke BUFOUTx ;AN000;; Print control chars nicely 2/17/KK | ||
| 176 | jnz ContIn1 ;AN000;; 2/17/KK | ||
| 177 | call InterCheck ;AN000;; 2/17/KK | ||
| 178 | jmp short InterLoop ;AN000;; 2/17/KK | ||
| 179 | CONTIN1: ;AN000;; 2/13/KK | ||
| 180 | ;;;CONTIN: ;AN000;; 2/13/KK | ||
| 181 | CMP BYTE PTR [INSMODE],0 | ||
| 182 | JNZ GETCH0 ; insertmode => don't advance template | ||
| 183 | CMP BH,BL | ||
| 184 | JAE GETCH0 ; no more characters in template | ||
| 185 | INC SI ; Skip to next char in template | ||
| 186 | INC BH ; remember position in template | ||
| 187 | |||
| 188 | PUSH AX ; | ||
| 189 | MOV AL,BYTE PTR [SI-1] ;AN000;; 2/13/KK | ||
| 190 | invoke TESTKANJ ;AN000;; 2/13/KK | ||
| 191 | POP AX ;AN000;; 2/13/KK | ||
| 192 | JZ GETCH0 ;AN000;; Wasn't a dual byte 2/13/KK | ||
| 193 | INC SI ;AN000;; Was a dual byte, 2/13/KK | ||
| 194 | INC BH ;AN000;; skip one more 2/13/KK | ||
| 195 | GETCH0: ;AN000;; 2/17/KK | ||
| 196 | JMP GETCH ;AN000;; 2/17/KK | ||
| 197 | |||
| 198 | BACKSPJ: JMP SHORT BACKSP | ||
| 199 | |||
| 200 | BUFFUL: | ||
| 201 | popf ;AN000;; 2/17/KK | ||
| 202 | MOV AL,7 ;AN000;; Bell to signal full buffer | ||
| 203 | invoke OUTT | ||
| 204 | JMP GETCH | ||
| 205 | ; 2/17/KK | ||
| 206 | ; Reduce character count, reduce pointer 2/17/KK | ||
| 207 | ; 2/17/KK | ||
| 208 | InterCheck: ;AN000;; 2/17/KK | ||
| 209 | dec dh ;AN000;; adjust count 2/17/KK | ||
| 210 | dec di ;AN000;; adjust buffer pointer 2/17/KK | ||
| 211 | ret ;AN000;; 2/17/KK | ||
| 212 | |||
| 213 | ESCC: | ||
| 214 | transfer OEMFunctionKey ; let the OEM's handle the key dispatch | ||
| 215 | |||
| 216 | ENDLIN: | ||
| 217 | STOSB ; Put the CR in the buffer | ||
| 218 | invoke OUTT ; Echo it | ||
| 219 | POP DI ; Get start of user buffer | ||
| 220 | MOV [DI-1],DH ; Tell user how many bytes | ||
| 221 | INC DH ; DH is length including CR | ||
| 222 | COPYNEW: | ||
| 223 | SaveReg <DS,ES> | ||
| 224 | RestoreReg <DS,ES> ; XCHG ES,DS | ||
| 225 | MOV SI,OFFSET DOSGROUP:INBUF | ||
| 226 | MOV CL,DH ; set up count | ||
| 227 | REP MOVSB ; Copy final line to user buffer | ||
| 228 | return | ||
| 229 | ; | ||
| 230 | ; Output a CRLF to the user screen and do NOT store it into the buffer | ||
| 231 | ; | ||
| 232 | PHYCRLF: | ||
| 233 | invoke CRLF | ||
| 234 | JMP GETCH | ||
| 235 | |||
| 236 | ; | ||
| 237 | ; Delete the previous line | ||
| 238 | ; | ||
| 239 | LineDel: | ||
| 240 | OR DH,DH | ||
| 241 | JNZ bridge00 ;AN000;; 2/13/KK | ||
| 242 | JMP GetCh ;AN000;; 2/13/KK | ||
| 243 | bridge00: ;AN000;; 2/13/KK | ||
| 244 | Call BackSpace | ||
| 245 | JMP LineDel | ||
| 246 | |||
| 247 | ; | ||
| 248 | ; delete the previous word. | ||
| 249 | ; | ||
| 250 | WordDel: | ||
| 251 | WordLoop: | ||
| 252 | Call BackSpace ; backspace the one spot | ||
| 253 | OR DH,DH | ||
| 254 | JZ GetChJ | ||
| 255 | MOV AL,ES:[DI-1] | ||
| 256 | cmp al,'0' | ||
| 257 | jb GetChj | ||
| 258 | cmp al,'9' | ||
| 259 | jbe WordLoop | ||
| 260 | OR AL,20h | ||
| 261 | CMP AL,'a' | ||
| 262 | JB GetChJ | ||
| 263 | CMP AL,'z' | ||
| 264 | JBE WordLoop | ||
| 265 | GetChJ: | ||
| 266 | JMP GetCh | ||
| 267 | ; | ||
| 268 | ; The user wants to throw away what he's typed in and wants to start over. We | ||
| 269 | ; print the backslash and then go to the next line and tab to the correct spot | ||
| 270 | ; to begin the buffered input. | ||
| 271 | ; | ||
| 272 | entry KILNEW | ||
| 273 | MOV AL,"\" | ||
| 274 | invoke OUTT ;Print the CANCEL indicator | ||
| 275 | POP SI ;Remember start of edit buffer | ||
| 276 | PUTNEW: | ||
| 277 | invoke CRLF ;Go to next line on screen | ||
| 278 | MOV AL,[STARTPOS] | ||
| 279 | invoke TAB ;Tab over | ||
| 280 | JMP NEWLIN ;Start over again | ||
| 281 | |||
| 282 | |||
| 283 | ; | ||
| 284 | ; Destructively back up one character position | ||
| 285 | ; | ||
| 286 | entry BackSp | ||
| 287 | Call BackSpace | ||
| 288 | JMP GetCh | ||
| 289 | |||
| 290 | BackSpace: | ||
| 291 | OR DH,DH | ||
| 292 | JZ OLDBAK ;No chars in line, do nothing to line | ||
| 293 | CALL BACKUP ;Do the backup | ||
| 294 | MOV AL,ES:[DI] ;Get the deleted char | ||
| 295 | invoke TESTKANJ ;AN000;2/13/KK | ||
| 296 | JNZ OLDBAK ;AN000; Was a dual byte, done 2/13/KK | ||
| 297 | CMP AL," " | ||
| 298 | JAE OLDBAK ;Was a normal char | ||
| 299 | CMP AL,c_HT | ||
| 300 | JZ BAKTAB ;Was a tab, fix up users display | ||
| 301 | ;; 9/27/86 fix for ctrl-U backspace | ||
| 302 | CMP AL,"U"-"@" ; ctrl-U is a section symbol not ^U | ||
| 303 | JZ OLDBAK | ||
| 304 | CMP AL,"T"-"@" ; ctrl-T is a paragraphs symbol not ^T | ||
| 305 | JZ OLDBAK | ||
| 306 | ;; 9/27/86 fix for ctrl-U backspace | ||
| 307 | CALL BACKMES ;Was a control char, zap the '^' | ||
| 308 | OLDBAK: | ||
| 309 | CMP BYTE PTR [INSMODE],0 | ||
| 310 | retnz ;In insert mode, done | ||
| 311 | OR BH,BH | ||
| 312 | retz ;Not advanced in template, stay where we are | ||
| 313 | DEC BH ;Go back in template | ||
| 314 | DEC SI | ||
| 315 | ;-------------------------- Start of DBCS 2/13/KK | ||
| 316 | OR BH,BH ;AN000; | ||
| 317 | retz ;AN000;; If we deleted one char and it was the only | ||
| 318 | ;AN000;; one, could not have dual byte | ||
| 319 | ;;;; POP AX ;AN000;; Get start of template | ||
| 320 | ;;;; PUSH AX ;AN000;; Put it back on stack | ||
| 321 | mov ax,cs:Temp_Var ;AN000;; 3/31/KK | ||
| 322 | XCHG AX,SI ;AN000; | ||
| 323 | LOOKDUAL: ;AN000; | ||
| 324 | CMP SI,AX ;AN000; | ||
| 325 | JAE ATLOC ;AN000; | ||
| 326 | PUSH AX ;AN000; | ||
| 327 | MOV AL,BYTE PTR [SI];AN000; | ||
| 328 | invoke TESTKANJ ;AN000; | ||
| 329 | POP AX ;AN000; | ||
| 330 | JZ ONEINC ;AN000; | ||
| 331 | INC SI ;AN000; | ||
| 332 | ONEINC: ;AN000; | ||
| 333 | INC SI ;AN000; | ||
| 334 | JMP SHORT LOOKDUAL ;AN000; | ||
| 335 | ;AN000; | ||
| 336 | ATLOC: ;AN000; | ||
| 337 | retz ;AN000;; Correctly pointing to start of single byte | ||
| 338 | DEC AX ;AN000;; Go back one more to correctly point at start | ||
| 339 | DEC BH ;AN000; ; of dual byte | ||
| 340 | MOV SI,AX ;AN000; | ||
| 341 | return ;AN000; | ||
| 342 | ;-------------------------- End of DBCS 2/13/KK | ||
| 343 | |||
| 344 | BAKTAB: | ||
| 345 | PUSH DI | ||
| 346 | DEC DI ;Back up one char | ||
| 347 | STD ;Go backward | ||
| 348 | MOV CL,DH ;Number of chars currently in line | ||
| 349 | MOV AL," " | ||
| 350 | PUSH BX | ||
| 351 | MOV BL,7 ;Max | ||
| 352 | JCXZ FIGTAB ;At start, do nothing | ||
| 353 | FNDPOS: | ||
| 354 | SCASB ;Look back | ||
| 355 | JNA CHKCNT | ||
| 356 | CMP BYTE PTR ES:[DI+1],9 | ||
| 357 | JZ HAVTAB ;Found a tab | ||
| 358 | DEC BL ;Back one char if non tab control char | ||
| 359 | CHKCNT: | ||
| 360 | LOOP FNDPOS | ||
| 361 | FIGTAB: | ||
| 362 | SUB BL,[STARTPOS] | ||
| 363 | HAVTAB: | ||
| 364 | SUB BL,DH | ||
| 365 | ADD CL,BL | ||
| 366 | AND CL,7 ;CX has correct number to erase | ||
| 367 | CLD ;Back to normal | ||
| 368 | POP BX | ||
| 369 | POP DI | ||
| 370 | JZ OLDBAK ;Nothing to erase | ||
| 371 | TABBAK: | ||
| 372 | invoke BACKMES | ||
| 373 | LOOP TABBAK ;Erase correct number of chars | ||
| 374 | JMP SHORT OLDBAK | ||
| 375 | |||
| 376 | BACKUP: | ||
| 377 | DEC DH ;Back up in line | ||
| 378 | DEC DI | ||
| 379 | ;-------------------------Start of DBCS 2/13/KK | ||
| 380 | OR DH,DH ;AN000; | ||
| 381 | JZ BACKMES ;AN000;; If deleted one and got only, no dual | ||
| 382 | MOV AX,DI ;AN000; | ||
| 383 | MOV DI,OFFSET DOSGROUP:INBUF;AN000; | ||
| 384 | LOOKDUAL2: ;AN000; | ||
| 385 | CMP DI,AX ;AN000; | ||
| 386 | JAE ATLOC2 ;AN000; | ||
| 387 | PUSH AX ;AN000; | ||
| 388 | MOV AL,BYTE PTR ES:[DI] ;AN000; | ||
| 389 | invoke TESTKANJ ;AN000; | ||
| 390 | POP AX ;AN000; | ||
| 391 | JZ ONEINC2 ;AN000; | ||
| 392 | INC DI ;AN000; | ||
| 393 | ONEINC2: ;AN000; | ||
| 394 | INC DI ;AN000; | ||
| 395 | JMP SHORT LOOKDUAL2 ;AN000; | ||
| 396 | ;AN000; | ||
| 397 | ATLOC2: ;AN000; | ||
| 398 | JE BACKMES ;AN000;; Correctly deleted single byte | ||
| 399 | DEC AX ;AN000; Go back one more to correctly delete dual byte | ||
| 400 | DEC DH ;AN000; | ||
| 401 | MOV DI,AX ;AN000; | ||
| 402 | CALL BACKMES ;AN000; | ||
| 403 | ;---------------------------End of DBCS 2/13/KK | ||
| 404 | BACKMES: | ||
| 405 | MOV AL,c_BS ;Backspace | ||
| 406 | invoke OUTT | ||
| 407 | MOV AL," " ;Erase | ||
| 408 | invoke OUTT | ||
| 409 | MOV AL,c_BS ;Backspace | ||
| 410 | JMP OUTT ;Done | ||
| 411 | |||
| 412 | ;User really wants an ESC character in his line | ||
| 413 | entry TwoEsc | ||
| 414 | MOV AL,[ESCCHAR] | ||
| 415 | JMP SAVCH | ||
| 416 | |||
| 417 | ;Copy the rest of the template | ||
| 418 | entry COPYLIN | ||
| 419 | MOV CL,BL ;Total size of template | ||
| 420 | SUB CL,BH ;Minus position in template, is number to move | ||
| 421 | JMP SHORT COPYEACH | ||
| 422 | |||
| 423 | entry CopyStr | ||
| 424 | invoke FINDOLD ;Find the char | ||
| 425 | JMP SHORT COPYEACH ;Copy up to it | ||
| 426 | |||
| 427 | ;Copy one char from template to line | ||
| 428 | entry COPYONE | ||
| 429 | MOV CX,1 ;AN000;; 2/13/KK | ||
| 430 | MOV AL,[SI] ;AN000;; get char 2/13/KK | ||
| 431 | invoke TestKanj ;AN000;; is it kanji? 2/13/KK | ||
| 432 | JZ CopyEach ;AN000;; no, go do copy2/13/KK | ||
| 433 | INC CX ;AN000;; do 2 byte copy2/13/KK | ||
| 434 | |||
| 435 | ;Copy CX chars from template to line | ||
| 436 | COPYEACH: | ||
| 437 | MOV BYTE PTR [INSMODE],0 ;All copies turn off insert mode | ||
| 438 | CMP DH,DL | ||
| 439 | JZ GETCH2 ;At end of line, can't do anything | ||
| 440 | CMP BH,BL | ||
| 441 | JZ GETCH2 ;At end of template, can't do anything | ||
| 442 | LODSB | ||
| 443 | STOSB | ||
| 444 | ;----------------------------- Start of DBCS 2/13/KK | ||
| 445 | INC BH ;AN000;; Ahead in template | ||
| 446 | INC DH ;AN000;; Ahead in line | ||
| 447 | CALL TestKanj ;AN000;; 2 byte character? | ||
| 448 | JZ CopyLoop ;AN000;; no, go copy next | ||
| 449 | CMP DH,DL ;AN000;; over boundary? | ||
| 450 | JNZ CopyBoth ;AN000;; no, move both | ||
| 451 | DEC BH ;AN000;; yes, backup template | ||
| 452 | DEC DH ;AN000;; back up line | ||
| 453 | DEC SI ;AN000;; patch (from Dohhaku) | ||
| 454 | DEC DI ;AN000;; remember to backup after previous move | ||
| 455 | JMP GetCh ;AN000;; go get next char | ||
| 456 | ;AN000; | ||
| 457 | CopyBoth: ;AN000; | ||
| 458 | invoke BUFOUT ;AN000;; output the first byte | ||
| 459 | LODSB ;AN000;; get the second | ||
| 460 | STOSB ;AN000;; move the second | ||
| 461 | INC BH ;AN000;; bump template | ||
| 462 | INC DH ;AN000;; bump line | ||
| 463 | DEC CX ;AN000;; dump byte count | ||
| 464 | CopyLoop: ;AN000; | ||
| 465 | invoke BUFOUT ;AN000; | ||
| 466 | LOOP COPYEACH ;AN000; | ||
| 467 | ;;;;; invoke BUFOUT | ||
| 468 | ;;;;; INC BH ;Ahead in template | ||
| 469 | ;;;;; INC DH ;Ahead in line | ||
| 470 | ;;;;; LOOP COPYEACH | ||
| 471 | ;----------------------------- End of DBCS 2/13/KK | ||
| 472 | GETCH2: | ||
| 473 | JMP GETCH | ||
| 474 | |||
| 475 | ;Skip one char in template | ||
| 476 | entry SKIPONE | ||
| 477 | CMP BH,BL | ||
| 478 | JZ GETCH2 ;At end of template | ||
| 479 | INC BH ;Ahead in template | ||
| 480 | INC SI | ||
| 481 | PUSH AX ;AN000;; 2/13/KK | ||
| 482 | MOV AL,BYTE PTR [SI-1] ;AN000;; 2/13/KK | ||
| 483 | invoke TESTKANJ ;AN000;; 2/13/KK | ||
| 484 | POP AX ;AN000;; 2/13/KK | ||
| 485 | JZ GETCH2 ;AN000;; 2/13/KK | ||
| 486 | INC BH ;AN000;; 2/13/KK | ||
| 487 | INC SI ;AN000;; 2/13/KK | ||
| 488 | JMP GETCH | ||
| 489 | |||
| 490 | entry SKIPSTR | ||
| 491 | invoke FINDOLD ;Find out how far to go | ||
| 492 | ADD SI,CX ;Go there | ||
| 493 | ADD BH,CL | ||
| 494 | JMP GETCH | ||
| 495 | |||
| 496 | ;Get the next user char, and look ahead in template for a match | ||
| 497 | ;CX indicates how many chars to skip to get there on output | ||
| 498 | ;NOTE: WARNING: If the operation cannot be done, the return | ||
| 499 | ; address is popped off and a jump to GETCH is taken. | ||
| 500 | ; Make sure nothing extra on stack when this routine | ||
| 501 | ; is called!!! (no PUSHes before calling it). | ||
| 502 | |||
| 503 | TABLE SEGMENT ;AN000;; 2/17/KK | ||
| 504 | Public KISTR001S,KISTR001E ;AN000;; 2/17/KK | ||
| 505 | KISTR001S label byte ;AN000;; 2/17/KK | ||
| 506 | LOOKSIZ DB 0 ;AN000;; 0 if byte, NZ if word 2/17/KK | ||
| 507 | KISTR001E label byte ;AN000;; 2/17/KK | ||
| 508 | TABLE ENDS ;AN000;; 2/17/KK | ||
| 509 | |||
| 510 | FINDOLD: | ||
| 511 | MOV [LOOKSIZ],0 ;AN000;; Initialize to byte 2/13/KK | ||
| 512 | call IntCNE1 ;AN000;; 2/17/KK | ||
| 513 | CMP AL,[ESCCHAR] ;AN000;; did he type a function key? | ||
| 514 | ;;;;; JNZ FindSetup ;AN000;; no, set up for scan 2/13/KK | ||
| 515 | JNZ TryKanj ;AN000;; no, continue testing 2/13/KK | ||
| 516 | call IntCNE1 ;AN000;; 2/17/KK | ||
| 517 | JMP NotFnd ; go try again | ||
| 518 | ;;;;;;;FindSetup: ;AN000;; 2/13/KK | ||
| 519 | TryKanj: ;AN000;; 2/13/KK | ||
| 520 | invoke TESTKANJ ;AN000;; 2/13/KK | ||
| 521 | JZ GOTLSIZ ;AN000;; 2/13/KK | ||
| 522 | INC [LOOKSIZ] ;AN000;; Gonna look for a word 2/13/KK | ||
| 523 | PUSH AX ;AN000;; Save first byte 2/13/KK | ||
| 524 | call IntCNE1 ;AN000;; 2/17/KK | ||
| 525 | POP CX ;AN000;; 2/13/KK | ||
| 526 | MOV AH,AL ;AN000;; 2/13/KK | ||
| 527 | MOV AL,CL ;AN000;; AX is dual byte sequence to look for | ||
| 528 | XOR CX,CX ;AN000;; Re-zero CH 2/13/KK | ||
| 529 | GOTLSIZ: | ||
| 530 | MOV CL,BL | ||
| 531 | SUB CL,BH ;CX is number of chars to end of template | ||
| 532 | JZ NOTFND ;At end of template | ||
| 533 | DEC CX ;Cannot point past end, limit search | ||
| 534 | JZ NOTFND ;If only one char in template, forget it | ||
| 535 | PUSH AX ;AN000;; 2/13/KK | ||
| 536 | MOV AL,BYTE PTR [SI] ;AN000;; 2/13/KK | ||
| 537 | invoke TESTKANJ ;AN000;; 2/13/KK | ||
| 538 | POP AX ;AN000;; 2/13/KK | ||
| 539 | JZ NOTDUAL5 ;AN000;; 2/13/KK | ||
| 540 | DEC CX ;AN000;; And one more besides 2/13/KK | ||
| 541 | JZ NOTFND ;AN000;; If only one char in template, forget it | ||
| 542 | NOTDUAL5: ;AN000;; 2/13/KK | ||
| 543 | PUSH ES | ||
| 544 | PUSH DS | ||
| 545 | POP ES | ||
| 546 | PUSH DI | ||
| 547 | MOV DI,SI ;Template to ES:DI | ||
| 548 | ;;;; INC DI 2/13/KK | ||
| 549 | ;;;; REPNE SCASB ;Look 2/13/KK | ||
| 550 | ;--------------------- Start of DBCS 2/13/KK | ||
| 551 | PUSH AX ;AN000; | ||
| 552 | MOV AL,BYTE PTR ES:[DI] ;AN000; | ||
| 553 | invoke TESTKANJ ;AN000; | ||
| 554 | POP AX ;AN000; | ||
| 555 | JZ ONEINC5 ;AN000; | ||
| 556 | INC DI ;AN000;; We will skip at least something | ||
| 557 | ONEINC5: ;AN000; | ||
| 558 | INC DI ;AN000; | ||
| 559 | CMP [LOOKSIZ],0 ;AN000; | ||
| 560 | JNZ LOOKWORD ;AN000; | ||
| 561 | LOOKBYTE: ;AN000; | ||
| 562 | PUSH AX ;AN000; | ||
| 563 | MOV AL,BYTE PTR ES:[DI] ;AN000; | ||
| 564 | invoke TESTKANJ ;AN000; | ||
| 565 | POP AX ;AN000; | ||
| 566 | JZ TESTITB ;AN000; | ||
| 567 | INC DI ;AN000; | ||
| 568 | INC DI ;AN000; | ||
| 569 | DEC CX ;AN000; | ||
| 570 | LOOP LOOKBYTE ;AN000; | ||
| 571 | JMP SHORT ATNOTFND ;AN000; | ||
| 572 | ;AN000; | ||
| 573 | TESTITB: ;AN000; | ||
| 574 | DEC CX ;AN000; | ||
| 575 | CMP AL,ES:[DI] ;AN000; | ||
| 576 | JZ ATSPOT ;AN000; | ||
| 577 | INC DI ;AN000; | ||
| 578 | INC CX ;AN000;; Counter next instruction | ||
| 579 | LOOP LOOKBYTE ;AN000; | ||
| 580 | ATNOTFND: ;AN000; | ||
| 581 | XOR AL,AL ;AN000; | ||
| 582 | INC AL ;AN000;; Set NZ | ||
| 583 | ATSPOT: ; 2/13/K;AN000;K | ||
| 584 | ;--------------------- End of DBCS 2/13/KK | ||
| 585 | POP DI | ||
| 586 | POP ES | ||
| 587 | JNZ NOTFND ;Didn't find the char | ||
| 588 | NOT CL ;Turn how far to go into how far we went | ||
| 589 | ADD CL,BL ;Add size of template | ||
| 590 | SUB CL,BH ;Subtract current pos, result distance to skip | ||
| 591 | return | ||
| 592 | |||
| 593 | NOTFND: | ||
| 594 | POP BP ;Chuck return address | ||
| 595 | JMP GETCH | ||
| 596 | ;------------------------- Start of DBCS 2/13/KK | ||
| 597 | LOOKWORD: ;AN000; | ||
| 598 | PUSH AX ;AN000; | ||
| 599 | MOV AL,BYTE PTR ES:[DI] ;AN000; | ||
| 600 | invoke TESTKANJ ;AN000; | ||
| 601 | POP AX ;AN000; | ||
| 602 | JNZ TESTITW ;AN000; | ||
| 603 | INC DI ;AN000; | ||
| 604 | LOOP LOOKWORD ;AN000; | ||
| 605 | JMP SHORT ATNOTFND ;AN000; | ||
| 606 | ;AN000; | ||
| 607 | TESTITW: ;AN000; | ||
| 608 | DEC CX ;AN000; | ||
| 609 | CMP AX,ES:[DI] ;AN000; | ||
| 610 | JZ ATSPOT ;AN000; | ||
| 611 | INC DI ;AN000; | ||
| 612 | INC DI ;AN000; | ||
| 613 | LOOP LOOKWORD ;AN000; ; Performs second DEC of CX | ||
| 614 | JMP SHORT ATNOTFND ;AN000; | ||
| 615 | ;------------------------- End of DBCS 2/13/KK | ||
| 616 | |||
| 617 | entry REEDIT | ||
| 618 | MOV AL,"@" ;Output re-edit character | ||
| 619 | invoke OUTT | ||
| 620 | POP DI | ||
| 621 | PUSH DI | ||
| 622 | PUSH ES | ||
| 623 | PUSH DS | ||
| 624 | invoke COPYNEW ;Copy current line into template | ||
| 625 | POP DS | ||
| 626 | POP ES | ||
| 627 | POP SI | ||
| 628 | MOV BL,DH ;Size of line is new size template | ||
| 629 | JMP PUTNEW ;Start over again | ||
| 630 | |||
| 631 | entry EXITINS | ||
| 632 | entry ENTERINS | ||
| 633 | NOT BYTE PTR [INSMODE] | ||
| 634 | JMP GETCH | ||
| 635 | |||
| 636 | ;Put a real live ^Z in the buffer (embedded) | ||
| 637 | entry CTRLZ | ||
| 638 | MOV AL,"Z"-"@" | ||
| 639 | JMP SAVCH | ||
| 640 | |||
| 641 | ;Output a CRLF | ||
| 642 | entry CRLF | ||
| 643 | MOV AL,c_CR | ||
| 644 | invoke OUTT | ||
| 645 | MOV AL,c_LF | ||
| 646 | JMP OUTT | ||
| 647 | |||
| 648 | EndProc $STD_CON_STRING_INPUT | ||
| 649 | |||
| 650 | ;-------------- Start of DBCS 2/17/KK | ||
| 651 | PUBLIC IntCNE0 ;AN000; | ||
| 652 | procedure IntCNE0,near ;AN000; | ||
| 653 | push word ptr [InterCon] ;AN000; | ||
| 654 | mov [InterCon],01 ;AN000; | ||
| 655 | get_com: ;AN000; | ||
| 656 | invoke INTER_CON_INPUT_NO_ECHO ;AN000;; get a byte character | ||
| 657 | pop word ptr [InterCon] ;AN000; | ||
| 658 | ret ;AN000; | ||
| 659 | IntCNE0 endp ;AN000; | ||
| 660 | ;AN000; | ||
| 661 | procedure IntCNE1,near ;AN000; | ||
| 662 | push word ptr [InterCon] ;AN000; | ||
| 663 | mov [InterCon],00 ;AN000; | ||
| 664 | jmp short get_com ;AN000; | ||
| 665 | IntCNE1 endp ;AN000; | ||
| 666 | ;AN000; | ||
| 667 | procedure outchax,near ;AN000; | ||
| 668 | pushf ;AN000; | ||
| 669 | mov [SaveCurFlg],0 ;AN000; | ||
| 670 | jnz sj1 ;AN000; | ||
| 671 | mov [SaveCurFlg],1 ;AN000; | ||
| 672 | sj1: ;AN000; | ||
| 673 | CALL OUTCHA ;AN000; | ||
| 674 | mov [SaveCurFlg],0 ;AN000; | ||
| 675 | popf ;AN000; | ||
| 676 | ret ;AN000; | ||
| 677 | outchax endp ;AN000; | ||
| 678 | ;AN000; | ||
| 679 | procedure bufoutx,near ;AN000; | ||
| 680 | pushf ;AN000; | ||
| 681 | mov [SaveCurFlg],0 ;AN000; | ||
| 682 | jnz sj2 ;AN000; | ||
| 683 | mov [SaveCurFlg],1 ;AN000; | ||
| 684 | sj2: ;AN000; | ||
| 685 | invoke BUFOUT ;AN000; | ||
| 686 | mov [SaveCurFlg],0 ;AN000; | ||
| 687 | popf ;AN000; | ||
| 688 | ret ;AN000; | ||
| 689 | bufoutx endp ;AN000; | ||
| 690 | ;-------------- End of DBCS 2/17/KK | ||