KBC Commands
Table of Contents

Keyboard Controller Commands
The commands accepted by a PC keyboard controller

This page details just the commands that a PC keyboard controller accepts. To send a command or read some results reliably see the sections on reading and writing the controller in the keyboard controller page.

The Commands

The controller accepts the commands shown in this table. The command itself is sent to port 0x64. Any following bytes of data - represented by X in the table - are sent to port 0x60.

Note that these are commands to the keyboard controller, not those sent to the keyboard or to the mouse.

Command Value AT Architecture PS/2 Architecture Description of Command
0x20 Yes (ph) Yes (ph) Read command byte (ph)
0x20 .. 0x3F Yes (misa) Read internal RAM location (misa)
0x60 X Yes (ph) Yes (ph) Write X to command byte (ph)
0x60 .. 0x7F X Yes (misa) Write X to RAM location (misa)
0xA4 No (ph) Yes (ph) Test if password installed. Result is 0xF1 = no, 0xFA = yes (ph)
0xA5 X…X0 No (ph) Yes (ph) Load password scan codes until a zero byte (ph)
0xA6 No (ph) Yes (ph) Enable the password (ph)
0xA7 No (ph) Yes (ph) Disable the mouse. Sets bit 5 of the command byte (ph)
0xA8 No (ph) Yes (ph) Enable the mouse. Clears bit 5 of the command byte (ph)
0xA9 No (ph) Yes (ph) Test the mouse. Result is
0 -> no error,
1 -> clock stuck low,
2 -> clock stuck high,
3 -> data line stuck low,
4 -> data line stuck high (ph)
Test the mouse clock and data lines (misa)
0xAA Yes (ph) Yes (ph) Self test. Result is 0x55 if no errors (ph)
0xAB Yes (ph) Yes (ph) Test interface (to keyboard?). Result is
0 -> no error,
1 -> clock stuck low,
2 -> clock stuck high,
3 -> data line stuck low,
4 -> data line stuck high (ph)
Test keyboard clock and data lines (misa)
0xAC Yes (ph) No (ph) Diagnostic dump 16 bytes of controller's RAM (ph)
0xAD Yes (ph) Yes (ph) Disable keyboard. Sets bit 4 of the command byte (ph) Disable keyboard interface (misa)
0xAE Yes (ph) Yes (ph) Enable keyboard. Clears bit 4 of the command byte (ph) Enable keyboard interface (misa)
0xC0 Yes (ph) Yes (ph) Read input port (to output buffer) (ph)
0xC1 No (ph) Yes (ph) Input port bits 3 :- 0 to status bits 7 :- 4 (ph)
0xC2 No (ph) Yes (ph) Input port bits 7 :- 4 to status bits 7 :- 4 (ph)
0xD0 Yes (ph) Yes (ph) Read output port (to output buffer) (ph)
0xD1 X Yes (ph) Yes (ph) Write X to output port. Beware not to clear system reset bit 0 (ph)
0xD2 X No (ph) Yes (ph) Write X to output buffer as if sent by the keyboard. An interrupt occurs (ph) Interrupt occurs if the keyboard interface is enabled (misa)
0xD3 X No (ph) Yes (ph) Write X to output buffer as if sent by the mouse. An interrupt occurs (ph) Interrupt occurs if the mouse interface is enabled (misa)
0xD4 X No (ph) Yes (ph) Write X to the mouse (ph)
0xE0 Yes (ph) Yes (ph) Read test inputs T1, T0 to bits 1 and 0 of output buffer (ph) Bits 1 :- 0 get mouse clock and keyboard clock respectively (misa)
0xF0 .. 0xFF Yes (ph) Yes (ph) Pulse output port. Bits 3 :: 0 pulse bits 3 :: 0 of the output port (ph). Ports are pulsed low for approximately six microseconds. A zero says to pulse the bit. A one says not to change it. (misa)

Sources

Sources of information in the table above are

  • (ph) - PC Programmer's Handbook – Second edition
  • (misa) - Mindshare ISA System Architecture
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License