HP-41C
The HP-41C series are programmable, expandable, continuous memory handheld RPN calculators made by Hewlett-Packard from 1979 to 1990. The original model, HP-41C, was the first of its kind to offer alphanumeric display capabilities. Later came the HP-41CV and HP-41CX, offering more memory and functionality.
The alphanumeric "revolution"
The alphanumeric LCD screen of the HP-41C revolutionized the way a pocket calculator could be used, providing user friendliness and expandability. By using an alphanumeric display, the calculator could tell the user what was going on: it could display error messages, such as showing upon attempting to divide by zero instead of simply displaying a blinking zero; it could also specifically prompt the user for arguments instead of just displaying a question mark.Earlier calculators needed a key, or key combination, for every available function. The HP-67 had three shift keys ; the competing Texas Instruments calculators had two and close to 50 keys. Hewlett-Packard were constrained by their one byte only instruction format. The more flexible storage format for programs in the TI-59 allowed combining more keys into one instruction. The longest instruction required eleven keypresses, re-using the shift keys four times. The TI-59 also made use of the key followed by two digits to access another 40 different functions, but the user had to remember the codes for them. Clearly, a more convenient and flexible method of executing the calculator's instructions was needed. The HP-41C had a relatively small keyboard, and only one shift key, but provided hundreds of functions. Every function that was not assigned to a key could be invoked through the key and spelled out in full, e.g. FACT for the factorial function.
The calculator had a special user mode where the user could assign any function to any key if the default assignments provided by HP were not suited to a specific application. For this mode, the HP-41C came with blank keyboard templates; i.e. plastic covers with holes for the keys, so the user could annotate customized keys. Hewlett-Packard even sold a version of the calculator where hardly any keys had function names printed on them, meant for users who would be using the HP-41C for custom calculations only ; this version of the calculator was colloquially known, within HP's Corvallis calculator team, as a "Blanknut".
Alphanumeric display also greatly eased editing programs, as functions were spelled out in full. Numeric-only calculators displayed programming steps as a list of numbers, each number generally mapped to a key on the keyboard, often via row and column coordinates. Encoding functions to the corresponding numeric codes, and vice versa, was left to the user, having to look up the function-code combinations in a reference guide. The busy programmer quickly learned most of the codes, but having to learn the codes intimidated the beginners. In addition to this, the user had to mentally keep function codes separate from numeric constants in the program listing.
The HP-41C displayed each character in a block consisting of 14 segments that could be turned on or off; a so-called fourteen segment display. The HP-41C used a liquid-crystal display instead of the ubiquitous LED displays of the era, to reduce power consumption.
While this allowed the display of uppercase letters, digits, and a few punctuation characters, some designs needed to be twisted arbitrarily and lowercase letters were unreadable. HP's competitor Sharp, when introducing the PC-1211, used a dot matrix of 5×7 dots and displayed the characters in principle as we see them today on computer screens ; this was later used by HP with the HP-71B handheld computer.
The HP-41CV and CX
Many users had used all four ports for memory expansion, leaving no room for other modules. HP designed the Quad Memory Module with four times the amount of memory, providing the maximum available memory and leaving three empty ports available. The HP-41CV included this memory module on the main board, thus providing five times the memory of the HP-41C, and four available slots.The internal architecture prohibited the addition of more memory, so HP designed an extended memory module that could be seen as secondary storage. The data could not be access directly, but it was possible to transfer data to and from main memory. To the calculator, data located in the extended memory looked like files on a modern hard disk do for a PC.
The final HP-41 model, the HP-41CX, included extended memory, a built-in time module, and extended functions. It was introduced in 1983 and discontinued in 1990.
Programming
The HP-41C is keystroke programmable meaning that it can remember and later execute sequences of keystrokes to solve particular problems of interest to the user. These keystroke programs, in addition to performing any operation normally available on the keyboard, can also make use of conditional and unconditional branching and looping instructions, allowing programs to perform repetitive operations and make decisions.The HP-41C also supports indirect addressing with which it is possible to implement a Universal Turing machine and therefore the programming model of the HP-41C can be considered Turing complete. The combination of indirect addressing and gotos easily led to spaghetti code.
Program steps are numbered starting from 1, but this numbering has no intrinsic meaning and changes as new instructions are added or removed in the middle of a program. A special LBL instruction is used to create a label that is then referenced by the user to invoke the program, or by the program itself as target of a GTO or XEQ instruction.
Programming example
Here is a sample program that computes the factorial of an integer between 1 and 69. The integer is entered in the X register and passed as an input parameter when the program is run. The program takes up two registers, which is ≈14 bytes.Step Op-code Comment
01 LBL'Fac ALPHA global label makes program callable by 'XEQ Fac'
02 STO 00 Store X=input parameter in register 00
03 1 Enter 1 in X, "lifting", or "pushing", the stack: Y=input parameter
X=1
04 LBL 00 Local label for goto
05 RCL 00 Recall register 00 into X, lifting the stack: Z=input parameter
Y=1 or interim or final factorial
X=input parameter minus effect of DSE command
06 * Multiply X and Y, "dropping", or "popping", the stack: Y=input parameter
X=interim or final factorial
07 DSE 00 Decrement register 00 and Skip next command when register value is Equal to 0
08 GTO 00 Go to local label 00
09 END End program - X=final factorial
FOCAL
Though the programming language used on the 41 series is a version of the keystroke programming languages used in all preceding programmable HP calculators, the range of technologies, and programming-related usability and extensibility features available in 41 series models, led some users to propose a new name for the language, resulting in a competition that was won by "FOCAL" for "Forty One Calculator Language". As the name FOCAL was already in use by the Digital Equipment Corporation, the name was never formally adopted by HP.Synthetic programming
A large user community was built around the HP-41C. Enthusiasts around the world found new ways of programming, created their own software and expansion modules, and sped up the clock. Most of these activities were coordinated by the PPC club and its president, Richard J. Nelson. The PPC club published the PPC Journal and produced the PPC ROM, a collection of highly optimized low-level programs for the HP-41C.One of the discoveries of the community was that, because some FOCAL instructions were stored in memory as more than one byte, it is possible to exploit a bug in the program editor to assign strange functions to keys. The most important function was known as the byte jumper or byte grabber, a way to step partially through programming instructions and edit them in ways that were not otherwise allowed. The use of the resulting instructions was called synthetic programming.
Through synthetic instructions, a user could access memory and special status flags reserved for the operating system, and do very strange things, including completely locking the machine. It was possible to create sounds or display characters, and create animations not officially supported by the operating system. The system flags were also accessed as low-level shortcuts to Boolean programming techniques. Hewlett-Packard did not officially support synthetic programming, but neither did it do anything to prevent it, and eventually even provided internal documentation to the user groups.