Just use the keyboard…

It’s official. I hate computers. Really, I mean it.

Case in point: Pentium II box, Windows 98. Someone plugs a USB pen-drive into the USB port on the back (not knowing that it won’t work anyhow, because 98 needs drivers for such things), the machine freaks out, crashes, and won’t come up. Complains that it cannot load HIMEM.SYS because of something with the A20 line.

After 30 minutes of attempting to get a boot floppy, and trying to boot the machine, we notice that the keyboard isn’t working. It had come unplugged. Plugged it in, rebooted, machine comes up.

I know what you’re saying - “What the hell does the keyboard have to do with HIMEM.SYS?”

I’ll tell you a little story about Backward Compatibility…

Set the WayBack machine for 1984. The place, Armonk, NY. IBM has just released the IBM PC/AT, with Intel’s spiffy new 80286 processor. This screamer ran at 6 MHz, and was capable of addressing 16 MB of RAM, as opposed to the pokey 4.77 MHz of the 8088 in the IBM PC, and it’s maximum addressable memory of 1 MB.

However, IBM’s engineers found a problem. The 80286 had two modes of operation, Real and Protected. In Real mode, the 80286 would act like an 8086 - it would only be able to access 1 MB of memory. But it differed from the 8086 in one important aspect: when a program got to the end of memory in an 8088/8086, the PC (program counter) would just loop around to 0 and keep going. There were actually programs that took advantage of this, although it was clearly the Wrong Thing to do. An 80286 would, instead, raise an exception and halt itself, because the next valid address would be 1MB + 1, which Real Mode was not allowed to access.

IBM’s solution: rather than leave piss-poor programmers out to hang, they put some additional logic in the keyboard controller chip (remember, this is long before the idea of an integrated chipset) that was used to “gate” the A20 line (which was referenced in our wonderful error message).

For the binary impaired: the CPU has pins on it for the address that the CPU wants to talk to, numbered starting with 0. Those pins would be A0-A19 on a machine with 1 MB of addressable space (220 addresses).

So, what IBM did was they ran the A20 line through the keyboard controller. And when a bit was set one way, it would behave normally, so that protected mode could be used (by the not-yet-released OS/2), and set another, it would do something strange.

It would, when A20 went active (signalling that the CPU was, in fact, attempting to “wrap around” the end of real-mode address space), the keyboard controller would clear the exception, set the program counter to 0, and RESET THE CPU, emulating the flaw in the 8088/8086 design to keep a few dozen programs from breaking.

As a result, to this day we are hampered with this bogus hack. At one time, you could actually change the performance of your computer by putting certain brands of keyboards on your system so that the keyboard controller could process the A20 line more often. And this brain-dead hack also leads to today’s problem: unplug the keyboard and the system gets stupid.

Many of the newer PCs don’t do this kind of crap. In fact, a large number of new machines won’t even boot DOS, because they don’t do the A20 trick at all, but that is certainly not going to free us from dealing with it, as computers can last for decades.

Comments are closed.