NEC PC Programmers Reference/PC-98xx Series Programmers Reference/Interrupt 0x18 - Keyboard

The Keyboard BIOS emits an Interrupt 0x9 when key is pressed. Keyboard data may be treated by invoking INT 0x18.

How BIOS Manages Keys

edit

BIOS maintains an array of data ("keyboard status table"), with a bit for each key. When key is down, bit is 1; when up, bit is 0. When key is pressed, index of key in input status array is combined with code for SHIFT status to produce key scan code (which is how programs recognize keys).

PC-98 Keyboard BIOS is IBM-compliant.

List of Key Access Commands

edit
AH Command Purpose Use
0x1 Sense First Key Queries keyboard for keypresses. Returns key at back of buffer. Returns
  • Key scan code to AH
  • JIS code of key to AL
  • BX = 0 if buffer empty; 1 if presses queued.
0x2 Examine Modifier Keys Returns status of key modifiers (SHIFT, CTRL, GRPH, CAPSLOCK, KANA) Returns modifier status byte in AL
  • SHIFT down = b0
  • CAPS = b1
  • KANA = b2
  • GRPH = b3
  • CTRL = b4
0x3 Initialize Keyboard Install built-in keyboard driver interface. Sets aside memory for BIOS use of keyboard; resets uPD8251A.
0x4 Get Key Group Status Queries the keyboard state table for the immediate state of a set of keys. Returns the byte for the key group requested, which in turn can be masked with logical AND to find the state of individual keys.
  • key group number to AL

Returns

  • key group status byte to AH
0x5 Sense Last Key Queries keyboard for keypresses. Returns key at front of buffer. Returns
  • Key scan code to AH
  • JIS code of key to AL
  • BX = 0 if buffer empty; 1 if presses queued.
0x6 Init Keyboard Buffer / Pending Keys Clear Sets up keyboard buffer. Calling this will clear the buffer.
0x7 Handle First Key Get the first key pressed not yet handled and removes it from the buffer.

Returns

  • AH = key scan code
  • AL = JIS code of key
  • BL = key modifiers byte
0x8 Handle Last Key Gets the last key pressed and removes it from the buffer.

Returns

  • AH = key scan code
  • AL = JIS code of key
  • BL = key modifiers byte
0x9 Simulate Key Press Creates a simulated keypress by filling the keyboard buffer with designated data.
  • AL = desired key code
  • BL = modifier keys state byte

Returns

  • Key scan code to AH
  • JIS code of key to AL