2011/01/30

HP-11C emulator

Some weeks ago, a guy that shares my taste for HP RPN machines sent me a gift: an HP-11C.

Of course, this present came with implicit strings attached; it was a delicate way to request for an HP-11C emulator.

Whatever, once I put my hands on this 11C, I just *had* to write an emulator for it, too. I really miss the scientific operation on 12C and the 11C is a perfect companion: operation is almost exactly the same way, keyboard feels the same, numeric limits the same etc. etc.

So, it is a pleasure to introduce the new 11C emulator, in three flavors: Web, Mac OS X widget and Windows gadget.

The emulator "engine" is still in beta stage; all known bugs have been solved but there may be plenty more. Except by a couple of poetic licenses, any deviation from the real thing's behavior is considered a bug and bug reports are welcome.

This has affected 12C engine as well, as I will explain later.

The real thing

First, let me talk a bit about the real machine. I was surprised by the power of 11C. I had had previous contact with 10C and thought they were the same thing, but 11C is far more powerful.

Actually, the 11C is just the mid-range scientific calculator of the "family", the 15C being the most powerful. 16C was a kind of computer programmer's calculator, and 12C was, of course, the financial. Only the 12C remains in production (with updated insides); all others were manufactured until 1989.

By the way, the 11C came in mint condition, and cells included! Almost unbelievable for a calculator that is at least 23 years old.

The only missing part was the original manual, which is almost mandatory to write a faithful emulator. There are 11C manuals for sale, but they are quite expensive. Fortunately, there is this quick guide from Thimet, that I found here. The guide is terse but covers everything, including programming.

Comparing against 12C, the most shining feature of 11C is the advanced programming. It supports jump/subroutine labels, "vectorized" memory access, advanced loop control opcodes and so on. Typing programs is also easier because it inserts and deletes opcodes, while 12C just does overwrites.

Finally, this 11C in hand feels like having (and driving) a vintage car. I like my 12C's, but I have three of them and I can always buy a brand new unit should they break :)

The engine

The 11C is similar to the 12C in many key points, and their emulators can share most of the code. The problem was, the 12C emulator was literally written in airport lounges to kill time, so it was a mess, there was no unit testing whatsoever, and a refactoring was long overdue.

This refactoring of original 12C took most of the time I spent on the 11C effort. Cleaning up old code is always boring and we end up adding new bugs. The effort paid off when I actually began to implement 11C-only features like sine, cosine, subroutines etc. That part was really pleasant.

In the refactoring process, I found several bugs in 12C. The most shameful was the exponent (EEX) number input: it had been broken for 4 years! Due to this, and due the fact I don't want to maintain old code, the 12C emulators are now using the new engine, too. There is the risk is exposing 'loyal' users of the 12C to unexpected bugs, but that's life.

In current state, it is probably very easy to write emulators for the rest of the "family": 10C, 15C and 16C. I will probably wait for someone to send me real units of them, and then think about extending the emulator once more. But never fear, there is always a delayed flight to bring inspiration :)
blog comments powered by Disqus