DM41 to Unicode FOCAL Converter
Table of Contents
DM41 to Unicode FOCAL Converter #
Step into the retro brilliance of the HP-41CX with hp41cx_tools-dm41_to_unicode, a clever tool that converts
DM41-encoded FOCAL source code (.dm41.focal
) to Unicode format
(.utf8.focal
). Built in Ada 2022 for rock-solid reliability, this filter masterfully handles special characters
(~
, ^
, #
) with context-sensitive conversions and restores XROM key assignments (e.g., ; KEY = XOR -81
)
to ensure Unicode compatibility. Part of the work-in-progress hp41cx_tools suite, it’s tested with Make (make test
) and runs flawlessly on macOS, Linux, and Windows, surpassing Windows-only tools.
Features #
- Smart Conversion: Transforms
.dm41.focal
(ASCII, double quotes) to.utf8.focal
(Unicode, HP-style quotes), with precise handling of special characters and XROM commands. - Context-Sensitive Handling:
- In ALPHA Strings:
~
→Σ
^
→↑
\x1D
→≠
- In Commands:
ENTER
→ENTER↑
^
→↑
S
→Σ
#
→≠
- In ALPHA Strings:
- XROM Handling: Restores XROM key assignments (e.g.,
; KEY = XOR -81
) from double-comments, preserving standard key assignments (e.g.,; KEY = TONE 42
). - Pipe-Friendly: Reads from standard input and writes to standard output, ideal for scripting and pipelines.
- Cross-Platform: Works on macOS, Linux, and Windows, perfect for any retro computing setup.
- Open Source: Explore the code on SourceForge.
- Comprehensive Docs: Explore detailed guides via GNATdoc.
- Robust Testing: Backed by AUnit tests via
make test
for reliable performance.
Usage #
No command-line options—just pipe DM41 FOCAL code in and get Unicode code out:
hp41cx_tools-dm41_to_unicode < in_program.dm41.focal > out_program.utf8.focal
Example Output #
; STACK = 8.760000000E+02 8.000000000E+00 8.000000000E+00 0.000000000E+00 1.000000000E+00
; ALPHA = ⊤⊤
; SIZE = 100
; ΣREG = 11
; FLAGS = 0000 0000 0000 0000 0000 0000 0011 0000 0000 0000 0000 1000 0000 0000
; A: 09999999999000 B: 000000300000fd C: 00000000300008
; S: 00101000001000
; M: 000018a5ff83d3 N: 1931a7001691a6 G: 90
; REG000 = 8.000000000E+00 8.000000000E+00 4.000000000E+00 1.000000000E+00
; REG004 = 3.000000000E+00 6.000000000E+00 2.000000000E+00 7.000000000E+00
; REG008 = 5.000000000E+00 0.000000000E+00 8.760000000E+02 8.000000000E+00
LBL ⊤NQUEENS⊤
LBL A
CLRG
8
STO 11
LBL 00
RCL 00
RCL 11
X=Y?
GTO 04
ISG 00
DEG
STO IND 00
LBL 01
ISG 10
DEG
RCL 00
STO 09
LBL 02
DSE 09
DEG
RCL 09
X=0?
GTO 00
RCL IND 00
RCL IND 09
-
X=0?
GTO 03
ABS
RCL 00
RCL 09
-
X≠Y?
GTO 02
LBL 03
DSE IND 00
GTO 01
DSE 00
GTO 03
LBL 04
RCL 10
RTN
.END.
Notes
- Input/Output: Reads .dm41.focal (ASCII, double quotes) and outputs .utf8.focal (Unicode, HP-style quotes).
- Character Handling: Uses AdaCL.Wide_Strings.Spitbol.Patterns for context-sensitive substitutions, as regular expressions fall short for distinguishing ALPHA strings, commands, and XROM assignments.
- Work in Progress: Part of the evolving hp41cx_tools suite, with more features planned.
Relive the HP-41CX’s golden era with this sharp converter, transforming DM41 code into Unicode elegance with the precision of a vintage calculator!