HP-21 Wait Loop

You’ll never see a shorter wait loop than this one.

It looks like this:


C:\Test\hp21w>hp21w -d

HP21w Ver 0.01
Copyright 2018 Greg Sydney-Smith

CPU speed is 200 kHz

>>> g
>>> dr
A=0000FFFFFFFFFF D=00000000000000 M1=00000000000000 P= 0
B=21000000000000 E=00000000000000 M2=00000000000000
C=00000000000000 F=00000000000000 S =...3.5..........
>>> dp
00376: if 0 = s 15 then goto 00376
>>>


That’s a one line wait loop.

There is some sense to it. After all, it doesn’t need to check if a mag card is inserted into a card reader (it doesn’t have one). It doesn’t need to check if you’ve switched to PRGM mode (it doesn’t have one). This is one of the few calculators where you can almost make it this simple.

Why almost? Well, there is a small flaw in this loop. It’s easy to miss and, in the same circumstances and at the same time, I probably would have missed it too.

You see, to my amazement, the HP-21 had a software-driven low power display. I really thought this came in much later in the series. The classic series, before this, all had hardware driving the low power display. I’m pretty sure (guess but consistent with the release times) that the HP-21 was the first to move to this.

On the HP-21, all of the dots, except the real one, light up to show low power. I thought of an inverter or an XOR gate somewhere in the logic driving the decimal point line of the display and a voltage sensor driving it. If volts is too low then the output swaps. Dots get displayed where they wouldn’t be, and don’t where they would. It should be easy in hardware but they did it in software (saves some hardware and you already have a processor right there on the printed circuit board).

It’s quite possible that the idea to do it in software came up after the rest of the software, or this loop, had been written.

The obvious problem, now that I’ve mentioned it, is “what about low power?”

The calculator can sit in this loop, waiting for a keypress, until the battery runs out. The calculator is on. The display is on. Power is being consumed; but it only checks the low power situation after it gets out of this loop. If you don’t press a key, you’ll never know that the battery is about to run out.

An interesting aspect of the microcode. It’s not a significant glitch as it would be a rare problem in the real world, and you probably shouldn’t leave your calculator on if you’re not using it (pressing keys). However, it may explain a few occasions where you pressed a key on the real thing, the low power indicator came on, and it died immediately afterward.

The emulator used above is my hp21w. It’s a free download with a 10 year trial period (which restarts if you you move to another computer anytime in the 10 years, and that restarts …). Yes, the intent is for you to just use it.

This article will be part of the HP-21 topic (when I get that page done).

It's only fair to share...Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on StumbleUponDigg thisPin on PinterestEmail this to someone

Leave a Reply

Your email address will not be published. Required fields are marked *