Re: 41 RPN LBL GTO rules Message #3 Posted by Raymond Del Tondo on 7 Mar 2009, 7:51 p.m., in response to message #1 by Egan Ford
Hello Egan,
re-using local labels inside a FOCAL program is a common technique.
You can save bytes (or reduce program size) if you manage
to use the one-byte local labels 00-14 more than once,
instead of local labels like LBL 22, which take two bytes of memory.
Also, the associated GTO's use two bytes for label 00-14,
but three bytes for numeric labels above 14.
As you know, the primary search direction is forward,
so when a GTO <local> is encountered the first time the program is
run (or after an edit or GTO..), the OS will search for a suitable label,
from the current PC ot the end, and then from the start of the prog.
If found, the offset will be noted in the label opcode,
so the next time the program is run a jump to the label will be faster.
Also note that the two-byte GTO's have a restricted offset field,
so farther jumps will have to be computed each time.
IIRC, the translator ROM produces at least an intermediate file
before actually compiling the FOCAL program.
This processing stage would be a point to jump in.
But for FOCAL programs of which you plan to convert them to FORTH anyway,
I'd replace the duplicate local labels on the HP-41 beforehand.
Just take care to adjust the correct GTO/XEQ statements.
Also be aware of another potential obstacle:
Many HP FOCAL programs make use of indirect addressing.
This feature works for jumps, too!
Something like XEQ IND X will jump to the label whose name or number is in X.
There may be more tricks to be aware of, but I don't have them handy right now:-)
HTH
Edit: Thomas' response was earlier and more precise in less words;-)
Edited: 7 Mar 2009, 7:57 p.m.
|