Post Reply 
dm42decode - a command-line decoder tool
12-24-2023, 09:06 PM
Post: #1
dm42decode - a command-line decoder tool
I have been enjoying both the Plus42 Emulator and a DM42 calculator, and while I can convert programs from binary to text using them, I thought it would be nice to have a command-line tool that could also do the job.

I've written one, and I've made it available under a GPL license. You can get a copy of the source code here: dm42decode

I develop on Linux, and in that environment the tool can be simply built via typing "make".

Disclaimer: The tool may not be 100% perfect, but it is able to correctly decode the various raw files that I've found on the web at: 42progs.

If folks try it and find any bugs, please let me know.
Find all posts by this user
Quote this message in a reply
12-25-2023, 07:11 PM
Post: #2
RE: dm42decode - a command-line decoder tool
Too bad you don't have a version for Windows.
I myself developed an interface tool for DM41L, DM41X then another one for DM15L and yet another one for DM11L
These tools allow me to exchange programs between emulators and calculators (see my site http://clones.phweb.me)
I started working on the DM32 and I put aside the DM42 interface (for 2024...) because it was much more complex.
My tools are in Excel in order to try to be as portable as possible.
Are you considering a version for Windows?

http://ti58c.phweb.me
http://clones.phweb.me
http://www.instagram.com/ti58c
"No! Do or Do not. There is no try!" [Master Yoda]
Visit this user's website Find all posts by this user
Quote this message in a reply
12-25-2023, 10:06 PM
Post: #3
RE: dm42decode - a command-line decoder tool
Pierre, I am very impressed by your emulator page. You have put in a lot of work! I bookmarked yur emulator website and will be spending more time looking at its contents.

Namir
Find all posts by this user
Quote this message in a reply
12-25-2023, 11:14 PM
Post: #4
RE: dm42decode - a command-line decoder tool
(12-25-2023 10:06 PM)Namir Wrote:  Pierre, I am very impressed by your emulator page. You have put in a lot of work! I bookmarked yur emulator website and will be spending more time looking at its contents.

Namir
Hi Namir,

MERCI !!!

(You have the habit of complimenting me and I am very flattered.)

The last improvement to my ti58c emulator dates back to April 19, 2023.
I let myself be tempted to add new instructions largely inspired by calculators... HP!
Then I wrote the documentation for Miroslav Nemecek's ET-57 calculator (largely improved clone of the TI-57).
For the moment I'm mainly working on code interfaces between calculators and emulators.
For example, my first program converts HP41cx sources into dump code for DM41X or PX41CX (Alex Garza prototype) but also produces barcodes for HP41C from programs from emulators.
My second program compiles/decompiles HP15C programs for exchange between emulators and DM15L.
The third program concerns the HP11C...
Since I retired I haven't stopped and I will continue !

I wish you Happy Holidays for this end of the year.

http://ti58c.phweb.me
http://clones.phweb.me
http://www.instagram.com/ti58c
"No! Do or Do not. There is no try!" [Master Yoda]
Visit this user's website Find all posts by this user
Quote this message in a reply
12-26-2023, 04:24 AM
Post: #5
RE: dm42decode - a command-line decoder tool
(12-24-2023 09:06 PM)stevenfalco Wrote:  Disclaimer: The tool may not be 100% perfect, but it is able to correctly decode the various raw files that I've found on the web at: 42progs.

You might have a look at: (Free42) txt2raw - raw2txt

These programs are based on the sources of Free42 and use some functions for the translation.
Therefore you can expect to get the same results.

I haven't tried but it should also compile on Windows.
After all Free42 does.
Find all posts by this user
Quote this message in a reply
12-26-2023, 11:07 AM
Post: #6
RE: dm42decode - a command-line decoder tool
Quote:You might have a look at: (Free42) txt2raw - raw2txt

Thanks but I know the solutions you cite but:
- raw2txt not very "flexible" (I wrote a parameterized command file for ease)
- txt2raw inoperative (.pl!!!)
Otherwise :
- dm42coder.py requires the installation of python but does not work with the python3 that I use.
- hp41uc with win41uc gives good results with programs that are not too specific HP-41
and there remains Swissmicros Programming tool...

so I have to follow my intuition and develop my own interface... after finishing hp-11C (dm11L) then hp-32s (dm32)!

http://ti58c.phweb.me
http://clones.phweb.me
http://www.instagram.com/ti58c
"No! Do or Do not. There is no try!" [Master Yoda]
Visit this user's website Find all posts by this user
Quote this message in a reply
12-26-2023, 12:28 PM
Post: #7
RE: dm42decode - a command-line decoder tool
(12-26-2023 11:07 AM)Pierre Wrote:  - txt2raw inoperative (.pl!!!)
What exactly do you mean by this?
This is not a Perl program.

My answer was more directed at stevenfalco.
Instead of reinventing the wheel, these C programs use the same code for the transformations as Free42.
They are just thin wrappers around the necessary function calls.
I haven't tried it yet, but the same should work with Plus42.
Find all posts by this user
Quote this message in a reply
12-26-2023, 06:01 PM
Post: #8
RE: dm42decode - a command-line decoder tool
Quote:What exactly do you mean by this?
This is not a Perl program.
See https://thomasokken.com/free42/download/...d/txt2raw/

http://ti58c.phweb.me
http://clones.phweb.me
http://www.instagram.com/ti58c
"No! Do or Do not. There is no try!" [Master Yoda]
Visit this user's website Find all posts by this user
Quote this message in a reply
12-26-2023, 06:07 PM
Post: #9
RE: dm42decode - a command-line decoder tool
Quote:Instead of reinventing the wheel...
I prefer a wheel with a rubber tire and an inner tube mounted on a good rim with good shock absorbers rather than a wooden wheel rimmed with iron... each to their own.

http://ti58c.phweb.me
http://clones.phweb.me
http://www.instagram.com/ti58c
"No! Do or Do not. There is no try!" [Master Yoda]
Visit this user's website Find all posts by this user
Quote this message in a reply
12-26-2023, 07:02 PM
Post: #10
RE: dm42decode - a command-line decoder tool
(12-26-2023 06:01 PM)Pierre Wrote:  See https://thomasokken.com/free42/download/...d/txt2raw/

From ABOUT.txt:
Code:
This directory contains some Free42-related materials that are no longer
supported, but may still be of interest:

(…)

txt2raw
Command-line program that converts HP-42S program listings to raw files.
Requires Perl.

Apart from the common name this is not related to the C program that I referenced:
(05-22-2022 12:27 PM)Thomas Klemm Wrote:  txt2raw.cc
This program uses core_paste to read the program from a txt-file and core_export_programs to write it to a raw-file.
Code:
#include <sstream>
#include <fstream>

#include "core_main.h"
#include "core_globals.h"

int main(int argc, char *argv[]) {
    std::ostringstream sstream;
    std::ifstream fs(argv[1]);
    sstream << fs.rdbuf();
    const std::string str(sstream.str());
    const char* prgm = str.c_str();

    core_init(0, 0, NULL, 0);
    flags.f.prgm_mode = true;
    core_paste(prgm);
    const int indexes[] = { 0 };
    core_export_programs(1, indexes, argv[2]);

    return 0;
}
Find all posts by this user
Quote this message in a reply
12-26-2023, 07:12 PM
Post: #11
RE: dm42decode - a command-line decoder tool
(12-25-2023 07:11 PM)Pierre Wrote:  Too bad you don't have a version for Windows.

From How to install Linux on Windows with WSL:
Quote:Developers can access the power of both Windows and Linux at the same time on a Windows machine. The Windows Subsystem for Linux (WSL) lets developers install a Linux distribution (such as Ubuntu, OpenSUSE, Kali, Debian, Arch Linux, etc) and use Linux applications, utilities, and Bash command-line tools directly on Windows, unmodified, without the overhead of a traditional virtual machine or dualboot setup.

(12-26-2023 06:07 PM)Pierre Wrote:  I prefer a wheel with a rubber tire and an inner tube mounted on a good rim with good shock absorbers rather than a wooden wheel rimmed with iron... each to their own.

Well then, maybe not for you.
Find all posts by this user
Quote this message in a reply
12-27-2023, 01:30 AM
Post: #12
RE: dm42decode - a command-line decoder tool
(12-26-2023 04:24 AM)Thomas Klemm Wrote:  You might have a look at: (Free42) txt2raw - raw2txt

These programs are based on the sources of Free42 and use some functions for the translation.
Therefore you can expect to get the same results.

That is a very clever approach to writing a text / raw translator!

It could be improved a bit, by calling core_list_programs() to check if the input contained multiple programs, and by scrapping most of the shell functionality and replacing it by stub functions, so the whole thing will build without any GUI library dependencies.
Visit this user's website Find all posts by this user
Quote this message in a reply
12-27-2023, 01:41 PM
Post: #13
RE: dm42decode - a command-line decoder tool
(12-27-2023 01:30 AM)Thomas Okken Wrote:  That is a very clever approach to writing a text / raw translator!

I'm glad you like the idea.

(12-27-2023 01:30 AM)Thomas Okken Wrote:  It could be improved a bit, by calling core_list_programs() to check if the input contained multiple programs, and by scrapping most of the shell functionality and replacing it by stub functions, so the whole thing will build without any GUI library dependencies.

I guess I can't really follow you there.
I wasn't able to remove the dependency on the GUI so easily.
My approach would probably be to extract these methods into separate files so they can be used by both the GUI and CLI.

Asked somewhat bluntly: Would it be possible to make these two tools available with a regular release of Free42/Plus42?
Most of the members in this forum are probably not able to compile them themselves.
Therefore, they would be happy if these were made available officially.



(12-26-2023 12:28 PM)Thomas Klemm Wrote:  I haven't tried it yet, but the same should work with Plus42.

In the meantime I tried to compile the two programs with plus42desktop.
That worked, but when I let them run it results in a segmentation fault.
I haven't looked at it in detail yet, but I saw that the signature of core_init changed:

free42:
Code:
void core_init(int read_state, int4 version, const char *state_file_name, int offset);

plus42desktop:
Code:
void core_init(int *rows, int *cols, int read_state, const char *state_file_name);

This can not work of course but should be easy to fix.
Find all posts by this user
Quote this message in a reply
12-27-2023, 01:48 PM
Post: #14
RE: dm42decode - a command-line decoder tool
I added txt2raw and raw2txt targets for the Linux version.
I'll add targets for the Windows and MacOS versions in a bit.
Visit this user's website Find all posts by this user
Quote this message in a reply
12-27-2023, 05:01 PM (This post was last modified: 12-27-2023 05:12 PM by Thomas Klemm.)
Post: #15
RE: dm42decode - a command-line decoder tool
That's great to hear.
And we even got a decent usage.

Usage: ./txt2raw <text-file>
Usage: ./raw2txt <raw-file>

I 'd say on the scale of evolution of the wheel we're right between a "wooden wheel rimmed with iron" and a "rubber tire and an inner tube mounted on a good rim with good shock absorbers".

[Image: CMyiLuKUwAA6l-V.jpg]



(12-27-2023 01:30 AM)Thomas Okken Wrote:  scrapping most of the shell functionality and replacing it by stub functions

Now I understand it after looking at your changes.
Find all posts by this user
Quote this message in a reply
12-27-2023, 05:20 PM
Post: #16
RE: dm42decode - a command-line decoder tool
(12-27-2023 01:48 PM)Thomas Okken Wrote:  I added txt2raw and raw2txt targets for the Linux version.
I'll add targets for the Windows and MacOS versions in a bit.
Good news !
(A good wheel that rolls on all roads whether Linux, Apple or Windows!)

http://ti58c.phweb.me
http://clones.phweb.me
http://www.instagram.com/ti58c
"No! Do or Do not. There is no try!" [Master Yoda]
Visit this user's website Find all posts by this user
Quote this message in a reply
12-27-2023, 05:43 PM
Post: #17
RE: dm42decode - a command-line decoder tool
I added the targets for Windows, but I still need to do some testing and look at some build warnings. I'll try to add the MacOS targets tomorrow.

Once it's all done, I'll upload executables to my web site. They won't be part of the app distribution since they only need to be updated when there are additions to the instruction set.
Visit this user's website Find all posts by this user
Quote this message in a reply
12-28-2023, 02:28 PM (This post was last modified: 12-29-2023 10:38 AM by Thomas Okken.)
Post: #18
RE: dm42decode - a command-line decoder tool
UPDATE: The tools are under Additional Downloads on my web site now.

Quote:I uploaded a zip file with the full set: raw2txt and txt2raw, Free42 and Plus42 versions, for Linux, MacOS, and Windows:

https://thomasokken.com/free42/download/...awconv.zip

Note: On my machine, the Free42 tools for Windows are shot on sight by Defender. The Plus42 tools are not. Your mileage may vary. More of those Intel-Library-induced false positives...

If people are happy with these, I'll put them up in the Additional Downloads sections of the Free42 and Plus42 home pages.

Maybe I'll end up posting only the Plus42 versions of these tools. I'm not sure how much value there is in having converters that don't handle the Plus42 extensions.
Visit this user's website Find all posts by this user
Quote this message in a reply
12-28-2023, 05:10 PM
Post: #19
RE: dm42decode - a command-line decoder tool
(12-28-2023 02:28 PM)Thomas Okken Wrote:  I uploaded a zip file with the full set: raw2txt and txt2raw, Free42 and Plus42 versions, for Linux, MacOS, and Windows:

MERCI !!!
Everything works on Windows.
No "usine à gaz": no "make" needed, no installation of Linux under Windows: just a simple executable!
Perfectly perfect.

http://ti58c.phweb.me
http://clones.phweb.me
http://www.instagram.com/ti58c
"No! Do or Do not. There is no try!" [Master Yoda]
Visit this user's website Find all posts by this user
Quote this message in a reply
12-28-2023, 11:30 PM
Post: #20
RE: dm42decode - a command-line decoder tool
(12-28-2023 02:28 PM)Thomas Okken Wrote:  Maybe I'll end up posting only the Plus42 versions of these tools. I'm not sure how much value there is in having converters that don't handle the Plus42 extensions.

Since Free42 is a proper subset of Plus42 (I think?!?), won't the Plus42 versions work for both kinds of users?

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 10 Guest(s)