, (buf: db 20 dup ('$')),
$-,
. , DOS
0Ah
.
, $- - ,
$ .
.
int 21h AH=0Ah
Buffered STDIN Input
, Enter.
,
3- ,
DS:DX.
, ,
2- .
- DOS,
. 1-
. 1
, 2. 254
255.
, ,
2- .
( ) ,
. ,
.
, .
- Escape .
, ,
, . - Backspace .
, , .
, , ,
.
,
backspacing , 1- ! - F6 (1Ah) .
"^ Z". - F7 .
"^ @". - ctrl Enter (
), ,
.
. EDLIN.EXE,
DOS, ,
, .
- F1 .
- F2 + ... , .
- F3 .
- F4 + ... ,
.
- F5 .
- Escape .
- Delete .
- Insert .
- Backspace .
- Left , Backspace.
- Right , F1.
. Tab -
ASCII 9 (ASCII 32),
, 8.
. ASCII 9.
ctrl C/ctrl Break
.
,
.
1, STDIN.
ORG 256 ;Create .COM program
cld
mov si, msg1
call WriteStringDOS
mov dx, buf
mov ah, 0Ah ;DOS.BufferedInput
int 21h
mov si, msg2
call WriteStringDOS
mov si, buf+2
movzx bx, [si-1] ;Get character count
mov word [si+bx+1], 10 ;Keep CR, append LF and 0
call WriteStringDOS
mov ax, 4C00h ;DOS.TerminateWithExitcode
int 21h
; --------------------------------------
; IN (ds:si) OUT ()
WriteStringDOS:
pusha
jmps .b
.a: mov dl, al
mov ah, 02h ;DOS.DisplayCharacter
int 21h ; -> AL
.b: lodsb
test al, al
jnz .a
popa
ret
; --------------------------------------
buf: db 255, 16, "I'm the template", 13, 255-16-1+2 dup (0)
msg1: db 'Choose color ? ', 0
msg2: db 10, 'You chose ', 0
; --------------------------------------
int 21h AH=3Fh
0 ( BX) ,
Enter. ( 127)
DOS. .
, DS:DX,
, CX. CX
, ,
.
, ,
!
.
, .
, .
ctrl C/ctrl Break
.
,
2a, " ", .
ORG 256 ;Create .COM program
cld
mov si, msg1
call WriteStringDOS
mov dx, buf
mov cx, 127+2 ;Max input is 127 chars + CR + LF
xor bx, bx ;STDIN=0
mov ah, 3Fh ;DOS.ReadFileOrDevice
int 21h ; -> AX CF
jc Exit
mov bx, ax ;Bytes count is less than CX
mov si, msg2
call WriteStringDOS
mov si, buf
mov [si+bx], bh ;Keep CR and LF, append 0 (BH=0)
call WriteStringDOS
Exit: mov ax, 4C00h ;DOS.TerminateWithExitcode
int 21h
; --------------------------------------
; IN (ds:si) OUT ()
WriteStringDOS:
pusha
jmps .b
.a: mov dl, al
mov ah, 02h ;DOS.DisplayCharacter
int 21h ; -> AL
.b: lodsb
test al, al
jnz .a
popa
ret
; --------------------------------------
buf: db 127+2+1 dup (0)
msg1: db 'Choose color ? ', 0
msg2: db 'You chose ', 0
; --------------------------------------
2b, " ", .
ORG 256 ;Create .COM program
cld
mov si, msg1
call WriteStringDOS
mov dx, buf
mov cx, 1
xor bx, bx ;STDIN=0
mov ah, 3Fh ;DOS.ReadFileOrDevice
int 21h ; -> AX CF
jc Exit
mov si, msg2
call WriteStringDOS
mov si, dx ;DX=buf, CX=1, BX=0
Next: mov ah, 3Fh ;DOS.ReadFileOrDevice
int 21h ; -> AX CF
jc Exit
call WriteStringDOS ;Display a single byte
cmp byte [si], 10
jne Next
Exit: mov ax, 4C00h ;DOS.TerminateWithExitcode
int 21h
; --------------------------------------
; IN (ds:si) OUT ()
WriteStringDOS:
pusha
jmps .b
.a: mov dl, al
mov ah, 02h ;DOS.DisplayCharacter
int 21h ; -> AL
.b: lodsb
test al, al
jnz .a
popa
ret
; --------------------------------------
msg1: db 'Choose color ? ', 0
msg2: db 10, 'You chose '
buf: db 0, 0
; --------------------------------------
int 2Fh AX=4810h
DOSKEY Buffered STDIN Input if
DOSKEY.COM TSR. ,
STDIN 0Ah (. ),
DOS,
DOSKEY.
- Up .
- Down .
- F7 .
- Alt F7 .
- ... F8 (), ...
- F9 .
- Alt F10 .
DOS 6.2 128 ,
127 .
, 2-
.
DOS Win95 255 ,
DOSKEY.COM TSR doskey /line:255.
. Win95
, 0Ah.
ctrl C/ctrl Break
.
,
. , ,
DOSKEY, .
!
, ,
.
, ($T)
1- .
.
, COMMAND.COM,
, , .
, ,
. , ,
DOS!
3: DOSKEY.COM.
ORG 256 ;Create .COM program
cld
mov ax, 4800h ;DOSKEY.CheckInstalled
int 2Fh ; -> AL
test al, al
mov si, err1
jz Exit_
Again: mov si, msg1
call WriteStringDOS
mov dx, buf
mov ax, 4810h ;DOSKEY.BufferedInput
int 2Fh ; -> AX
test ax, ax
mov si, err2
jnz Exit_
cmp [buf+1], al ;AL=0
je Again ;Macro expansion needed
mov si, msg2
call WriteStringDOS
mov si, buf+2
movzx bx, [si-1] ;Get character count (is GT 0)
mov word [si+bx+1], 10 ;Keep CR, append LF and 0
Exit_: call WriteStringDOS
Exit: mov ax, 4C00h ;DOS.TerminateWithExitcode
int 21h
; --------------------------------------
; IN (ds:si) OUT ()
WriteStringDOS:
pusha
jmps .b
.a: mov dl, al
mov ah, 02h ;DOS.DisplayCharacter
int 21h ; -> AL
.b: lodsb
test al, al
jnz .a
popa
ret
; --------------------------------------
buf: db 128, 0, 128+2 dup (0)
msg1: db 'Choose color ? ', 0
msg2: db 13, 10, 'You chose ', 0
err1: db 'N/A', 13, 10, 0
err2: db 'Failed', 13, 10, 0
; --------------------------------------
int 21h AH=08h
- 30000 , Qaru , ...
? , :
- , (.) 1-
- , (:) 2
- - (SIMO),
push cx si
push cx push si.