|Re: HP 32sII - upgrade memory to 32K?|
Message #9 Posted by John Noble on 1 Feb 2006, 1:17 a.m.,
in response to message #5 by Norris
The 33S, which is basically a 32SII with a 2-line display and 32K memory, has this problem. Even though the memory is greatly enlarged, it's difficult to load more than a few moderately complex programs into it, because you run out of labels.
It depends on how you write the programs. If you take the traditional approach of doing this:
A0001 LBL A
A0003 GTO Z
Z0001 LBL Z
... it's only nine lines of code, but you'll chew up labels in a hurry.
A far less elegant way to do it that conserves labels is to use a flag and keep testing it:
A0001 LBL A
A0002 CF 0
A0004 SF 0
A0005 FS? 0
A0007 FS? 0
A0009 FS? 0
A0011 FS? 0
A0013 CF 0
Thirteen lines, one label.
Either all the flag tests will fail and skip over the stuff in between, or all of them will succeed and the code gets executed.
Inlining subroutines like this feels cheesy and obviously won't work in a lot of situations, but there's RAM to burn and it can save a bunch of labels you'd otherwise have to waste on simple conditionals.
I probably saved 4 or so labels this way in a ~100 line program I wrote recently. The code is ugly as hell, but it computes Julian dates given a Gregorian date (the usual dd.mmyyyy, expected in stack X) and an optional time zone offset from UTC & time (tz.hhmmss, expected in stack Y) with one label. Working this way, I think I might actually run out of RAM before I run out of labels.