|HP41 Program "Decompiler"|
Message #1 Posted by Dan McDonald on 24 June 1999, 8:24 p.m.
HP41C code "Decompiler"
I've just spent a bunch of time writing a code "decompiler" for HP-41 programs that runs on the PC. This code will take 41C/V/X binary program files and print out a HP41 program listing. Probably somebody has done this in the past, but I found it a good way to learn both some 41C internal workings and some mainstream software.
This "decompiler" assumes that the binary program resides in a DOS file somewhere. How'd it get there? Well, from the HP-IL, either via the 82973 Interface Board, or the 9114 disk drive. There are plenty of these files available on the ftp server ( ftp://ftp.math.jyu.fi/pub/hpil )
While this may not seem useful to anybody but me :-), I'm finding it a helpful tool to figure out what all those files I got from the ftp archive might do. If anybody else might find such a tool useful, we can discuss it here or via email.
I have another, simpler program that will lop off the extraneous header info in the DOS/LIF file (if it was created by the HP82973 board - all the ones on the ftp archive site were) while remembering the important pieces. This allows those (like me) who don't have the interface board but DO have a disk drive to easily send these files to the HP41 (or 71 or 75...)and have them work as programs (or lex files or whatever).
My code is written in "MS Visual Basic" to run within "MS Excel," but I'm sure it could be made to work in other environments. I just went with what was available to me. Discussions of evil empires and world domination through proliferation of mundane software should be taken somewhere else....
Advantages of my decompiler code:
Will take a binary 41 program file in DOS and create a correct DOS text HP41 program listing. This is much faster (and sometimes handier) than using the HP-41 itself to drive other printers.
You've got to have a way to get the file from the HP-41 to DOS. This means extra hardware - HP-IL and a 9114 disk drive or the 82973 interface board, or some other creative interface.
Right now, it will print out only the XROM numbers (XROM xx, yy) but doesn't tell you what the program is. It is easy to ID the module numbers (xx), but I don't have a Synthetic Quick Reference Guide (Jeremy Smith) to get to the detail of all the program numbers (yy). I do have a moderate supply of modules that I will use to automatically add their correct info to the printouts as time allows, but it is far from complete.
Doesn't print out all printable or displayable characters. Easy enough to insert the byte hex value on the printout, or whatever else would make it useful. Synthetic text strings are the worst, but that's pretty much the case for all program listings I've seen so far.
It's not yet the user-friendliest, but there's always room for improvement, isn't there? I won't have a lot of time to dedicate to this project for some time to come, so I thought I'd take a pause for now and see what happens.