Focal (HP-41)The Forty-One Calculator Language (Focal) is the language used to program the HP-41 range of calculators from Hewlett-Packard.As with most other programmable calculators of the time, a Focal program is a linear list of instructions. Each instruction (or step) roughly correspond to a key (or key combination) press, and thus correspond to what the user would do if he was to perform the computation himself on the calculator. This paradigm made Focal programming relatively easy for the newcomer, but program maintenance could be a nightmare. Add to that the use of GOTO instructions (including going to a step based on a value in a data register - the GTO IND instruction) and you had all the ingredients for the dreaded spaghetti code. Program steps are numbered starting from 1, but this numbering has no intrinsic meaning, and can change as new instructions are added or removed in the middle of a program. A special instruction LBL is used to create a label, that can be used by the user to invoke the program, or by the program itself, as target of a GTO (unconditional go-to) or XEQ (execute) instruction. Here's a very simple Focal program :
001 LBL "DOUBLE" 002 2 003 * 004 ENDThe LBL "DOUBLE" instruction is a label, indicating that the user can invoke the program by XEQ "DOUBLE". As this function can also be assigned to any key on the calculator's keyboard, this effectively adds a new function to the calculator. The following steps correspond to what the function does, mainly multiply the X register by 2 (remember, the HP-41 uses RPN notation.) The END instruction indicates the end of the program. Note that contrary to many other programmable calculators, each Focal step could be stored in memory as more than one byte. While the calculator memory could hold 2233 bytes of program, no actual program acually reached this number of steps. |
||
"To love oneself is the beginning of a lifelong romance" - - Oscar Wilde (1854-1900) |
