When I was in CÉGEP, my parents gave me a calculator as a birthday present. An HP-67, it is a programmable RPN calculator. I used it constantly, though it eventually had to retire because I could no longer get replacement battery packs for it, and it couldn’t run off the mains without a working battery pack. Still, I got about 15 years of use out of it. I’ve always preferred RPN calculators, and when I use infix calculators I have to be very careful not to lose my partial results.
I also tend to write HP-67 emulators. I started with a CDA (classic desk accessory) version for my Apple ][GS. I probably still have the sources on my old Apple ][GS, but it’s boxed up in the basement. I did, though, find them still on comp.sources.apple2, more than 20 years after I posted them, so I’ve pulled them out and put them into an archive here. It was compiled with ORCA/C and ORCA/M, the C compiler and assembler commonly used for development on the Apple ][GS.
A few years later, I decided to learn C++, and used the HP-67 emulator as my practice problem. The resulting program, hp67, is one I still use frequently today. Its sources and screenshots are available here. It used to ship with redhat, but I don’t think it’s packaged anymore.
The emulators I wrote are programmable, though it’s now many years since I’ve invoked the programmable mode in hp67. The programming mode in the HP-67 is mostly a keypress recorder, but with simple flow control. The mode supports goto, gosub, and conditional operators that skip over the next program step when the condition is not met. Together, these operations allow the calculator to be programmed to perform more complex, repetitive operations.
Now, I’m going to start doing some development of an hp-67 emulator in Lisp, just to provide some real examples of some of the Lisp features I’ve been describing in these pages. I’ll probably put the sources on github later, for easier access.
We’ll be making use of handlers, macros, a tiny domain-specific language, and other features. I’m an engine writer, I don’t like doing user interface stuff, and have little experience with it, so I’ll be writing my code from the engine outward, but with an eye to plugging in different front-ends. The C++ version of the calculator is an interactive, ncurses-based program, but I may aim for a stream-processing calculator and for a proper GUI version, we’ll see what happens when we get to the front-end.