A Simulation

In August 2001 three things happened: I found myself with 2 months between commercial projects; I wondered if it was possible to build applications for the desktop and pocket variants of Microsoft's Windows™ from a common code base; I cursed the so-called "programmer's calculator" that I had purchased for my iPAQ Pocket PC. In the ensuing fit of pique I started sketching the design of what would become a huge WOFTAM—a simulation of the HP-16C.

Screenshot of simulator's portrait view

Fast forward to the present. I now have a fairly comprehensive software imitation of the original HP calculator. It's not finished—it probably never will be—but it works and I've been using it on my iPAQ since November 2001. The code is still in "beta". If you're interested you can can have a peek at the revision history here.

The simulation is written in C++ and runs on Windows 98/2000/XP and Pocket PC 2000/2002. Until I get hold of a new Pocket PC (don't hold your breath) the simulator will not run on hand-helds based on the XScale processor.

Breaking News: a user recently suggested that output of my ARM compiler may actually run on XScale-based Pocket PCs. I had assumed that this would not be the case since my compiler is not optimised for the Intel processor. I don't have an XScale-based system so I cannot test this claim. If you have an XScale device, perhaps you could download the PPC package and test it for me.

The desktop variant is built from the same code base and is able to render the two Pocket PC views as well as a view based on a bitmap of the real calculator.

View of desktop variant

The Pocket PC variant has proven to be a real challenge. Microsoft have emasculated their API so they can squeeze their hand-held operating system into a meagre 16 MBytes of ROM. Most notable amongst the expended interfaces are the 2D graphics transformations. Consequently I have had to hand code the landscape view.

View of PPC variant on iPAQ

If you'd like a copy of the simulator, feel free to download it from the links below.

Release Notes

The complete release notes are maintained in the file VERSION.txt which is included in the zip files that are available for download. The current release versions are:

               Desktop:  0.332  8 May 2006
               Pocket PC:  0.332  8 May 2006

The Pocket PC release will often lag a little behind the current desktop build because I use the latter as the primary development target.

Development News

30 April 2006. This weekend I was playing with the code in an essay titled Long Live the HP-16C! by Valentin Albillo (which can be found on his website). This led to the embarrasing discovery that there were two 16C functions that I had not implemented. This has now been corrected. Release 0.331 includes the indirect branch functions GSB I and GTO I.

20 December 2005. I've been using the simulator quite a lot while laying out an IP Address scheme for a client. This revealed a minor bug that I corrected in release 0.329. In the lab I've been working on an ALU implementation that will handle HP's decimal floating point format. Once implemented the simulator will be "binary compatible" with the real calculator.

2 July 2004. With the release of version 0.319 the implementation of the last useful operator is complete. I should be celebrating—indeed I'm quaffing a fine Australian Merlot as I write these words—but the result is a little anti-climactic. I trust you find the recent additions useful or instructive.

Where to next? I'm not sure. A couple of users have made some very useful suggestions. I might down tools for a while and fix any bugs that make themselves known. I remain open to suggestion. If you have any ideas about something you'd really like implemented, drop me a line.

Release Highlights

Version 0.326 adds range checking to the flag manipulation instructions. The implementation is experimental and as such may be changed in a future release. As always, I welcome your feedback.

Version 0.324 adds the capability to preserve the position of the application on the desktop across subsequent invocations. Obviously this feature is meaningless on the PPC. I also corrected a couple of minor bugs. Please review the release notes if you need more details.

Version 0.323 introduces a build for the Hitachi SH3 processor which enables the simulator to run on Pocket PCs powered by that device. This includes the HP Jornada 548. I would like to acknowledge David Brown and Gordon Dyer for testing the trial SH3 build. This release also corrects a subtle bug in the handling of the ON button.

Version 0.319 implements a high-fidelity storage sub-system simulation complete with the f MEM operator. Since this involved an upheaval in several modules, I expect that there will be some (hopefully minor) consequential damage. If you find aberrant behaviour, please send me an email with the details. This release also corrects several long-standing but unnoticed bugs. The full details are in the release notes.

Version 0.310 adds an image loader that can handle compressed bitmaps to the desktop variant. This significant;y reduces the size of the executable file. The extra space this afforded allowed me to incorporate some of the (mainly cosmetic) changes I had made to the classic rendering. I hope you find the new look pleasing and the added functionality useful.

Version 0.303 adds the clipboard paste function. Numbers stored on the clipboard (as text) are interpreted according to the currently selected radix or floating-point mode. The resulting value will be copied to the X register as if it had been recalled from a storage register.

Version 0.300. Pocket PC landscape mode is here! This release features a substantially re-written user interface layer. You can now use the calculator as its designers intended on your Pocket PC. I would really appreciate feedback from PPC owners. It works fine on my iPAQ but it may not do so on all platforms. You can help me make this as portable as possible by sending me an email and letting me know your PPC model and whether it did or didn't work satisfactorily. My address is on the links page.

What version do I have?

It is easy to find out the version you have installed on your system. Selecting Help→About... from the menu bar will display a dialog box that will show the version that you are running. Alternatively, you can use Windows Explorer. Right-click on the executable file and select Properties from the context menu. Click on the Version tab. Complete details will be shown on the property page.

NOTE: the second technique will work for both the desktop and Pocket PC executable files. However you can only view the file's properties with a desktop system's Windows Explorer.


All the files you need for each platform are packaged in a single ZIP file. You will need a utility such as ZIP Reader to unpack them. Installation instructions can be found in the README file, which is included in the package. If you are installing over an earlier version, please review the README-FIRST.txt file, also included in the package, before you install. To begin downloading, click on the appropriate link(s) below.

NOTE: the Pocket PC executable files are not interchangeable. Take care to select the ZIP file that is appropriate for your device. If you are unsure, please ask me.

Windows Desktop Pocket PC (ARM) Pocket PC (SH3)
Runtime (ZIP file) Runtime (ZIP file) Runtime (ZIP file)

Breaking News: it is possible to install and run the simulator on Linux (using WINE). Thank you Wayne Brown for taking the time to experiment and report the result.

If you download the simulator, please keep in mind that I'm actively (but slowly) improving it. Therefore I would prefer that you don't mirror copies (on the web) or share it with your friends and colleagues. Feel free to direct people to this page so they can fetch the most recent version.

If you detect bugs or deficiencies in the simulation, feel free to email me with the details. Please follow the guidelines in the README file when reporting problems. I don't promise to respond to your emails but I will attempt to address any bugs in a timely manner.

Copyright © 2001, 2004-2006  Cameron Paine Valid HTML 4.0!