HP Forums

Full Version: file format for HP48gx objects
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm using the iHP48 emulator on my iPhone configured as a HP48gx. I own a HP48sx but the keyboard is a bit flakey so the emulator is a great backup. Program works great and i'm able to save and load objects from the phone's file system into the calculator. However, i'd like to edit my HP programs on my mac then load onto my phone. The problem is i don't understand the structure of the object files. Examples attached as a zip file.

file "a" = << >> (empty program)
file "b" = << 1 'A' STO >>
file "c" = << 2 'A' STO >>
file "d" = << 1 'B' STO >>
file "e" = << 2 'B' STO >>
file "f" = << 'A' RCL >>
file "g" = << 'B' RCL >>

I would be very grateful if someone could help me understand the internals of the attached files or point me to a reference. My goal is to build a python script that can translate between ASCII representation of a program and the binary version the calculator requires.
Hi,

I'm afraid I can't help you much directly, as I only know a little about HP 48 objects myself. However, I have done some research for one of my projects, and I can tell you this: it's complicated, and there isn't really an easy way around that. You have to be able to read and deal with plain nibbles (though you probably knew that already, didn't you? Smile). As a result, it may be worth learning a bit of C, if you don't know it already, because the ability to deal with sizes of numbers and pointers will simplify the challenge quite a bit.

Since I myself am not much help, here's some resources that have helped me. One really good, though large, reference is https://www.hpcalc.org/details/4576. This documents every binary object type in the 48SX. Another source, which may be more readable, is the 3rd edition of "Introduction to Saturn Assembly Language", which I've browsed through and I know it has a chapter on objects. hpcalc.org surely hosts more information, so don't be afraid to search for what you need.

Good luck! I think that a tool like what you want to create would actually be really useful.
Thank Liam. This was very helpful. I'm already noticing a pattern. It seems some of the byte code is written in the reverse order!

Daniel
(07-06-2021 07:43 PM)djb146 Wrote: [ -> ]My goal is to build a python script that can translate between ASCII representation of a program and the binary version the calculator requires.

This would be far more involved than you may realize. Objects that are stored on an RPL calculator are stored in a compiled format. They are only in ASCII form while you are editing the object using the standard editing features on the calculator. As soon as you are done editing, the object is actually compiled into a binary form. All objects (other than strings) are stored in binary form on the calculator.

EDIT: That last sentence is probably misleading. Strings are actually stored in compiled form as well, but they are simply easier to open/view on other systems. The mapping of special RPL characters is unique, so some of the characters won't look the same on another platform as they do on the calculator.

See the two commands →STR and STR→ for a built-in way to translate User RPL objects on the calculator to and from ASCII form.
Thanks for the info David. I don't have the time or interest to build a compiler from scratch so i'll have to find a work around. The ->STR and OBJ-> commands may be a workable solution. The quest continues ...
Thank you all. Problem mostly resolved. First, I switched to the HP48sx emulator on iHP48. From there I was able to use the DOS-based HP-48.exe (v2.61) compiler (HP-48.exe) inside "DOSBOX". Once compiled, i copied the program from my Mac to my iPhone and into a directory the iHP48 could use.

Not ideal but satisfactory.
Reference URL's