Focal (HP-41)

For the FOCAL language on DEC minicomputers, see FOCAL (programming language) and FOCAL-69.

FOCAL (Forty-one calculator language) is the language used to program the HP-41 range of expandable science/engineering calculators from Hewlett-Packard.

As with most other calculator programming languages of the 1980s, 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. Besides that, the use of GOTO instructionsincluding going to a program step based on a value in a data register ("GTO IND"), a technique known as computed goto, easily led to 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 is a very simple FOCAL program:

 001 LBL "DOUBLE"
 002 2
 003 *
 004 END

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 code, no reported program actually reached this number of steps.

See also

This article is issued from Wikipedia - version of the 10/27/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.