Appendix G
Advanced Programming and Operation
There are several features on the HP-41C that offer significant power and convenience in the operation of the calculator. As you become more interested in the HP-41C and how it works, you may wish to know more specifically how some features work.
Label Searching
Earlier in this handbook it was mentioned that the HP-41C could remember the location of most labels in program memory. More specifically, the HP-41C has been designed to remember the location of all labels depending on their location in a program and how they are used. The calculator can only remember a numeric label location after the first execution of that label. Subsequent branches to that label are much faster because the HP-41C does not need to search (in most cases).
Labels 00 through 14 are called short form labels. They use only a single byte in program memory (there are seven bytes per register). When a program branches to LBL 00 through LBL 14 using a GTO instruction, the calculator can remember the location of these labels if they are located 112 bytes before or after the GTO instruction. If the short form label is beyond 112 bytes from the GTO , the calculator must search sequentially for that label. So if you are concerned about the speed of execution, you should examine your program and determine the location of branches and corresponding labels.
Labels 15 through 99, on the other hand, are not short form labels. They require two bytes in program memory. However, the location of these labels is always remembered by the calculator, regardless of their location in a program.
The location of all numeric labels ( LBL 00 through LBL 99) is remembered by the calculator when the program branches using XEQ .
The HP-41C handles branches to ALPHA labels in a unique way. As soon as an ALPHA label is keyed into a program, the calculator records that label and its location in such a way that each ALPHA label knows where the next ALPHA label is located. A GTO or XEQ of an ALPHA label then causes the HP-41C to search from ALPHA to ALPHA label for the ALPHA name. The HP-41C then branches to the corresponding location in program memory. The ALPHA label search is from the bottom-most program in program memory to the top-most program. The result is a search of the last programs first. This ALPHA label search scheme increases the speed of execution by decreasing search time.
259