[1] Clears the type-ahead buffer and then invokes one of the keyboard input functions.
[2.0+] Clears the standard input buffer and then invokes one of the character input functions. Input can be redirected.
Call with:
AH = 0CH
AL = number of input function to be invoked after resetting
buffer (must be 01H, 06H, 07H, 08H, or 0AH)
(if AL = 0AH)
DS:DX = segment:offset of input buffer
Returns:
(if called with AL = 01H, 06H, 07H, or 08H)
AL = 8-bit input data
(if called with AL = 0AH)
Nothing (data placed in buffer)
Notes:
The function exists to allow a program to defeat MS-DOS's type-ahead feature. It discards any characters that are waiting in MS-DOS's internal type-ahead buffer, forcing the specified input function to wait for a character (usually a keyboard entry) that is truly entered after the program's request.
The presence or absence of Ctrl-C checking during execution of this function depends on the function number placed in register AL.
A function number in AL other than 01H, 06H, 07H, 08H, or 0AH simply flushes the input buffer and returns control to the calling program.
Example:
Clear the type-ahead buffer, then wait for a character to be entered, echoing it and then returning it in AL. Store the character in the variable char.
char db 0
.
.
.
mov ah,0ch ; function number
mov al,1 ; subfunction = input char
int 21h ; transfer to MS-DOS
mov char,al ; save character
.
.
.