rejig got its name because it rejiggers programs between any input/output pairing of:
P47 input: This is the R47’s
WRITEPformat, so named due to the.p47file name extension the calculator uses. It is the default input format, which you may specify redundantly with the--from/-f p47option.P47 output: The tool can write out a file using that same format. Combined in this way,
rejigacts as a byte-code verifier: if you get out the same file content as you put in, the input is a valid R47 program. Select this with the--to/-t p47option.UTF-8 output: This is the default output format, translating the input into pretty-printed Unicode plaintext. No flag is needed to specify it, but you may give either
--to utf8or--to unicodeto be explicit about taking the default path.Unicode input: The
-f utf8option reverses the prior mode, but because our Unicode input handling is broader than that, you may instead specify--from unicode. See that link for details.Forty series family I/O:
- Plus42: The
--from/to plus42options read/write Plus42 binary state files with extension.p42. - Free42: The
--from/to free42options give similar support for the Free42.f42format, differing in framing details. - DM42[n]: The above should support the SwissMicros DM42 series, though this is as-yet untested.
- DM41L/X: Their state file format (
.d41) is handled much as with Free42/Plus42. - HP raw: The raw byte code format used by all forty-series machines from the HP-41C up through Plus42. Pair
--from/to hprawwith--validate/syntax hp41*/dm41x/hp42s/free42/plus42to select the rule set used, or leave it off to use the most capable of these,plus42. - MOD: HP-41 plug-in module files (
.mod, MOD1 and MOD2).rejigprints the named entrypoints and decodes a module only when its ROM image holds HP raw bytecodes. It can write a FOCAL-in-ROM MOD1 from program input. It does not produce microcode modules. See the HP-41C doc. - Unicode: The
.txtand.utf8extensions imply--from/to unicode, which presumes R47 input by default, but if it sees theraw2txtinstruction “00” header line on input, it engages--validate plus42when the user does not specify an input validation rule set. On output, giving--syntaxand any of {plus42,free42,hp42s,hp41c} causesrejigto emit text program listings formatted as close to the forty-family machine you request as Unicode allows. (More below.)
See our HP-41C and HP-42S Family docs for details.
- Plus42: The
Thirty series family I/O:
- DM32: The
--from/to dm32options read/write SwissMicros DM32 state files with extension.d32. - HP 35s: As with HP-42S Unicode I/O above, you can use
--syntax/validate hp35s. It uses HP 35s op spellings, with validation of supported ops. The mantissa of real numbers is truncated on output to 12 significant digits, with a warning if the input exceeds that. Reals with exponents greater than ±499 halt processing with an error. - HP-32SII: Use
hp32siiinstead to restrictrejigto a subset of the DM32 rules minus its lone extension, the remote-XEQ feature. It has the same real-number limits as with the 35s.
See the HP-32S Family Support doc for details.
- DM32: The
HP Voyager family I/O:
- JRPN simulator files: The
--from/to hp16c/hp15coptions are implied by use of the.16cand.15cfile name extensions. - Manz simulator file: The
.15cformat was originally designed for Torsten Manz’ HP-15C Simulator but later adopted by the JRPN simulators, Nibble Workshop’s my15C family emulators, and The Calculator Store’s VoyagerCalc. - [RLM-1xC]: JSON based simulator program file format for the HP-15C/12C/11C. Because the RLM simulators use those oft-overloaded names as file extensions, implied format guessing might not work, requiring an explicit
--from/to rlm15cor similar. This is distinct from the UTF-8 pretty-printed format,--to utf8 --syntax hp15c. - Unicode: As with HP-42S Unicode I/O above, you can use
--syntax/validate hp11c/hp12c/hp15c/hp16c. It uses HP-11C/12C/15C/16C op spellings, with validation of supported ops. The mantissa of real numbers is truncated on output to 10 significant digits, with a warning if the input exceeds that. Reals with exponents greater than ±99 halt processing with an error. (These Nut-CPU limits are shared with--syntax hp41c.) There’s enough flexibility in the parser to allow variants like the NutEm/PC text export format. - VoyagerCalc text exports: Read-only support via
--from emu1?c.1
- JRPN simulator files: The
See the HP-11C, HP-12C, HP-15C, and HP-16C docs for details.
Additionally, rejig offers these output-only formats:
--to htmlproduces an HTML file based loosely on the default Unicode output, but instead of relying on Unicode glyphs for math typesetting, we do it via ASCIIMath. By default,rejiguses the same lightly-modified version of the baseASCIIMathML.jsserved from this Fossil site’s unversioned files, but you may elect to switch to a heavier alternative with nicer output by giving the--mathjaxflag.--to html-staticis a variant of--to-htmlwhich uses a Go conversion ofASCIIMathML.jsto produce this same MathML code, but inlined within the output HTML. The resulting markup text isn’t as readable, but it is completely standalone, allowing it to work under no-JS restrictions.--to latexproduces LaTeX output in the style used by the R47 community manual.
Unicode
The --from/to unicode/utf8 options described above assume R47 program text by default, with appropriate restrictions and stylings. However, these may be paired with the --validate and --syntax command line options respectively to cause rejig to expect/produce a more constrained RPN dialect.
The default output mode of rejig is to pretty-print in an R47 inspired format, but giving --syntax restricts its output to the limits and style of other machines. For instance, hp42s disallows R47-only ops and causes rejig to use HP-42S op name spellings, plus 42-isms like ST and IND markers. Further, it changes how --line-numbers operates to better match the style seen on-calculator and in the HP manuals.
These additional validation rule sets are available in rejig:
hp35s: HP 35shp32sii: HP-32SIIdm32: DM32hp15c: HP-15Chp12c: HP-12Chp11c: HP-11C
Some of these have associated program file formats listed above, but do not confuse these two schemes. Consider:
./rejig --to dm32 < program.p47
./rejig --syntax dm32 < program.p47
Both calls rely on the default --from p47 option by reading the input from a pipe, but with different output. The first overrides the default R47-inspired Unicode pretty-printing to produce a DM32 statefile instead. The second keeps the default output format but applies additional restrictions atop it to produce plaintext similar to what is found for the example programs printed in the DM32 manual.
Similar things occur on input with --from unicode except that the paired flag is --validate, which causes the Unicode plaintext parser to apply tighter validation rules than it normally would, overriding those for inputs presumed to be interpretable by an R47. Examples:
./rejig program.p47 --validate dm32
./rejig program.p47 --to dm32 > program.d32
The first command attempts to lower the R47 byte code given as input to Unicode pretty-printed form, using DM32 inspired op spellings, label and variable restrictions, and so forth. If it succeeds, the result should be suitable for presentation as a human-readable program listing for a DM32.
The second command does the same, but to a DM32 statefile. The explicit --to option is not needed here if you say instead:
./rejig program.p47 --output program.d32
…because it can then infer the output format from the given file name’s extension.
This takes us to…
Implied Formats
By default, rejig operates as if you gave -f p47 -t utf8, but the command line parser consults those defaults only when it cannot see a file name, as when using rejig in a pipeline:
rejig < input.p47 > output.p47u
This relies on rejig defaulting to stdin when no input file name is given and writing to stdout when no --output/o is given. This is convenient, but do be aware that using rejig in a pipeline like this prevents it from seeing the file names, defeating its ability to infer a machine type from that clue. Ironically, this can force simple commands like the above to become longer, as you now need to give flags like --syntax and --validate to supply details rejig could guess, if you directly gave it the file names with machine-specific extensions.
The following command is equivalent to the one immediately above:
rejig input.p47 -o output.p47u
The first command works because the file formats match the rejig defaults, avoiding the need for explicit --from/to options. The second works because this command form allows rejig to see the file name extensions and make suitable inferences.
You need not give --from/to options when doing non-default things provided you give rejig file names with extensions it knows about:
rejig input.utf8 -o output.p47
In needlessly verbose form, that can instead be expressed as:
rejig --from p47u input.utf8 --to p47 --output output.p47
Now consider this counterexample:
rejig -f utf8 -t p47 < input.p47u > output.p47
This is the overly-verbose example above recast using pipes, making the -f/t options fully justified because they override defaults we do not want to accept in this instance.
Format inferencing makes --from/to options largely redundant when not using rejig in a pipeline since you should be naming your RPN program files in accord with the conventions this program supports regardless.
The only thirty-series machine presently having a calculator-specific --from/to file format is the DM32 with its .d32 statefiles.
For all else, use file name extensions matching the --syntax/validate values when you wish to imply these options on Unicode I/O. Do realize, however, that the actual file format is --from/to unicode in these cases. Syntax and validator rules are a distinct concept to rejig.
(You may now wish to return to the rejig home page.)
License
This work is © 2026 by Warren Young and is licensed under CC BY-NC-SA 4.0
- ^
Although this mode is implied by a matching file name extension, be aware that VoyagerCalc’s “Export Listing as Text…” feature uses the generic
.txtextension, which inrejigimplies Free42raw2txtstyle listings. (It wins on longstanding precedent.) All else but theLISTINGsection is ignored. There is no--to emu1?cpartly because VoyagerCalc lacks a corresponding “Import” feature and partly becauserejiglacks the ability to produce the non-LISTINGsections.