Files in directory rlm12cp/EML from the latest check-in of branch trunk
- README.md
- Suite.12c
- Suite.hp12cp
EML/Suite for the HP-12C Family
EML/Suite port to the HP-12C family.
The source code should work as-is with any machine in this family, except that non-Platinum types use 2-digit GTO addresses.
Because rejig does not yet have a --syntax hp12c option implementing the HP-12C family conventions, I hand-transcribed that source code into the RLM 12c Platinum simulator to produce the program file.
Usage
See the link above for details, but briefly:
| Addr | Fn | Args | Stk | Description |
|---|---|---|---|---|
| 001 | eml | x,y | 0 | eponymous `eml(x,y)` |
| 006 | e | none | 2 | Euler’s number, `e` |
| 010 | exp | x | 1 | `e^x` |
| 013 | ln | x | 1 | `ln(x)` |
| 026 | 0 | none | 2 | the constant 0 |
| 028 | – | x,y | 1 | `y-x` |
| 032 | -1 | none | 3 | the constant -1 |
| 035 | 2 | none | 3 | the constant 2 |
| 041 | + | x,y | 3 | `y+x` |
| 043 | inv | x | 2 | reciprocal of `x` |
| 046 | × | x,y | 2 | `x×y` |
| 058 | pow | x,y | 2 | `y^x` |
| 071 | sqr | x | 3 | `x^2` |
| 073 | ÷ | x,y | 2 | `y÷x` |
| 077 | test | none | 4 | tests stack usage |
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!
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 full suite uses scratchpad registers, but not this cut-down port. That brings us to…
Limitations
No Subroutines
This lack requires all the primitives to be unrolled except when we can perform a GTO tail-call. This hastens the point where we run into the…
400 Step Limit
The RLM-12CP simulator extends the HP-12c Platinum’s 3-digit GTO argument scheme to its natural limit by allowing up to 999 program steps, but that doesn’t gain us much in the end since the further you go down the spiral, the deeper the call chains become, increasing the amount of inlining required.
No Complex Number Support
I had hoped this wouldn’t matter for the arithmetic functions at least, as long as the arguments were in the real (ℝ) domain. The EML scheme is based on foundations that are present on the 12C family — 1, 𝑒ˣ, ln(𝑥), 𝑥⇄𝑦, and subtraction — but there’s a surprise coming…
(x≤0) = Error 0
Nearly everything ends up calling this builtin via our `eml(x,y)` function, and `x<=0` is easy to come by:
0 GTO 013 ; simple restatement of the problem, Ln(0)
0 42 GTO 028 ; subtraction fails when it goes negative
0 42 GTO 041 ; additive identity fails for 0+42 but not 42+0
Technically speaking, this is part-and-parcel with the prior limitation: `ln(x),x<=0` is undefined in ℝ, but not in the complex domain. We may restate the error as, “Giving an answer would require complex number support.”
For this same basic reason, I have not bothered to attempt an HP-11C port even though it would get us past the first problem above, and it’d split the difference between the original HP-12C and the Platinum on the second. The ROI just isn’t there; this is one case where the HP-15C has a material advantage.
The sole entrypoints not at risk are GTO 006…
`eml(1,1)=e^1-ln(1)=e-0=e`
…and GTO 026 (`0=ln(1)`) purely because these are implemented in terms of canned values that don’t trigger the trouble.
This then explains why there is no `-x` entrypoint: it could be no more than a thin, cheating wrapper around the builtin CHS function to avoid an `ln(0)` call at the key `0-x` step. All the places in the code where we should be calling EML’s `-x` are cheated with an inline CHS call. This includes the -1 entrypoint at GTO 032, and one could argue that we shouldn’t bother providing it, either.
For this same core reason, multiplication, `x^2`, and `y^x` are limited to positive arguments in this port.
Worst is that division fails outright because the divisor inevitably becomes negative by the time it reaches the `ln(x)` at step 052.
Silver Lining
If there’s an upside to all these limitations, it is that the resulting cut-down port fits within the classic HP-12C limit of 99 program steps.
License
These programs are © 2026 by Warren Young and offered under the terms of the MIT License.