Skip to main content

HP-41CX Emulator Tool - Main

·

HP-41CX Emulator Tool - Main #

Unleash the retro computing magic of the HP-41CX with hp41cx_tools-main, the heart of the hp41cx_tools suite! This command-line powerhouse decodes memory dumps and converts FOCAL source code for PX-41CX and DM41X emulators, bringing the 1980s calculator era to life. Written in Ada 2022 for rock-solid reliability and tested via Make (make test), it runs seamlessly on macOS, Linux, and Windows, outshining Windows-only alternatives.

Note: This is a work-in-progress tool. Decoding and conversion are fully functional, but encoding/compiling is planned for a future release.

Features #

  • Decode Memory Dumps: Transform .px41 and .dm41 memory dumps into readable FOCAL source code, with automatic input format detection.
  • Convert FOCAL Code: Seamlessly convert between .utf8.focal, .dm41.focal, and .px41.focal formats, handling subtle differences like quote styles and unsupported commands.
  • Cross-Platform: Runs on macOS, Linux, and Windows, perfect for any retro computing setup.
  • Scriptable: Command-line interface integrates into automated workflows.
  • Robust Testing: AUnit tests ensure reliability, covering edge cases (run via make test).
  • Open Source: Explore and extend on SourceForge.

Usage #

hp41cx_tools-main command {options} in_file out_file

Commands #

  • -d, --decode: Decode .px41 or .dm41 memory dumps to FOCAL source code (e.g., .utf8.focal).
  • -e, --encode: Encode FOCAL source code to memory dumps (not yet implemented).
  • -c, --convert: Convert FOCAL source code between .utf8.focal, .dm41.focal, and .px41.focal.

Input File Format Options #

  • -i utf8, --in=utf8: Input is Unicode FOCAL code (.utf8.focal, default).
  • -i dm41, --in=dm41: Input is DM41 FOCAL code (.dm41.focal, ASCII with double quotes).
  • -i px41, --in=px41: Input is PX-41CX FOCAL code (.px41.focal, ASCII with single quotes).
  • Note: For decoding, input format is auto-detected for .px41 and .dm41 dumps, ignoring -i.

Output File Format Options #

  • -o utf8, --out=utf8: Output Unicode FOCAL code (.utf8.focal, default, with HP-style quotes).
  • -o dm41, --out=dm41: Output DM41 FOCAL code (.dm41.focal, ASCII with double quotes).
  • -o px41, --out=px41: Output PX-41CX FOCAL code (.px41.focal, ASCII with single quotes).

Quotes for Unicode Output #

  • -q hp, --quotes=hp: Use HP-41CX style quotes (⊤) for alpha strings (default for .utf8.focal).
  • -q single, --quotes=single: Use single quotes (’) for alpha strings.
  • -q double, --quotes=double: Use double quotes (") for alpha strings.
  • -q back, --quotes=back: Use backticks (`) for alpha strings.
  • Note: Quote options apply only to .utf8.focal output.

Other #

  • -?, --help: Display help information.
  • Version: 1.6.3 (Documentation).

File Format Details #

Input Detection: .px41 and .dm41 memory dumps are auto-detected for decoding, ignoring -i options.

Output Conversion: Default output is .utf8.focal with HP-style quotes (⊤). For .dm41.focal, uses double quotes ("). For .px41.focal, uses single quotes (’).

Supported Formats: #

  • .utf8.focal: Unicode FOCAL code, supports HP-style quotes for authentic HP-41CX output.
  • .dm41.focal: ASCII FOCAL code for SwissMicros DM41, using double quotes.
  • .px41.focal: ASCII FOCAL code for PX41CX_Interface.xls, using single quotes.

Example: Decoding #

Decode a DM41 memory dump to Unicode FOCAL code:

hp41cx_tools-main --decode in_GRAVITY.dm41 out_GRAVITY.utf8.focal

Example Input: in_Number.px41 #

DM41
08  4b000000000000  00000000000000  00000000000000  00000000000000
0c  0000000000019c  1a70016919c175  0000002c048000  00000000000000
174  00000000000000  00000000c8262d  93021036ba0000  402143668e2142
178  225140668e5222  8e042126421242  0010362266ba00  452e2e2e2163b4
17c  45502053504143  06ba0003fd4445  12437120424092  40ce0220512442
180  aa001330244222  00431371457502  40542467b200a9  a80066b2005222
184  42124222517141  42134321413426  2345759303207a  2e2e7e897f3061
188  77f75a45524f2e  4e452e2e2e7e89  2e2e2e7e89f64f  2e7e89f654574f
18c  54485245452e2e  7e892367b300f8  3d9b06f37f2046  537e894585f241
190  9b71f57f20462f  45f27f46f27f3d  226e261a15f156  454c3d9b037e89
194  899c000af54655  9c02a91d9b017e  10322533f2473d  101010361c1510
198  10104035cf6615  61181010421112  56495459a81b31  c000f800475241
A: c000f800475241  B: 0000002c0480fd  C: 0000002c0480fd
S: 00001100000000
M: 00011cd5ff73cb  N: 000000000000c0 G: 00

Example Output: out_Number.focal #

; ALPHA = ⊤                     ⊤
; SIZE =  100
; ΣREG =  624
; A: c000f800475241  B: 0000002c0480fd  C: 0000002c0480fd
; S: 00001100000000
; M: 00011cd5ff73cb  N: 000000000000c0  G: 00
LBL ⊤GRAVITY⊤       ; c000f80047524156495459
SF 27               ; a81b
STO 01              ; 31
ABS                 ; 61
800                 ; 181010
*                   ; 42
1200                ; 11121010
+                   ; 40
STO 05              ; 35
LBL A               ; cf66
5000                ; 15101010
STO 06              ; 36
-500                ; 1c151010
STO 02              ; 32
RCL 05              ; 25
STO 03              ; 33
⊤G=⊤                ; f2473d
FIX 2               ; 9c02
CF 29               ; a91d
ARCL 01             ; 9b01
AVIEW               ; 7e
PSE                 ; 89
FIX 0               ; 9c00
LBL 09              ; 0a
⊤FUEL=⊤             ; f54655454c3d
ARCL 03             ; 9b03
AVIEW               ; 7e
PSE                 ; 89
RCL 02              ; 22
RND                 ; 6e
RCL 06              ; 26
.5                  ; 1a15
⊤V⊤                 ; f156
X>Y?                ; 45
⊤⊦F⊤                ; f27f46
⊤⊦=⊤                ; f27f3d
ARCL 13             ; 9b71
⊤⊦ F/S⊤             ; f57f20462f53
AVIEW               ; 7e
PSE                 ; 89
X>Y?                ; 45
RTN                 ; 85
⊤A=⊤                ; f2413d
ARCL 06             ; 9b06
⊤⊦ F⊤               ; f37f2046
AVIEW               ; 7e
PSE                 ; 89
RCL 03              ; 23
X=0?                ; 67
GTO 02              ; b300
⊤THREE...⊤          ; f854485245452e2e2e
AVIEW               ; 7e
PSE                 ; 89
⊤TWO...⊤            ; f654574f2e2e2e
AVIEW               ; 7e
PSE                 ; 89
⊤ONE...⊤            ; f64f4e452e2e2e
AVIEW               ; 7e
PSE                 ; 89
CLX                 ; 77
⊤ZERO...⊤           ; f75a45524f2e2e2e
AVIEW               ; 7e
PSE                 ; 89
CLD                 ; 7f
STO 00              ; 30
ABS                 ; 61
RCL 03              ; 23
X>Y?                ; 45
RDN                 ; 75
ST- 03              ; 9303
RCL 00              ; 20
SIGN                ; 7a
*                   ; 42
3                   ; 13
/                   ; 43
RCL 01              ; 21
-                   ; 41
STO 04              ; 34
RCL 06              ; 26
*                   ; 42
2                   ; 12
*                   ; 42
RCL 02              ; 22
X↑2                 ; 51
X<>Y                ; 71
-                   ; 41
SF 00               ; a800
X<0?                ; 66
GTO 01              ; b200
SQRT                ; 52
RCL 02              ; 22
+                   ; 40
CHS                 ; 54
RCL 04              ; 24
X=0?                ; 67
GTO 01              ; b200
CF 00               ; a900
/                   ; 43
3                   ; 13
X<>Y                ; 71
X>Y?                ; 45
RDN                 ; 75
LBL 01              ; 02
FS?C 00             ; aa00
3                   ; 13
STO 00              ; 30
RCL 04              ; 24
*                   ; 42
RCL 02              ; 22
+                   ; 40
X<> 02              ; ce02
RCL 00              ; 20
X↑2                 ; 51
RCL 04              ; 24
*                   ; 42
2                   ; 12
/                   ; 43
X<>Y                ; 71
RCL 00              ; 20
*                   ; 42
+                   ; 40
ST+ 06              ; 9206
GTO 09              ; ba00
LBL 02              ; 03
⊤DEEP SPACE...⊤     ; fd444545502053504143452e2e2e
RCL 01              ; 21
X≠0?                ; 63
GTO 03              ; b400
0                   ; 10
STO 06              ; 36
RCL 02              ; 22
X<0?                ; 66
GTO 09              ; ba00
PROMPT              ; 8e
LBL 03              ; 04
RCL 01              ; 21
RCL 06              ; 26
*                   ; 42
2                   ; 12
*                   ; 42
RCL 02              ; 22
X↑2                 ; 51
+                   ; 40
X<0?                ; 66
PROMPT              ; 8e
SQRT                ; 52
RCL 02              ; 22
+                   ; 40
RCL 01              ; 21
/                   ; 43
X<0?                ; 66
PROMPT              ; 8e
RCL 01              ; 21
*                   ; 42
ST- 02              ; 9302
0                   ; 10
STO 06              ; 36
GTO 09              ; ba00
.END.               ; c8262d

Example: Conversion #

Convert DM41 FOCAL code to PX-41CX format, adjusting quotes and commenting unsupported commands:

hp41cx_tools-main --convert --in=dm41 --out=px41 in_program.dm41.focal out_program.px41.focal

Relive the HP-41CX’s golden era with hp41cx_tools-main, where decoding and conversion bring your emulator projects to life. Stay tuned for the upcoming encoder!