1 advanced features of keyboard processing suthida chaichomchuen [email protected]
TRANSCRIPT
2
Introduction
• Shift status byte• Scan code• Keyboard buffer area
3
INT 21H FUNCTIONS
• 01H : Keyboard input with echo• 06H : Direct console I/O• 07H : Direct keyboard input without echo• 08H : Keyboard input without echo• 0AH : Buffered keyboard input• 0BH : Check keyboard status• 0CH : Clear buffer & invoke function
4
INT 16H FUNCTIONS
• 00H : Read a character• 01H : Determine if character present• 02H : Return current shift status• 05H : Keyboard write• 10H : Read keyboard character• 11H : Determine if character present• 12H : Return current shift status
5
Basic key types
• Standard characters– A-Z, 0-9, Characters: % $ #
• Extended function keys– Program function keys: <F1>, <Shift>+<F1>– Numeric keypad keys with NumLock toggled off: <
Home>, <End>, <Arrows>– <Alt>+alphabetics, <Alt>+program-function keys
• Control keys– <Alt>, <Ctrl>, <Shift>
6
Keyboard shift status
• Segment of data area is 40[0]H• First byte of current keyboard shift status at 4
0:17H• Bits set to 1 indicate following
– 7 : Insert active– 6 : CapsLock state active– 5 : NumLock state active– 4 : ScrollLock state active– 3 : <Alt> pressed– 2 : <Clrt> pressed– 1 : <Left Shift> pressed– 0 : <Right Shift> pressed
7
Keyboard shift status
• Second byte for the enhanced keyboard at 40:18H
• Bits set to 1 indicate following– 7 : Insert pressed– 6 : CapsLock pressed– 5 : NumLock pressed– 4 : ScrollLock pressed– 3 : Ctrl/NumLock (pause) active– 2 : SysReq pressed– 1 : Left Alt pressed– 0 : Left Ctrl pressed
8
INT 21H Function 01H
• Keyboard input with echo• Response to a <Ctrl>+<Break> request• AH = 01H• Value return
– AL <> 0 : ASCII character– AL = 0 : user has pressed an extended function key
• Example– MOV AH,01H– INT 21H
9
INT 21H Function 06H
• Direct console I/O• Input : load 0FFH into DL• Output : load ASCII character into DL• AH = 06H• Example
– MOV AH,06H– INT 21H
10
INT 21H Function 07H
• Direct keyboard input without echo• Not response to a <Ctrl>+<Break> request• AH = 07H• Example
– MOV AH,07H– INT 21H
11
INT 21H Function 08H
• Keyboard input without echo• Work like function 01H• AH = 08H• Example
– MOV AH,08H– INT 21H
12
INT 21H Function 0AH
• Buffered keyboard input• Inability to accept extended function keys• AH = 0AH• Example
– MOV AH,0AH– LEA DX,msg– INT 21H
13
INT 21H Function 0BH
• Check keyboard status• AH = 0BH• Return value to AL
– AL = FFH : character is available– AL = 00H : no character is available
• Example– MOV AH,0BH– INT 21H
14
INT 21H Function 0CH
• Clear keyboard buffer and invoke function• AH = 0CH• AL = required function• Example
– MOV AH,0CH– MOV AL,function– MOV DX,kbarea– INT 21H
15
INT 16H Function 00H
• Read a character• AH = 00H• Example
– MOV AH,00H– INT 16H
16
INT 16H Function 01H
• Determine whether a character is present• AH = 01H• Example
– MOV AH,01H– INT 16H
17
INT 16H Function 02H
• Return the current <Shift> status• AH = 02H• AL = value return• Example
– MOV AH,02H– INT 16H
18
INT 16H Function 05H
• Keyboard write• Insert characters in the keyboard buffer• AH = 05H• CH = load ASCII character• CL = load scan code• Example
– MOV AH,05H– INT 16H
19
INT 16H Function 10H
• Read a keyboard character• AH = 10H• Example
– MOV AH,10H– INT 16H
20
INT 16H Function 10H
• Key pressed– Regular ASCII character
• AL = ASCII character• AH = scan code
– Extended function key• AL = 00H• AH = scan code
– Extended duplicate control key• AL = E0H• AH = scan code
21
INT 16H Function 11H
• Determine whether a character is present• Same as function 01H
– accept the extended functions
• AH = 11H• Example
– MOV AH,11H– INT 16H
22
INT 16H Function 12H
• Return the current keyboard shift status• Similar to function 02H• AH = 12H• Example
– MOV AH,12H– INT 16H