FOCAL (Hewlett-Packard)

From Wikipedia, the free encyclopedia
  (Redirected from Focal (HP-41))
Jump to navigation Jump to search

FOCAL (Forty-one calculator language)[1][2][3] 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 instructions—including 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
  • The LBL "DOUBLE" instruction is a label, indicating that the user can invoke the program by XEQ "DOUBLE". The name "DOUBLE" can also be assigned to any key on the user keyboard, effectively adding a new function to the calculator.
  • The next two steps correspond to what the function does, mainly multiply the X register by 2 (the HP-41 uses Reverse Polish 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 code, no reported program actually reached this number of steps.

See also[edit]

References[edit]

  1. ^ "Series 40 File". Professional Computing Magazine. John Wiley & Sons. 1 (3): 65. August 1984. […] The June-August 1982 issue of HP Key Notes had a "Name-That-Language" contest for the keystroke code used on the 41. FOCAL, for Forty-One Calculator Language, was the winning entry. Although not widely recognized due to lack of publicity, it was supposed to be, and yet may become, the common description for standard keystroke language. […]
  2. ^ Extend you HP-41. 1985. p. 12. (NB. Mentions "FOCAL".)
  3. ^ HEPAX manual. 2. 1988. p. 16 (95). […] Forty One CAlculator Language […]

Further reading[edit]

  • Horn, Henry C., ed. (November 1982). "(no title)". HP Key Notes. 6 (4). […] In Vol. 6 No. 3 on page 16, we initiated a "Name That Language Contest," which was our way of inviting the readership the language used by the HP-41. While choosing a winner, we ran into some unexpected problems; namely, that some of the best names were already being used as trade-names or trademarks by other companies. So we have had to initiate a trade-name search before the winner can be announced. We will notify the winner by mail as soon as possible, and we will publish the winning name and the winner's name in a future issue of the Portable-Computation Guide. […] (NB. According to the Computing Information Directory the announced Portable-Computation Guide was never actually published.)
  • Bugg, James (January 1984). "(no title)". PPC Calculator Journal. 11 (1): 7. […] 2. Question - Did HP ever decide on a "language" acronym for the HP-41? […] Ed note - (2) Yes, Henry Horn will announce this somehow. I will report the winner when I can. […]

External links[edit]