Function 10h works like INT 16h AH=00h (wait for a key, take it, return AL = ASCII and AH = scan code) and 11h like INT 16h AH=01h (ZF = 1 if no key, otherwise AX = the next key, left in the buffer). The difference is what they do with the keys the 101-key keyboard added. The keyboard handler stores those with markers that 00h and 01h remove or filter out for the sake of programs written for the 84-key keyboard; 10h and 11h return them as stored.
| Key | AH=10h / 11h | AH=00h / 01h |
|---|---|---|
| Up, keypad (Num Lock off) | 4800h | 4800h |
| Up, grey arrow block | 48E0h | 4800h |
| Enter, keypad | E00Dh | 1C0Dh |
| / on the keypad | E02Fh | 352Fh |
| F11 / F12 | 8500h / 8600h | dropped |
| Alt+Up, Ctrl+Up, other new combinations | reported | dropped |
E0h in AL marks a grey key; E0h in AH marks a key on the numeric keypad that has a twin in the main block. A program that does not care which copy was pressed treats AL = E0h like AL = 0. The example stores a grey Up and F11, reads them with the enhanced functions, then reads a grey Up the old way:
MOV AH, 05hMOV CX, 48E0h ; the grey Up arrow: scan 48h, E0h for "grey"INT 16hMOV AH, 05hMOV CX, 8500h ; F11: scan 85hINT 16hMOV AH, 11h ; enhanced check: is a key waiting?INT 16h ; ZF = 0, AX = 48E0h, left in the bufferCALL PHEX4MOV DL, " "MOV AH, 02h ; DOS: print the character in DLINT 21hMOV AH, 10h ; enhanced readINT 16h ; 48E0hCALL PHEX4MOV DL, " "MOV AH, 02h ; DOS: print the character in DLINT 21hMOV AH, 10hINT 16h ; 8500h: F11CALL PHEX4MOV DL, " "MOV AH, 02h ; DOS: print the character in DLINT 21hMOV AH, 05h ; the grey arrow once more...MOV CX, 48E0hINT 16hMOV AH, 00h ; ...read the old wayINT 16h ; 4800h: it looks like the keypad arrowCALL PHEX4PHEX4 PROC NEAR ; print AX as four hex digits; keeps every registerPUSH AXMOV AL, AHCALL PHEX2 ; the high byte firstPOP AXCALL PHEX2 ; then the low byteRETPHEX4 ENDPPHEX2 PROC NEAR ; print AL as two hex digits; keeps every registerPUSH AXPUSH CXPUSH DXMOV DH, AL ; keep the byteMOV CL, 4SHR AL, CL ; the high nibbleCALL HEXN1MOV AL, DHAND AL, 0Fh ; the low nibbleCALL HEXN1POP DXPOP CXPOP AXRETHEXN1:ADD AL, "0"CMP AL, "9"JBE HEXN2ADD AL, 7 ; past "9": "A".."F"HEXN2:MOV DL, ALMOV AH, 02hINT 21hRETPHEX2 ENDP
Which to use
On any machine with an enhanced keyboard BIOS (bit 4 of 0040:0096h set, every AT-class PC from the late 1980s, and DOSBox-X) prefer 10h/11h and decide yourself what a grey key means. On an older BIOS these function numbers do nothing useful, so careful programs check that bit first. Do not mix the families on the same keys: 01h removes F11 from the buffer when it sees it, so an 01h check followed by a 10h read can wait for a key that 01h has already thrown away. The matching shift-flag function is INT 16h AH=12h.