Function 0Ah Buffered Keyboard Input

mov dx, seg Buffer

mov ds, dx

mov dx, offset Buffer ;ds:dx points to buffer for input

mov al, MaxLength

mov byte ptr Buffer[0], al ;maximum amount of input

mov ah, 0Ah ;Buffered Keyboard Input

int 21h

Buffered Keyboard Input (Function 0Ah) reads a string from standard input and echoes it to standard output until a program-defined number of characters is reached or until the user presses the ENTER key.

This function has been superseded by Read File or Device (Function 3Fh).

Parameters

Buffer

Points to the buffer where the string will be returned. The buffer must have the following form:

Offset Contents

00h Specifies the maximum number of characters, including the carriage return, to be copied to the buffer. This value, set by the program, must not exceed 255 (0FFh).
01h Receives the actual number of characters copied to the buffer, not counting the carriage return. The function sets this value.

Bytes from offset 02h up to the end of the buffer receive the typed characters. The entire buffer must be at least two bytes longer than the size specified at offset 00h.

MaxLength

Specifies the maximum length of the input string.

Return Value

The string area of the buffer (starting at the third byte in the buffer) contains the input string, and the second byte of the buffer contains the number of characters read (not counting the carriage return).

Comment

Characters are read from standard input and placed in the buffer, beginning at the third byte, until a carriage-return character (ASCII 0Dh) is read. When the number of characters in the buffer reaches one fewer than the maximum, additional characters read are ignored and a beep character (ASCII 07h) is sent to standard output until a carriage-return character is read.

See Also

Function 3Fh Read File or Device