Ok, solved my own problem. If you bang your head hard enough ...
The first version of Ping worked just fine no matter how hard I abused
the keyboard.
My new timer code is fine. The BIOS of the machine is fine. So what's
the problem? This is the first time since I started this project that I
turned on floating point emulation in the Turbo C++ 3.0 library. Even
though I specified emulation, it is probably trying to be smart and use
an 8087 if it finds one. Which also implies that it is setting the NMI
vector. (I'll verify this later.)
So doing anything on the keyboard on the Jr while the code was running
was enough to trigger an NMI, and the Turbo C++ runtime was probably
trying to figure out what to do with a bogus NMI. Not a happy thing.
The same exact code without the one stinking little floating point calc
works just fine, and I can lay on the keyboard the whole time.
Grrrr ...
On an unrelated note, CLI and STI are not enough to prevent an NMI on
this machine. (Or on any PC for that matter - but on this machine NMIs
are easy to trigger.) I'm wondering if I should make it a habit to
disable NMI if I really am serious about disabling interrupts. In this
particular case, touching the timer while only using CLI and STI is
unsafe because a keypress will touch that exact timer hardware too.
Anytime that an NMI caused by the keyboard might screw up the state of
hardware that you are touching it seems like NMI needs to be disabled.
Unfortunately, there is a lot of BIOS code to handle the keyboard that I
need to read to find out what it might be touching.
Mike