What is HP-41X?

It is an HP-41C/CV/CX Extended MicroCode Emulator for HP-48GX and HP-49G calculators. The famous HP-41C/CV/CX vintage calculators are fully recreated because I emulated the real CPU behavior and the emulator executes a code from the real HP-41C/CV/CX ROMs. But calling it just a "emulator" is only one side of the story. I made many enhancements and extensions to the original HP-41C specifications which make HP-41X appear more as a "new" calculator.

Is it based on the HP-41E?

Yes, it is based on my former freeware project called HP-41E (HP-41C/CV MicroCode Emulator for HP-48S/SX/G/G+/GX and HP-49G) which I recently revived. This emulator can be found here.

Important notice: Features described below refer only to the full version - they could be missing from demo version.

What are these enhancements and extensions which make HP-41X unique?

4096 Registers Address Space:

  #000..00F: Status Registers (16)
  #010..0BF: XM Registers (176)
  #0C0..DFF: Program/Data Registers (3392)
  #E00:      Scratch Register (1)
  #E01..EFF: XM Registers (255)
  #F00:      Scratch Register (1)
  #F01..FFF: XM Registers (255)

Yes, this is true, you have 16 status registers, 3392 Program/Data registers (3391 free) and 686 Extended Memory registers (680 free) for use in your programs. The emulator engine is changed to support this as well as some parts of the HP-41C firmware. You can execute SIZE 1999 without problem to allocate space for data and have 1393 free registers left for the program. You can even execute PSIZE with 3391 in the X register. After MEMORY LOST, 320 registers are allocated for programs and the rest is free for data.

Of course, STO IND, RCL IND and other indirect instructions fully support the new allocation scheme. The addressing is further enhanced with the ability to virtually address all registers in the range #000..FFF. The absolute register #000 is located at the virtual address 512+SIZE, #001 is at 513+SIZE, etc. This is ideal for indirectly accessing status, XM, program and data registers which is not possible on the real 41. For example, SIZE 010 535 ENTER 0 STO IND Y will cause MEMORY LOST because register 'c' is at the virtual address 535.

The behavior of XEQ/RTN is changed to support calling subroutines (and returning from subroutines) in registers above #1FF. With lower registers there is no change so the programs like LR, RT and SR (from PPC ROM) will work as usual. Subroutines can now be called from every single location in Program/Data, Extended and Port memory (including ROM modules and HEPAX RAM).

There is a little problem with global alpha labels and END instructions if they are more than 511 registers (3577 bytes) far away. In this case (which isn't very likely to happen) the emulator puts zero in the global label or END instruction which in fact removes the label or END instruction from the chain without doing any damage. So, there is a userís responsibility to keep their programs under 3577 bytes.

16-characters LCD:

The emulator engine is enhanced to support 16 characters LCD. All display instructions are changed. Some parts of the HP-41C firmware are changed, too, especially routines which are dealing with the alpha register. All 16 characters are supported all the time. You can view 16 alpha characters, 16 characters of the program line (like 123 .END. REG 2392), ... Some differences could occur with programs like RAMED from ZENROM (the display is right justified because RAMED thinks it is 12 characters wide) but the functionality is the same. It is even possible to see on the display all 10 digits of a number together with the exponent (like 1.234567891-99).

The advanced display handling now supports textual form of all HP-41C annunciators except BAT. Calculator annunciators for SHIFT, ALPHA, PRGM and BAT are used in conjunction with the textual annunciators. Annunciators for printer MAN, NORM and TRACE modes are provided, too.

Now, almost every single pixel on the calculator display is used for some purpose.

Extended Character Set:

There are two display fonts: the big one (16 pixels height) and the small one (8 pixels height). The big font is easily readable and is ideal for the usual work. However, sometimes when using printer emulation it is very useful to have one additional printer line on the display and that's why the small font exists. The switching between big/small font is implemented via ON&key sequence.

Furthermore, the emulator supports all lower case letters and HalfNut special characters. With the help of CCD ROM or ZENROM these new characters can be easily entered. The HalfNut contrast adjustment is implemented, too.

Built-in Modules:

The core of the emulator consists of the HP-41C mainframe (pages 0..2), CCD ROM Module (pages 3 & 4), Time or XF/XM Module (page 5), Printer Module (page 6) and HEPAX Module (page 7, 4 banks). As you can see, this page allocation differs from the standard HP-41C scheme because page numbers aren't hardwired to any particular module. On the real HP-41C page 3 is not used (it is used in CX), page 4 is hardwired to Diagnostic Module, page 5 to Time Module and page 7 to HP-IL Module. With HP-41X this is not the case.

Pages 8..15 are free and can be used for loading additional modules (like ZENROM, PPC ROM, Advantage, Math, Stat, ...). Unused pages are automatically used as HEPAX RAM. So, you can have up to 5222 free HEPAX registers. Free pages can be used as MLDL boxes for developing programs written in machine language, too (with the help of instructions like HEXEDIT from HEPAX, MCED from ZENROM or some external assembler).

The internal engine and mainframe are changed to eliminate the diagnostic module test on page 4 and to support searching from page 3. There is an ability to decide which modules will be searched: low (3..7), high (8..15) and all (3..15). This is very useful feature because you can have together modules which aren't compatible (like CCD ROM and ZENROM) and activate them at demand. CAT 2 always shows all modules.

The mainframe is an HP-41C ROM version FEE. I made some modifications in order to eliminate bug fixes for some bugs (BUGs #2, 3 and 8). It is now a heaven for synthetic programming because it contains all useful bugs. On the other side, some other bugs which aren't useful at all and have been fixed in the later revisions (GFF) are fixed now. This include BUG #5 (CLP would only clear 1089 program lines), BUG #7 (the second nibble of the seventh byte of Alpha is copied along with the first six bytes during an ASTO) and one another bug which disables CCD ROM and ZENROM operating system extensions on machines with serial numbers less than 2035.

HP-41CX Date/Time and XF/XM functions are supported because Time and XF/XM modules are built-in. Time Module is active by default and XF/XM can be activated at demand (this will deactivate Time Module). If both modules are needed then Time Module must be activated and XF/XM Module must be loaded from the HP41Z library (to a page in the 8..15 range). Additional HP-41CX commands are supported through loadable XR41 module (see below). CAT functionality is supported (and enhanced) through CCD ROM Module.

Timer Emulation:

Phineas clock chip is (almost) fully emulated. This means that both timers (main and stopwatch) are working properly. Interval timer is working, too, as well as alarms. Even negative stopwatch is implemented. Regular alarms are working as usual. In order to use alarms when the emulator is in the power-off state, hibernation mode must be activated. This is because in the usual deep-sleep state the emulator doesn't respond to alarm interrupts (alarm cannot wake up the emulator) but in the hibernation mode waking up the emulator by alarm is possible. Hibernation state should not be active for more than 3 days otherwise HP-48/49 date/time will be corrupted (this is the limitation of HP-48/49, not HP-41X). For the same reason, maximum alarm time is limited to 3 days in this mode. It is not recommended to stay a long time in hibernation mode on HP-48GX, either, because the emulator is stored on the RAM card and executed from there so the calculator must hold active lines to the card even when powered off which results in slightly increased power consumption compared to the deep-sleep mode. We are not talking about large values here, something like 0.4-0.5mA which is much less then idle power consumption but still more than in a true deep-sleep mode.

Only thing which is missing is the stopwatch ability to wake-up the emulator from hibernation state when crossing from negative to positive values. If the stopwatch alarm has been past-due, it will be activated at power-on. Also, checking for stopwatch alarm while executing a program requires a little overhead when stopwatch is active and time is negative.

Increased Speed:

Despite the larger display, huge memory address space, many built-in modules and other "speed consuming" features, the average speed increase is about 3 times comparing to the real HP-41C. The slowest case is a simple loop with only goose walking on the display. This is very cheap operation on the real calculator because it needs only one shifting which is done in hardware (display driver). The emulator has to refresh the whole display instead in order to emulate it properly. So, if you want to speed up the execution just display something with VIEW/AVIEW or disable goose with ON&G.

I had to modify some constants used in time loops because otherwise some operations would be too fast for normal use (CAT, PSE, NULL, TONE, BEEP, KEY?, EMDIR, scrolling). These constants are modified according to my needs and I programmed them to be slightly faster than on the real HP-41C.

There is also an internal version of the emulator which is almost 4 times faster (some operations are up to 4.33 times faster) then real HP-41C but it just consumes too much memory to be flexible enough for everyday use.

Printer Emulation:

Helios printer is fully emulated on the calculator display. There are 5 (or 6 when using small display font) rows of the printer "paper" above the HP-41C LCD. The width of the "paper" is 22 characters (131 columns). There is a separate printer buffer which can hold all columns. All characters, printer instructions and features are supported including graphics, MAN, NORM and TRACE modes, turning printer on and off, paper advancing, etc. Characters are defined as 6x7 dot matrix but without blank column between two consecutive characters.

Few more things are slightly different. The paper is advanced only if there is something in the printer buffer because with only 5 lines of the "paper" there isn't much use of many blank lines on the display. Two spaces between two consecutive instructions when printing program with PRP or LIST in TRACE mode are changed to one space. Of course, the internal programs PRPLOT, PRPLOTP and PRAXIS are changed in order to support plotting on the display with only 131 columns. Actually, when plotting, display width is 132 columns and the display can be scrolled in order to show the last column.

Furthermore, printing to the external printer (compatible with HP82240A/B) can be activated. External printing always occurs in graphic mode and the printout on the paper looks exactly like the one on the display (WYSIWYG). All character shapes are exactly the same. Paper width is limited to 131 columns in order to preserve compatibility with display output. External printer emulation works very well in conjunction with 82240 printer emulators, too. The active status of external printing is indicated by the annunciator.

There are also two another solutions: direct printing with HP-82143A Helios Thermal Printer Emulator or printing to HP-62162A HP-IL Thermal Printer using HP-IL emulation.


The emulator consists of 2 parts: HP41X (Emulator Kernel - codename ADQEE, library #41C) and HP41Z (External Modules - codename ADQUE, library #41D).

HP41X library contains the engine and core modules (Mainframe, XF/XM, CCD ROM, Printer and HEPAX). It occupies 128K and must be stored to Port1 (ERAM) because there is no way to map the bank from Port2 (FLASH) to the address #00000 (this is needed in order to install emulatorís own interrupt system). There is also a XM41 variable which contains all 4096 registers (Program/Data/Extended memory) together with port memory (pages 8..15, including HEPAX RAM) and additional bank-switching page which isn't visible for the user (it is used by the Advantage Module). The variable is automatically created by the engine (in the HOME directory) when the emulator is started for the first time and its size is around 100K.

External Modules:

The second part (HP41Z) of the emulator is an optional library of up to 21 4K modules which can be dynamically loaded and installed into the emulator memory. For HP-49G, there are two versions of the library: HP41Z1 which must be stored to Port1 and HP41Z2 which must be stored to Port2. For HP-48GX, only one version of the library exists. The list of all modules supported by HP-41X is here. Some modules, like PPC ROM, use two pages. Advantage Module occupies three pages in total and must be loaded to pages 12 and 13 because only page 13 supports bank switching. That's why only one bank-switched module (not counting HEPAX) can be installed in the system at the same time.

There is also the ability to load and compile additional modules from memory (stack) into the emulator. These are modules which aren't part of a library but are transferred from the computer or another calculator. Some modules like HP-IL Development Module can be loaded this way. The utility function for removing the module from emulator memory (converting the module to HEPAX RAM) is provided, too. The library contains some other functions like the utility for clearing Extended Memory and such.

XR41: HP-41X Extended ROM Module:

This module from HP41Z deserves a special attention because it contains all commands from HP-41CX which were initially missed in HP-41X (ASROOM, CLALMA, CLALMX, CLRALMS, CLRGX, ED, EMDIRX, EMROOM, GETKEYX, RCLALM, RESZFL, SigmaREG?, SWPT, X=NN?, X<>NN?, X<NN?, X<=NN?, X>NN? and X>=NN?). Their functioning is identical as in the HP-41CX but without any additional overhead which would be introduced with bank switching. Note that their XROM numbers have been changed.

Beside HP-41CX, few other commands are included in XR41:

PRTON: Turn printer ON.
PRTOFF: Turn printer OFF.
PRTLCD: Activate printing to LCD only.
PRTLED: Activate PRINTing via IR LED (RedEye) mode.
PRTIR: Activate PRINTing via IR serial mode (baud rate default to 2400).
PRTRS: Activate PRINTing via RS-232 (Wire) serial mode (baud rate default to 9600).
MAN: Activate MAN mode on printer.
NORM: Activate NORM mode on printer.
TRACE: Activate TRACE mode on printer.
UNDON: Activate underline mode.
UNDOFF: Dectivate underline mode.
INVON: Activate inverse (negative) mode.
INVOFF: Dectivate inverse (negative) mode.
RESETP: Reset the printer to default settings (FC 12, FC 13, UNDOFF, INVOFF).
BAUD: Set baud rate (value of the X register) after PRTIR and PRTRS.
CLC: Clear CCD ROM lowercase bit
SLC: Set CCD ROM lowercase bit

Valid baud rate values are: 0 (1200), 1 (1920), 2 (2400), 3 (3840), 4 (4800), 5 (7680), 6 (9600) and 7 (15360).

XR41 module can be loaded to page 15 only. In order to use time functions, Time Module must be activated. XF/XM Module doesn't have to be loaded for XM functions to work properly because they are totally independent.

Enhanced Interrupt System:

The emulator takes total control over calculator interrupt system and has its own interrupt handler. For speed reasons, the keyboard handling is implemented outside the interrupt handler. The keyboard is scanned only when needed by some machine code instructions. The main advantage of the dedicated interrupt system is the ability to use ON key as an additional system-shift key for various purposes. Because ON key interrupts are detected all the time it is very easy to break freezed synthetic and machine code programs. Furthermore, in the case of very low battery condition interrupt handler will turn off the calculator immediately to protect the memory from being erased.

Card Reader Support:

In order to provide program/data loading/saving capabilities, the emulator has card reader support built-in. Support is implemented via card reader module emulation which means that all card reader instructions and functions work as usual. Cards are maintained via card files which contain all cards saved with a dedicated card reader instruction. The size of a file is limited only by the free memory. Loading and saving process is automated so there is no further user assistence needed after executing a dedicated load/save instruction. There is no need to confirm every RDY mm OF nn message because the whole process is executed in one pass. After saving, all cards are placed on the calculator stack (in the form of a single character string object) from where they can be further manipulated. Of course, before loading, card file must be placed on the calculator stack, too. Card files provide an easy and simple way to save and interchange HP-41C programs/data because they can be stored to a variable/port or sent to another calculator or computer via serial cable.

HP-IL emulation:

If you need to communicate with the peripherals at more advanced level then HP-IL emulation is just for you ...

Compatibility with the real HP-41C:

HP-41X is trying to be fully compatible with the real HP-41C but this isnít always possible due to additional extensions and enhacements. All synthetic programs are working without problems. All functions and features from Time, XF/XM, CCD ROM, Printer, HEPAX, ZENROM, Advantage and other installed modules are supported. But, as said before, certain differences exist:

(*) Different pitch and duration of synthetic tones,
(*) Different display representation of some non-normalized numbers (although I must admit that I found the new representation better),
(*) Different display layout in some cases due to the 16-characters LCD,
(*) Different Helios printer layout due to the 22-characters paper width,
(*) Status registers 5..10 are represented as M,N,O,P,Q,R both on the display and the printer,
(*) CAT 1 shows length of each program together with the END instruction (as on the CX),
(*) Different display and printer justification/layout due to the larger address space (when displaying size of the program etc.),
(*) ďPeekingĒ around the ROM (firmware and other modules) can produce different results because ROMs are not the same,
(*) Executing new CPU instructions which are specific to the HP-41X (these should not be used outside the firmware),
(*) Bank-switching mechanism is different and should not be used directly,
(*) Direct access to the timer and card reader doesnít work (standard entry points should be used),
(*) HP-41X ROM word is 12-bit so CXISA and WMLDL will produce different results if all 12-bits are used,
(*) Some display instructions arenít implemented in order to save space,
(*) The size of a single program must be limited to 511 registers when working with peripheral devices like card reader and tape drive (via HP-IL) to avoid compatibility issues.

But, I really don't think about HP-41X as (only) an emulator - for me, it is a very new and exciting calculator with plenty of new features and enhancements ...

At the current stage of development the emulator is very stable - I haven't been able to crash it by using every synthetic routine or trick I tried. In the case of freezed programs the emulator was able to break them without problems (with ON&C). Of course, MEMORY LOST happened many times but I am considering this as normal.

Other features and enhancements:

(*) Light Sleep Mode when waiting for a key
(*) Automatic Shut-Down after some time of inactivity
(*) Support for "Continuous On" with flag 44 set
(*) Forced Shut-Down of the emulator on Low Battery condition (flag 44 ignored)
(*) Deep Sleep Mode (ON&G) when the emulator is turned off
(*) Hibernation Mode (ON&H) with active alarms in the power-off state
(*) The ability for the calculator alarm to wake up the emulator and start executing
(*) ON key turns on the emulator when it is off
(*) Safe key combination for Cold Start (MEMORY LOST)
(*) ON key suspends the execution if the emulator is on (until released)
(*) ON&Shift turns off the emulator immediately
(*) Enhanced Alpha Mode (ON&A, ON&B) and Temporary Alpha Mode (ON&Alpha)
(*) Automatic Temporary Alpha Mode for easy keying instructions like RCL X, STO Y, ...
(*) The ability to turn goose movement off/on in order to increase execution speed (ON&I)
(*) The ability to break the execution and restart the emulator (ON&C)
(*) The ability to restart the emulator with different display font (ON&D)
(*) The ability to turn printer on/off from the keyboard (ON&SPC)
(*) The ability to activate/deactivate printing to external printer (ON&0)
(*) The ability to activate card loading/saving from the keyboard (ON&L)
(*) The ability to use both unshifted and shifted ON&key combinations
(*) The ability to load Time Module (ON/*) and XF/XM Module (ON&/) at demand
(*) ON&key combinations for additional functionality (ON&+, ON&-, ON&<−, ON&F, ...)
(*) Extended Memory protection from MEMORY LOST

Here are few samples captured from the emulator running under Emu48 for Windows:

Installation guide with description of many other (advanced) features is here.

Please, keep in mind that HP-41X is not a free software.
If you want to buy one, you can find the necessary info here.
Demo version can be obtained at request.