I’m sharing information on the structure of HP48 ASCII headers, sourced from a FAQ available here, I decided to repost it because I used this function with success in particular to copy to emulators that do not support Kermit transfer but allow a copy paste, I can then encode the program as ASCII and put in on the stack and then it can be converted back.
My purpose in doing so is to detail a method I’ve personally found effective for transferring programs to emulators that do not support the Kermit transfer protocol but do permit copy-pasting. This involves encoding the program in ASCII format for transfer, then decoding it back on the emulator. It’s important to note that this is purely a description of what has worked for me. I am not advocating for or recommending this approach due to the potential risks involved, including the loss of memory I experienced during my attempts.
Sending an HP48 GX object via electronic mail can be difficult if the object does not have an ASCII form, such as is the case for library objects.
The programs are nominally called →ASC
and ASC→
. The former takes an object from the stack and converts it to a string, in which each nibble of the object and its checksum is converted to a character 0-9 or A-F. (The object must be in RAM, otherwise a “ROM Object” error is returned.) For sake of easy inclusion in e-mail letters, the string is broken up by linefeed characters after every 64 characters.
ASC\->
is the inverse of →ASC
: it takes a string created by →ASC
and converts it back into an object. When the encoded strings is trasmitted, the string shouldn’t be changed; ASC→
uses the checksum encoded in the string to verify that the decoding is correct. An "Invalid String"
error is returned if the result object does not match the original object encoded by →ASC
. When a string is uploaded to a computer, HP48 mode 3
is recommended so that the HP48 will convert any CR/LF’s back to LF’s when the string is later downloaded.
Two versions of ASC→
are listed here. The first (P1
) is in HP48 user language, using SYSEVAL
to execute system objects. P2
is a string that the setup program uses P1
to decode into an executable ASC→
- then P1
is discarded. The second version is more compact than the first, and also uneditable and therefore safer (but it can’t be transmitted in ASCII form, which helps to make the point of this exercise).
How I installed these functions:
CONV
.CONV
text file to the 48, and verified its checksum (6C8Ah).CONV
to make it the current directory.SETUP
.CONV
now contains ASC→
and →ASC
, ready to use.I finally archived the decoded versions of ASC→
and →ASC
on my computer, setting the HP48 SX in binary transfer mode before uploading.
Many documents make references to the “checksum” of an object. This is a 16-bit user binary resulting from a CRC calculation on the contents of an object. This binary is supposed to be relatively unique, with only 1 change in 65536 of accidental equal checksums on two different objects. This allows to distinguish programs that look the same but may be quite different (even if the size of them is the same). It is also often used to verify the correct transmission of files.
It is possible to calculate the checksum of an object using the BYTES
command. This will return on the stack two things - the size of the object in bytes on level 1, and the checksum on level two. Note that while the checksum of a variable name is the same as running the checksum on the object itself, the sizes will be differ by 4.5 bytes + the size of the variable name itself.
In rare cases the checksum of two objects can be the same, even if the objects are different. This is due to the limited nature of the HP48’s checksum function.