Files in directory hp42s/EML from the latest check-in of branch trunk
- Makefile
- README.md
- Suite.hp42s
- Suite.raw
EML/Suite for the HP-42S Family
EML/Suite port to the HP-42S,1 Free42, Plus42, and SwissMicros DM42n.
Rather than key in all this code on-device, I wrote the source code in the one true programmer’s text editor,2 then used rejig to produce the program file:
$ rejig Suite.hp42s -o Suite.raw
Or, thanks to the provided Makefile, just say make.
The result may be loaded into any of the machines linked above. I made particular use of Thomas Okken’s simulators in producing this port.
Usage
This suite’s subroutines drop the “EML” prefix3 to avoid clipping in the XEQ/PRGM menus. The chunky font on the HP-42S family meant that had I kept that all-caps prefix, you’d be left with but one or two characters to tell the labels apart.
Subroutines taking arguments follow the traditional RPN order used by the builtin operations.
Beware that the addition and multiplication operations aren’t strictly commutative due to differences in the way the arguments are handled. Swapping their order will give slightly different results! This then affects everything built atop them, most notably the Avg and Hyp subroutines, both of which should also be commutative, but are not.
Resources
Operands are consumed and replaced with results in the same manner as the builtin equivalents. Prior elements on the stack may be overwritten by intermediate results, but no “litter” is left behind.
The reference implementation uses the R47’s LocR feature to allocate local scratchpad registers at need. This version could have used the Free42-specific LSTO feature to much the same end, but because I wanted it to be portable to the HP-42S, I had to resort to global registers:
| Regs | Usage |
|---|---|
| R00-R01 | general scratchpad |
| R02 | CosH |
| R03 | ASin, ATan, Tan |
| R03-R04 | Hyp |
| R05 | Ball |
We need this many registers to avoid overlapping uses in nested calls even though it is never using more than two temporaries per subroutine.
Limitations
Even the Plus42 doesn’t give us everything needed to transliterate the reference version of EML/Suite. Several things had to be massaged:
I had to add the
ReandImsubroutines to emulate the R47 built-in operations of the same name.STOfails with complex numbers unless you first force the machine to convert its internalREGSmatrix to complex form. ThusCpxRegs.The HP-42S refuses to calculate `ln(0)=-oo`. This occurs within
NegX(or in the general case,Subwhen Y=0) which would then cause anInvalid Dataerror if we did not explicitly patch around it.I chose to limit the port to the traditional 4-slot HP stack rather than make use of Free42’s
NSTKmode. This required increased use of temporaries, akin to what we do in the lesser machines, to avoid blowing the stack. This is also reflected in this port’sStkUsubroutine, as compared to theEMLStkUtest in the reference implementation.
License
These programs are © 2026 by Warren Young and offered under the terms of the MIT License.
- ^
Technically not; the code uses the Free42
DROPextension, but that’s easily emulated on the actual HP-42S usingCLx-then-add. - ^
In this specific case Cursor with the Neovim plugin, but
vigenerically, being the proper baseline for writing software. I have spoken. - ^
…except for
EMLandEMLi, which could not be renamed to just “e” and “i” under the HP-42S label rules. Fortunately, their names were short enough without dropping the prefix.