Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ASC for HP49, Here & Hidden programs

27 views
Skip to first unread message

John H Meyers

unread,
Dec 24, 1999, 3:00:00 AM12/24/99
to
To permit small binary files to be posted, emailed,
or even typed into a calculator by hand, Bill Wickes of HP
created the HP48 ASC format, which is a hex dump of an object,
broken into lines of manageable width, including a
checksum which can be verified before restoring the object;
further details may be found in the comp.sys.hp48 FAQ.

Here is something very similar for the HP49, aided by
the new internal functions ->H and H-> of library 256;
unfortunately, those functions by themselves do not
"wrap" long hex strings into shorter lines, and they
do not check the encoded string at all for validity
when restoring an object (neither to validate
nor to bypass characters that are not hex digits, nor
to check that the final object is valid and not corrupt).

The following programs therefore perform "line wrapping"
for convenience in posting and mailing,
and add a checksum test (this checksum is
the checksum of the string object made by ->H,
rather than the checksum of the original object).

ASCO replaces ->ASC as a function to encode binary objects
as hex strings, and ASCI replaces ASC-> as a function
to decode hex strings to re-create binary objects.

Need we say more?

Well, just make sure to have performed HOME 256 ATTACH
before downloading (or typing) into your calc.

If you download what follows using Kermit,
give it any name and just execute it; this will create
the two new functions ASCI and ASCO in your current directory,
after which you may discard the originally downloaded file.

HP48 binary files are still incompatible with HP49 binary files,
so this can not be used to transfer objects between HP48 <-> HP49.

You may freely insert more newline characters or spaces into
the hex strings, or adjust the output line width, if you wish
(note that the line width affects two different program constants).

As an example,
here are two small useful HP49 SysRPL programs in this format:

"D9D201DF604CE52B2130#7EB5h" @ Here

"D9D201DF603C073B2130#96C8h" @ Hidden

Here are examples of how to use these programs
(after decoding them with ASCI
and storing them with the indicated names):

\<< Hidden VARS \>>
Displays the names of variables in the "hidden directory"
(an unseen directory used by the operating system).

\<< 123 'name' Hidden STO \>>
Stores 123 into 'name' in the hidden directory
(similarly you can use RCL and PURGE in place of STO).

Caution: Do not purge or modify any of the last three
"reserved variables" used by the operating system.

\<< "VARS" Hidden OBJ\-> \>>
Normally, "VARS" OBJ\-> would execute the VARS command,
but when OBJ\-> is performed in the "hidden context,"
built-in commands are not executed (they are instead
compiled as names); this could be used as a safer way
to evaluate strings returned by INPUT commands.


Create a subdirectory to try out the following programs,
e.g. 'MyDir' CRDIR (or use the Filer to create it),
and then first go into that directory before
creating any of the following programs:

\<< 'VX' Here VTYPE \>>
\<< 'VX' Here RCL \>>
\<< 'VX' Here EVAL \>>

If the variable does not exist in the current directory,
normally any higher directories are searched for it;
however, the 'Here' program prevents any higher
directories from being searched, in case you want
to prevent variables in higher directories
from being used by default.

E.g. \<< 'name' Here VTYPE \>> tells you (via a result of -1.)
if that variable does not exist in the current directory,
disregarding any higher directories.


Both 'Hidden' and 'Here' act on the next single command
which follows them in a running program; they have
no effect if manually executed from the VAR menu
or by themselves in the command line.

In SysRPL, these programs are:

:: COLA WithHidden ;

:: COLA DoHere: ;

Although it was possible to accomplish these functions
in the HP48 by using #64037h SYSEVAL for WithHidden
and #185C7h SYSEVAL for DoHere:, you can not just
look up the new SYSEVAL addresses for the HP49
and do the same, because SYSEVAL in the HP49
will not work with functions that operate
on the subsequent words of a runstream (program),
due to the fact that SYSEVAL is now implemented
via a FlashPtr, and interposes another system program
between itself and your program.

If you download and install the "extable" library
(HP symbol tables) and use the built-in MASD assembler,
you can create SysRPL programs, or even insert SysRPL fuctions
into user programs, but the possibility of posting small
programs in an ASC type of format allows anyone to
just install them directly, without having to
install the optional 90K bytes of symbol tables and use the
assembler (which requires a cable to accomplish); it also
even allows small binary programs to be typed in by hand,
for people who have no cable, or who may not even have
the current OS version of the assembler.

-----------------------------------------------------------
With best wishes from: John H Meyers <jhme...@mum.edu>
-----------------------------------------------------------


%%HP: T(3)F(.); @ an HP49 style of ASC encoding, with checksum

@ Attach library 256 before loading into calc
@ E.g. HOME 256 ATTACH


\<< RCWS 16. MAX STWS
\->H DUP BYTES DROP SWAP @ checksum (any base)
"" SWAP WHILE DUP SIZE REPEAT
DUP 1. 64. SUB ROT SWAP + 10. CHR + @ fold to 64-char lines
SWAP 65. OVER SIZE SUB END DROP SWAP + \>>
@ 1. + 64. == 65.

'ASCO' STO @ object ==> hex string with checksum


\<< 13. CHR "" SREPL DROP @ remove <cr>
10. CHR "" SREPL DROP @ remove <lf>
32. CHR "" SREPL DROP @ remove spaces, too (why not?)
DUP "#" POS DUP2 @ look for checksum at end
1. SWAP 1. - SUB UNROT
OVER SIZE SUB "{" SWAP + STR\-> 1. GET
OVER BYTES DROP \=/ { 515. DOERR } IFT H\-> \>>
@ unequal checksum

'ASCI' STO @ hex string with checksum ==> object

@ The HP49 checksums of the above programs are:
@ ASCI # C01Ah, ASCO # 493Fh

@ End of downloadable file

Sent via Deja.com http://www.deja.com/
Before you buy.

0 new messages