[1] Reads a line from the keyboard and places it in a user-designated buffer. The characters are echoed to the display.
[2.0+] Reads a string of bytes from the standard input device, up to and including an ASCII carriage return (0DH), and places them in a user-designated buffer. The characters are echoed to the standard output device. Input may be redirected. (If input has been redirected, there is no way to detect EOF.)
Call with:
AH = 0AH
DS:DX = segment:offset of buffer
Returns:
Nothing (data placed in buffer)
Notes:
The buffer used by this function has the following format:
Byte Contents 0 maximum number of characters to read, set by program 1 number of characters actually read (excluding carriage return), set by MS-DOS 2+ string read from keyboard or standard input, terminated by a carriage return (0DH)
If the buffer fills to one fewer than the maximum number of characters it can hold, subsequent input is ignored and the bell is sounded until a carriage return is detected.
This input function is buffered with type-ahead capability, and all of the standard keyboard editing commands are active.
If the standard input is not redirected, and a Ctrl-C is detected at the console, an Int 23H is executed. If the standard input is redirected, a Ctrl-C is detected at the console, and BREAK is ON, an Int 23H is executed.
See Int 21H Functions 01H, 06H, 07H, and 08H for single-character input from the keyboard or standard input device.
[2.0+] You can also read strings from the keyboard by performing a read (Int 21H Function 3FH) using the predefined handle for the standard input (0000H), if it has not been redirected, or a handle obtained by opening the logical device CON.
Example:
Read a string that is a maximum of 80 characters long from the standard input device, placing it in the buffer named buff.
buff db 81 ; maximum length of input
db 0 ; actual length of input
db 81 dup (0) ; actual input placed here
.
.
.
mov ah,0ah ; function number
mov dx,seg buff ; input buffer address
mov ds,dx
mov dx,offset buff
int 21h ; transfer to MS-DOS
.
.
.