HP Forums

Full Version: Keystroke Programming: Labels vs. Line Numbers
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Which do you prefer:

Line Numbers (i.e. GTO 150)
Labels (i.e. LBL A, GTO A)

Or do you have a preference in keystroke programming?

HP calculators that use line numbers: 33C, 33E, 25C, 12C, 35S, 16C (?)
HP calculators that use labels: 33S, 32SII, 15C, 41, 42S, 35S
(yes 35S does both, not a typo)
Definetely, labels. They make much more easy to modify programs!
Labels unless line numbers GTOs self modify during editing.
(11-04-2014 02:07 PM)Eddie W. Shore Wrote: [ -> ]Which do you prefer:

Line Numbers (i.e. GTO 150)
Labels (i.e. LBL A, GTO A)

Or do you have a preference in keystroke programming?

HP calculators that use line numbers: 33C, 33E, 25C, 12C, 35S, 16C (?)
HP calculators that use labels: 33S, 32SII, 15C, 41, 42S, 35S
(yes 35S does both, not a typo)

Are you serious?!? Wink

Labels, of course.
Labels, unless the number of labels is limited compared to the programming steps available.

That's one reason the 35S did labels and line numbers within labels (which idea I had a hand in, FWIW). The paradigm for single letter alpha labels could not be changed within the budgeted timeframe, but the suggestion of sightly modifying the GTO and XEQ instructions to allow for A003 as a destination could be done. The self-modifying nature of the code so that A003 would change to A004 in a GOTO if you added a step at A002, etc, was a suggestion I made that was readily adopted.

I believe it contributes greatly to using the 32K of ram much better than merely having 26 alpha labels would have.

Would expanded labels have been better than Label/StepNumber? Sure. As a compromise when that was not available, I believe still it was a very good choice.

All made very bad by the checksum bug which went unnoticed. I am really sorry to say that was right in front of some of us and we didn't notice it. For that, I really am still upset.
Labels, all the way! I find the 12C painful to program, for just this reason. The shifting nature of line numbers requires a "two-pass" approach to writing and entering a program, which labels do not suffer from.

Even the 71B's BASIC, which supports line numbers - with automatic line renumbering - as a destination, also supports alpha labels. They convey more meaning, making them cognitively easier to deal with.
My vote is label.
Labels are easier to deal with, when writing the program.
when the program is done/cleaned/debuged, line number is more efficient, but less readable.
aka wp34S
(11-04-2014 02:07 PM)Eddie W. Shore Wrote: [ -> ]Which do you prefer:

Line Numbers (i.e. GTO 150)
Labels (i.e. LBL A, GTO A)

Or do you have a preference in keystroke programming?

HP calculators that use line numbers: 33C, 33E, 25C, 12C, 35S, 16C (?)
HP calculators that use labels: 33S, 32SII, 15C, 41, 42S, 35S
(yes 35S does both, not a typo)
16C is Labels !
Labels, for sure! Even HP-71 BASIC allowed GOTO labels because they are so much nicer than meaningless line numbers:

10 GOTO 'QUIT'
20 'QUIT': END

Silly example, but it illustrates the syntax.
(11-04-2014 02:07 PM)Eddie W. Shore Wrote: [ -> ]HP calculators that use line numbers: 33C, 33E, 25C, 12C, 35S, 16C (?)
HP calculators that use labels: 33S, 32SII, 15C, 41, 42S, 35S
(yes 35S does both, not a typo)

Some calculators that use both run programs faster with absolute addresses. When they execute GTO with a label, they have to search memory for the label.
Of course editing a program with labels is much easier since you don't have to manually adjust line number references.
(11-05-2014 01:22 PM)toml_12953 Wrote: [ -> ]Some calculators that use both run programs faster with absolute addresses. When they execute GTO with a label, they have to search memory for the label.

The HP-41 seems to record the address offset when it finds a local label he first time, and subsequent times run faster since it only has to verify that it's still there instead of searching again. You lose that benefit if you have something like GETKEY followed by GTO IND X, since it might jump to a different place each time the program is run. My first programmable was a TI-58c which had to search for the label every time, so I did try to write with step numbers when possible.
The TI-95 gives you the best of both worlds. You develop the program using labels, and when you're done, there's a command that will convert all the branching instructions to absolute addresses to improve execution speed. There's also a corresponding command to reverse the process if you want to make further changes to the program. It's a pretty cool machine, despite the lack of RPN.
(11-06-2014 07:43 PM)Dave Britten Wrote: [ -> ]The TI-95 gives you the best of both worlds. You develop the program using labels, and when you're done, there's a command that will convert all the branching instructions to absolute addresses to improve execution speed. There's also a corresponding command to reverse the process if you want to make further changes to the program. It's a pretty cool machine, despite the lack of RPN.
Would be nice to have the same functionality on the wp-34s
(11-06-2014 09:28 PM)patrice Wrote: [ -> ]Would be nice to have the same functionality on the wp-34s

The 34S has variable length instructions so we can't just jump to an absolute address -- we'd have to search for the address from the beginning of program memory. This would almost always be slower than using a label.

Converting to BACK/SKIP is also a non-gain mostly. SKIP would be no faster since we're parsing each instruction skipped over. BACK might be a little faster but, I doubt it would be a noticeable difference in practice due to all the other overheads.

If you are so wedded to the idea of this conversion, download the 34S source code and implement it yourself Smile I am not going to since I don't see any utility in this operation. If I ever want a program with BACK/SKIP, which is rare, I use the assembler to generate the code for me.


- Pauli
(11-06-2014 09:47 PM)Paul Dale Wrote: [ -> ]If I ever want a program with BACK/SKIP, which is rare, I use the assembler to generate the code for me.

Things are a little different for ROM based programs. We call it XROM in the WP 34S. Since ROM based code doesn't change, we can precompute all jump targets. Furthermore, SKIP and BACK in XROM use absolute distances, not step counts. Of course no one ever performs these calculations manually. It's the assembler as part of the build process that does all the tedious counting for us.
I use both a physical 35s, and Free42 on my phablet.

The labelling system used by the 35s (typical use LBL A, XEQ A, GTO A123) is simple and neat, and makes possible the construction of long complex programs.

The 42s/Free42 system is obviously more powerful as it allows three forms of label (local 2-digit numeric, local single-letter in ranges A..J and a..e, or multi-letter global), but in my view a bit scattered. Numeric labels can be easily confused with line numbers; single-letter locals are limited; and you just don't put global labels inside a program.

I don't expect computer-grade facilities in a calculator. Both the 35s and 42s offer good power in a traditional package. For anything more, I'll use a computer.
Reference URL's