Function 06h Direct Console I/O

mov dl, IOSwitch ;0FFh = read, 00h through 0FEh = write

mov ah, 06h ;Direct Console I/O

int 21h

Direct Console I/O (Function 06h) reads a character from standard input or writes a character to standard output. If no character is available, MS-DOS does not wait. When this function reads a character from standard input; it does not send the character to standard output.

Parameter

IOSwitch

Specifies whether the function is to read from standard input or write to standard output. This parameter can be any value in the range 00h through 0FFh. The values result in the following actions:

Value Action

0FFh Reads a character from standard input; returns immediately if no character is ready.
00–0FEh Writes the character to standard output.

Return Value

If output is requested, this function has no return value.

If input is requested and a character is ready, the AL register contains the character and the zero flag is cleared. If no character is ready, the AL register is undefined and the zero flag is set.

Comments

This function is typically used by programs that must be able to read and write any character or control code.

If the character read from the keyboard is an extended key code (for example, if the user presses one of the function keys), Direct Console I/O returns 00h and the program must call the function again to get the second byte of the extended key code.

This function does not check for CTRL+C.

See Also

Function 02h Display Character
Function 04h Auxiliary Output
Function 05h Print Character
Function 07h Direct Console Input
Function 08h Read Keyboard Without Echo
Function 09h Display String
Function 0Ah Buffered Keyboard Input
Function 0Bh Check Keyboard Status
Function 0Ch Flush Buffer, Read Keyboard
Function 3Fh Read File or Device
Function 40h Write File or Device