HP41 Program "Decompiler"



#2

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.

Disadvantages:

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.


#3

I have been working on and off on code that also does this.

The major problems for me are the common characters used by the HP41 that have no obvious replacements in normal characters.

I refer to the append character, and sigma. The append character is probably the worst as it appears frequently enough in normal (i.e. non-synthetic) programs. In addition it has a rather specific symbolic meaning that is not made any clearer by printing the value in hex.

One of the problms you'll find with converting XROM codes to mnemonics is that several modules use the same XROM codes.


#4

Steve raises some very good points about printing a program listing:

1. How to print out 'append' and 'sigma', very common yet important characters, or other special characters. 2. Multiple modules with the same XROM number.

Luckily(?) for me, my listings are concatenations of strings from "MS Excel" worksheet cells. As such, I can put anything of any length in the appropriate master lookup cell. So, for problem #1, and a step of ("append-character" =) my listing might show

104 "'app'="

just like that. Sure 'app' is not as concise as the real thing, but it's enough to let me know what it is. Similar adjustments can be made for all the other non-displayable characters.

For problem #2, I envision that I can leave the XROM xx, yy as it is, but print out a list of all the possible XROM functions (ModName:CommName) it could be to the right of the program line on the 8.5x11 (or A4!) paper. I see a max of 3 possible duplicate XROM functions - plenty of space for that - then the reader of the listing can decide by context what the command should be. Maybe not too elegant, but I can think of a lot worse!

Dan


#5

How about a tilde (~) for the append character. It's not used very often, and a text line in a listing like

"~blabla"

is clearly ment to be appendet. Isn't it?

Ciao.....Mike


Possibly Related Threads…
Thread Author Replies Views Last Post
  HP Prime: run a program in another program Davi Ribeiro de Oliveira 6 2,786 11-11-2013, 08:28 PM
Last Post: Davi Ribeiro de Oliveira
  [hp41] reading the catalog under program control Wolfgang 3 1,602 02-25-2013, 01:32 PM
Last Post: Dan Grelinger
  HP41 Blank formulars for program documentation? Wolfgang 3 1,552 02-15-2013, 11:08 PM
Last Post: Wolfgang
  OT: HP RMBASIC Csub Translator/Decompiler Rodney W Young (PA-USA) 0 865 05-19-2012, 08:51 PM
Last Post: Rodney W Young (PA-USA)
  HP-41 Focal Compiler/Decompiler MichaelG 0 930 02-14-2012, 11:30 AM
Last Post: MichaelG
  HP-41 MCODE: Making an MCODE program call another MCODE program Geir Isene 10 2,947 01-13-2008, 05:58 AM
Last Post: Raymond Del Tondo
  Scan / PDF / text file of HP41 application pac program listings? Gene 10 3,107 05-30-2007, 09:56 PM
Last Post: Les Wright
  CH136 - Chess program for HP41 now on Internet Claude Roeltgen 1 825 12-18-2003, 11:55 AM
Last Post: Ángel Martin
  Hp41 Program question Greg Atkins 21 4,358 07-02-2003, 05:55 PM
Last Post: David Smith
  HP41 Unit conversion program? Peter Greb 5 1,532 11-15-2002, 10:35 AM
Last Post: Peter Greb

Forum Jump: