decomp41 - decompile a HP-41 program file
lifutils decomp41 [-h][-a] [-l] [-r] [-x XROMFILE ] ... INPUTFILE [> Output file ]
lifutils decomp41 [-h][-a] [-l] [-r] [-x XROMFILE ] ... < Input file [> Output file ]
lifutils decomp41 -?
decomp41 produces a listing of an HP-41 FOCAL bytecode program. It reads the program as a series of bytes from standard input or the file specified by the command line parameter INPUTFILE and prints the listing to standard output (in a similar format to the standard HP-41 printer).
By default, functions contained in plug-in modules are displayed as XROM rr,nn where rr is the number of the plug-in ROM and nn is the number of the function within that ROM. This can be overridden by loading XROMFILEs, see the -x option below. An XROMFILE consists of a number of lines, each consisting of 2 decimal numbers and one or two strings (containing no whitespace), in that order, separated by whitespace. The first string gives a name to the function specified by the first number as rr and the second number as nn. The optional second string is the function name containing Unicode characters, which must not be used in the first string. See the -a option below.
The Linux command pr may be useful for formatting the output of decomp41 into multiple columns.
|
-h |
Display the bytes (in hexadecimal) that make up each program instruction immediately preceding the display of that instruction | ||
|
-l |
Enable line numbers | ||
|
-a |
Decompile the following non ASCII HP-41 FOCAL characters as Unicode characters: text append (hex 0x251c), greek small mu (hex 0x03bc), angle (hex 0x2280), not equal to (hex 0x2260), greek capital sigma (hex 0x03A3). | ||
|
-r |
Skip an existing LIF header of the input file. This is mandatory, if the input file is a LIF instead of a raw file. |
-x XROMFILE
Use XROMFILE to define names for functions in plug-in modules. This option may be repeated to load multiple XROMFILEs. The file name has to be specified either as a full pathname or as the filename without the extension .xrom in the default location that is specified with the environment variable LIFUTILSXROMDIR (see below). There is a special XROMFILE hpdevices.xrom that contains all definitions for the standard HP peripheral ROM functions.
|
-? |
Print a message giving the program usage to standard error. |
xroms/*
xrom function definition files. Use the environment variable LIFUTILSXROMDIR to point to the location of this directory. On Linux the default location is /usr/share/lifutils/xroms, if the variable is not specified.
The format of an HP-41 program is documented in many books. Amongst the most useful references are Extend Your HP41 (W. A. C. Mier-Jedrzejowicz) and The HP41 Synthetic Programming Quick Reference Guide (Jeremy Smith)
If disk1.dat is a LIF image containing an HP41 program called PROG then
lifutils lifget -r disk1.dat PROG | lifutils decomp41 -x hpil.xrom -x time.xrom
will produce a listing of the program to standard output, with the standard names for the functions in the HPIL module and time module.
Some synthetic functions may not be displayed correctly, although an attempt has been made to handle synthetic programming. Some common HP41C characters are not printable in ASCII (and are displayed as \nnn octal display sequences) so the display of strings in programs may be somewhat messy.
decomp41 was written by Tony Duell, ard@p850ug1.demon.co.uk and has been placed under the GNU Public License version 2.0