Keypad Mapping

A.C. Wright 6502
KIM Keypad · KC Monitor
The pad
ESC$10INS$11PGUP$12A$13
$14DEL$15PGDN$16B$17
7$078$089$09C$0F
4$045$056$06D$0E
1$012$023$03E$0D
$000$0A$0BF$0C
Twenty-four keys, and every one of them is a number underneath: the encoder hands the PIA a five-bit code, $00 to $17, and the monitor decides what it means.
What each key does
KeyFunction
0 – FShift a hex digit in — into the address while navigating, into the byte while editing
◄ / ►Step the address back or on by one
PGUP / PGDNStep the address by $0100
INSSwitch between reading memory and editing it
DELWrite $00 at the current address
Run the code at the current address. It comes back on RTS
ESCStop a running program and return to the monitor
Every code, in order
CodePA4…PA0KeyLCDHex value
$000 0 0 0 0<
$010 0 0 0 1111
$020 0 0 1 0222
$030 0 0 1 1333
$040 0 1 0 0444
$050 0 1 0 1555
$060 0 1 1 0666
$070 0 1 1 1777
$080 1 0 0 0888
$090 1 0 0 1999
$0A0 1 0 1 0000
$0B0 1 0 1 1>
$0C0 1 1 0 0FF15
$0D0 1 1 0 1EE14
$0E0 1 1 1 0DD13
$0F0 1 1 1 1CC12
$101 0 0 0 0ESC*
$111 0 0 0 1INSI
$121 0 0 1 0PGUPU
$131 0 0 1 1AA10
$141 0 1 0 0^
$151 0 1 0 1DELX
$161 0 1 1 0PGDNN
$171 0 1 1 1BB11
The code is not the value. Nowhere do the two line up: key 0 is code $0A, and C to F run backwards — $0C is F and $0F is C. The encoder numbers the switches in the order they sit on the board, and the firmware's lookup table turns that into a digit. Read a code off the bus and you must look it up; there is no arithmetic that gets you there.
How a press gets to the CPU
An MM74C922 encoder scans the pad — sixteen keys natively, extended to twenty-four with a 74HC00 — and raises data-available on the PIA's CA1. That fires an interrupt, the handler reads the five-bit code off PA0PA4, and CA2 drops the encoder's output enable again. So no press is ever missed, and the monitor is never sitting in a polling loop.
The same 65C21 PIA drives the LCD: Port A's top three lines are RS, R/W and E, and Port B is the display's data bus.