[WP34s] About SKIP and BACK



#10

I found it already a bit strange when SKIP and BACK were extended to a range of 255 instead of 99 - we've always been told that long SKIPs/BACKs should be replaced by GTO labels, and that's in fact true: changing anything within this range would need to count all jumps again.

But now (with todays ASM tool) it's indeed necessary to change all SKIP xx by SKIP 0xx (same for BACK) - it just doesn't accept 2-digit jumps anymore! :-(

That's really a bit annoying - it requires to change all existing sources and you can't simply make sourcefiles compatible anymore for V2 and V3 versions of WP34s!

So I would suggest to either undo these changes for SKIP and BACK again (i.e. going back to 2-digit addresses) or make the ASM tool a bit more tolerant so that it would accept xx and xxx as jump addresses.

Franz


#11

It does still accept 2-digit offsets for V2 code (or more correctly, older wp34s.op files).

The problem is (fully documented in the ASM manual) that the instruction format comes directly from the wp34s.op file. If that file generates an instruction with a 3-digit number, the assembler will be looking for a 3-digit number***. That is the price we are paying to have an assembler that will accept new instructions that were not ever dreamed up when the tool was written. Putting in exceptions to the rule tends to break new, upcoming features.

Technically, a 2-digit BACK/SKIP instruction does not exist in the current machine anymore.

Rather than using SKIP/BACK, use JMP and a symbolic label instead and feed this through the PP. That tool will correctly create 2-digit numbers for V2 code (or older wp34s.op file) and 3-digit numbers for V3 code. If your offset exceeds the maximum allowed, the tool will automatically switch the instruction to a GTO and insert a LBL at the appropriate target location.

PP has the other benefit that if you come back to your code and inject a few more steps between your branch and your target at a later date, PP will regenerate the correct branch offsets for you (or "promote" it to a GTO/LBL) automatically. It also alleviates the need for you to count steps -- which is even more important when the offset limit is north of 200 steps (I guess that should be "south" for those Australians among us)!

Additionally, many of us feel that the PP-ready JMP is much more readable and self documenting than using BACK/SKIP instructions.

In the meantime, you can use this little ditty to convert your older code to the newer style if you want. Simply run it as a filter:

$ skip2.pl < old.wp34s > new.wp34s

(Hopefully there are no bugs :-)

#!/usr/bin/perl -w
# Convert 2-digit BACK/SKIP to 3-digit versions.
while (<>) {
# Look for any 2-digit BACK/SKIP instructions.
if (/(SKIP|BACK)\s+(\d{2})($|\s+)/) {
my $offset2 = $2;
my $offset3 = sprintf "%03d", $offset2;

# Replace the 2-digit SKIP/BACK with a 3-digit variant.
# Be careful to put the white space back exactly as it was found!
s/(SKIP|BACK)(\s+)${offset2}/${1}${2}${offset3}/;
}
print;
}


*** This is a consequence of the instruction lookup method used. A table is built from wp34s.op with all legal instructions (eg: SKIP 000, SKIP 001, etc.). The source instruction is parsed out of the source line and an explicit match is attempted against the legal instructions.


#12

Quote:
It does still accept 2-digit offsets for V2 code (or more correctly, older wp34s.op files).

Ok, I just thought that with all the powerful possibilities of Perl it won't be difficult to accept such 2-digit offsets for SKIP/BACK (maybe even for other commands) in all cases by simply replacing "SKIP xx" with "SKIP 0xx".

#13

OK, since I was working it that area anyway, I decided I might as well just slurp that little fragment into the main script and do this for you on-the-fly.

You can add the "-sb2to3" switch to either LIB or ASM and it will do the conversion of BACK and/or SKIP from 2-digit to 3-digit on any instances it encounters.

However, the best approach is still to port your code to PP where all that messy stuff is done for you magically...


#14

Quote:
OK, since I was working it that area anyway, I decided I might as well just slurp that little fragment into the main script and do this for you on-the-fly.

Great service, many thanks! :-)

Franz


#15

Neil, just 2 little 'cosmetic' problems:

1) PP script: in the helptext for the -v3 option the letters in "enhancement" are a bit mixed-up ;-)

2) ASM & LIB script: my perl2exe doesn't like one line in your helptext for the new -sb2to3 option: it thinks that "use with old-style V2 ..." should include a module 'with.pm' - what a stupid compiler! ;-)

Maybe you could change the line-wrapping in these 2 scripts a bit when you make your next changes ... ("use with" shouldn't be the first text in a line).

Franz


#16

Thanks. Done.


Edited: 9 Jan 2012, 6:37 a.m.


#17

Hey, I just saw this in the SVN:

"Pull in Marcus' really bright idea about zero extending instructions and re-search
the instruction hash. Allows coding source with things such as "RCL 4"."

Great, that's much better than -sb2to3. :-)

I guess this also works for SKIP 05 (and even SKIP 5) --> SKIP 005.

Then you could remove this -sb2to3 option again. ;-)


#18

Yup!


Possibly Related Threads…
Thread Author Replies Views Last Post
  Getting back to the CL Geir Isene 6 2,220 03-20-2013, 07:02 PM
Last Post: Geir Isene
  [WP34S] WP34S firmware on the AT91SAM7L-STK dev kit? jerome ibanes 1 1,248 10-04-2012, 04:59 PM
Last Post: Paul Dale
  HP-11C Back Screws John Swisher 0 1,315 09-12-2012, 10:52 AM
Last Post: John Swisher
  I am back ;) with a problem on HP 41 ;( wildpig 7 2,283 07-09-2012, 11:30 AM
Last Post: Mike Morrow
  [WP34S] Inverse F Distribution--Danged "Domain Error" Issue is Back Les Wright 16 4,673 05-23-2012, 10:28 PM
Last Post: Les Wright
  Back with my DEG<->DMS formulas ! PGILLET 5 1,822 05-03-2012, 07:44 PM
Last Post: Bart (UK)
  15c LE back at HP Neil Carlson 4 1,716 03-27-2012, 04:56 PM
Last Post: Harald
  15C back in stock at hp.com sjthomas 8 2,634 12-22-2011, 10:32 AM
Last Post: Dan Grelinger
  [wp34s] Incomplete Gamma on the wp34s Les Wright 18 5,349 12-06-2011, 11:07 AM
Last Post: Namir
  [wp34s] Romberg Integration on the wp34s Les Wright 2 1,520 12-04-2011, 10:49 PM
Last Post: Les Wright

Forum Jump: