Keystroke programming

Last updated

Keystroke programming describes a specific way of programming by which each keystroke on a device or application is recorded in some way and then played back so that the recorded key-presses can be repeated multiple times. Keystroke programming is most commonly but not exclusively found in programmable calculators, but there are keystroke-programmable software applications, too, for example Vim (text editor) [1]

Contents

Example: TI Calculators

The TI-58C TI58c.jpg
The TI-58C

The Texas Instruments TI-58/TI-58C/TI-59 calculators were programmable, and program storage took the form of a sequence of codes which (mostly) corresponded to the position of keys on the calculator keypad. Here is a simplified diagram of the basic key layout:

 x1x2x3x4x5
1x A  B  C  D  E 
2x2ndINVlnxCECLR
3xLRNx⇌tx2x1/x
4xSSTSTORCLSUMyx
5xBSTEE (  )  ÷ 
6xGTO 7  8  9  × 
7xSBR 4  5  6  - 
8xRST 1  2  3  + 
9xR/S 0  . +/- = 

Each key is assigned a two-digit code; for most (but not all) keys, the tens digit comes from the row number (as indicated down the left of the table) and the units digit comes from the column number (as indicated across the top of the table).

Now consider a very simple program, which adds 2 to the number being displayed, and then stops. The program is entered starting from program location 000, and looks like this:

LocationContentsMeaningComments
00085+
001022
00295=compute result
00391R/Sstop program

To use this program, you would enter the number n to be operated on, press RST to ensure the current program location was 000, then R/S to start execution. When the program stops (which should happen quite quickly for such a simple program), the display will be showing the number n + 2.

You can see that the codes 85, 95 and 91 correspond to the positions of the keys labelled  + ,  =  and R/S on the grid above, but the code for the  2  is not 83 as you would expect from the grid position, but 02. This last code was chosen to be more easily understandable by a human trying to read the program. There is no row 0, so the codes 00 .. 09 are used to represent the keys  0  ..  9 .

Context-Dependent Interpretations

These TI calculators allowed for addressing up to 100 data memory locations, numbered 00 to 99 (some models had a lower limit than this). A keystroke sequence like STO 4  2  (store the currently-displayed number into memory 42) would be encoded as 42 42. In this case the first 42 is the key code for the STO key, but the second 42 is not a key code, but a memory register number. The calculator knows to interpret it as such because that's what has to follow the code for the STO key.

Program addresses were 3 digits, potentially allowing programs to consist of up to 1000 steps, numbered 000 to 999 (though in fact none of the models produced allowed for this maximum). A branch instruction, for example GTO 3  4  5  (unconditional branch to location 345) would be encoded as 61 03 45. In this case the hundreds digit of the branch destination is in the units digit of the second instruction byte (after the opcode), with a zero tens digit; and the remaining digits are in the third instruction byte.

A code sequence like 61 11, on the other hand, represents the keystrokes GTO A , which is a branch to the location marked by the symbolic label A . The calculator can tell this is a symbolic branch, rather than a branch to a numbered location, because the tens digit of the byte immediately following the opcode is not zero.

Most of the keys on the keypad can be used as symbolic labels. For example, sequences like GTOSTO and GTOGTO are legitimate, provided that STO and GTO have in fact been defined as labels somewhere in the program.

Modifier Keys

Most of the keys had multiple functions, depending on whether INV or 2nd had been pressed beforehand. INV invoked the "inverse" (whatever that meant) of the following function, and was recorded in a program as a separate keystroke (code 22), while 2nd invoked a completely different function which was written on the keypad faceplate just above the key. For example, pressing 2ndx2 invoked the sin function, while INV2ndx2 (or INVsin) gave you the arcsine.

The code for this alternate function is derived from that of the original key function by adding 5 to the units digit (without carry to the tens digit). Thus, the key codes corresponding to the position of the 2nd key itself (21 and 26) are never used as opcodes. Here is the table of the codes produced with the 2nd prefix:

 x6x7x8x9x0
1x A'  B'  C'  D'  E' 
2x INVlogCPCLR
3xPgmP→Rsincostan
4xInsCMsExcPrdInd
5xDelEngFixInt|x|
6xPausex=tNopOpDeg
7xLblx≥tΣxmean(x)Rad
8xSt flgIf flgD.MSπGrad
9xWriteDszAdvPrtList

Merged Keystrokes

The Ind key allows for indirection: wherever a reference to a memory register or a program location is allowed, this key can be used to fetch the actual value from a memory register. For example, the key sequence RCLInd 1  0  means to fetch the value in memory register 10, and use that value in turn as the number of a memory register whose contents are to be fetched as the current operand. However, in this case the Ind cannot be encoded as code 40, because the code sequence 43 40 would be interpreted as RCL 4  0 , not RCLInd.

But, because of the use of the 00 .. 09 codes for the  0  ..  9  keys, the codes 62-64, 72-74, 82-84 and 92 are available for other uses. So most of these are reallocated to represent opInd sequences:

 x2x3x4
6xPgmIndExcIndPrdInd
7xSTOIndRCLIndSUMInd
8x GTOIndOpInd
9xINVSBR  

Thus, the key sequence RCLInd 1  0  would be encoded as 73 10.

Note the use of code 92 for INVSBR (return from subroutine); this was not necessary for reasons of ambiguity, but was done to save space with such a common sequence.

See also

Related Research Articles

Calculator Electronic device used for calculations

An electronic calculator is typically a portable electronic device used to perform calculations, ranging from basic arithmetic to complex mathematics.

In computer science, an instruction set architecture (ISA), also called computer architecture, is an abstract model of a computer. A device that executes instructions described by that ISA, such as a central processing unit (CPU), is called an implementation.

IBM 1401 1960s decimal computer

The IBM 1401 is a variable-wordlength decimal computer that was announced by IBM on October 5, 1959. The first member of the highly successful IBM 1400 series, it was aimed at replacing unit record equipment for processing data stored on punched cards and at providing peripheral services for larger computers. The 1401 is considered to be the Ford Model-T of the computer industry, because it was mass-produced and because of its sales volume. Over 12,000 units were produced and many were leased or resold after they were replaced with newer technology. The 1401 was withdrawn on February 8, 1971.

Graphing calculator Electronic calculator capable of plotting graphs

A graphing calculator is a handheld computer that is capable of plotting graphs, solving simultaneous equations, and performing other tasks with variables. Most popular graphing calculators are programmable calculators, allowing the user to create customized programs, typically for scientific, engineering or education applications. They have large screens that display several lines of text and calculations.

Function key Key on a computer or terminal keyboard

A function key is a key on a computer or terminal keyboard that can be programmed so as to cause an operating system command interpreter or application program to perform certain actions, a form of soft key. On some keyboards/computers, function keys may have default actions, accessible on power-on.

TI-83 series Series of graphing calculators produced by Texas Instruments

The TI-83 series is a series of graphing calculators manufactured by Texas Instruments.

HP-41C Hewlett-Packard handheld RPN calculator

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.

HP-20S

The HP-20S (F1890A) is an algebraic programmable scientific calculator produced by Hewlett Packard from 1989 to 2000.

HP-32S

The HP-32S was a programmable RPN Scientific Calculator introduced by Hewlett-Packard in 1988 and discontinued in 1991. It continued the tradition of the HP-15C programmable RPN Scientific Calculator. But some functions of the HP-15C were omitted and some were reduced in functionality, so to some extent it is more correct to say that the HP-32S expanded upon the HP-34C. It supported complex math, statistics, probability, and other functions.

TI-57 Programmable calculator produced by Texas Instruments

The TI-57 was a programmable calculator made by Texas Instruments between 1977 and 1982. There were three machines by this name made by TI, the first was the TI-57 with LED display released in September 1977 along the more powerful TI-58 and TI-59. It had 50 program steps and eight memory registers. Two later versions named TI-57 LCD and TI-57 LCD-II have a LCD display, but were less powerful and had much less memory: 48 bytes to be allocated between program 'steps' and storage registers.

TI-59 / TI-58 Programmable calculator produced by Texas Instruments

The TI-59 is an early programmable calculator, that was manufactured by Texas Instruments from 1977. It is the successor to the TI SR-52, quadrupling the number of "program steps" of storage, and adding "ROM Program Modules". Just like the SR-52, it has a magnetic card reader for external storage. One quarter of the memory is stored on each side of one card.

Programmable calculators are calculators that can automatically carry out a sequence of operations under control of a stored program. Most are Turing complete, and, as such, are theoretically general-purpose computers. However, their user interfaces and programming environments are specifically tailored to make performing small-scale numerical computations convenient, rather than general-purpose use.

HP-16C Programmable calculator produce by Hewlett-Packard

The HP-16C Computer Scientist is a programmable pocket calculator that was produced by Hewlett-Packard between 1982 and 1989. It was specifically designed for use by computer programmers, to assist in debugging. It is a member of the HP Voyager series of programmable calculators. It was the only programmer's calculator ever produced by HP, though many later HP calculators have incorporated most of the 16C's functions.

Elektronika MK-52

The Elektronika MK-52 is an RPN-programmable calculator manufactured in the Soviet Union from 1983 to 1992 at the Quasar and Kvadr plants in Ukraine. It belongs to the third generation of Soviet programmable calculators. Its original selling price was 115 rubles.

In computer programming, a branch table or jump table is a method of transferring program control (branching) to another part of a program using a table of branch or jump instructions. It is a form of multiway branch. The branch table construction is commonly used when programming in assembly language but may also be generated by compilers, especially when implementing optimized switch statements whose values are densely packed together.

TI-990 Series of 16-bit computers by Texas Instruments.

The TI-990 was a series of 16-bit minicomputers sold by Texas Instruments (TI) in the 1970s and 1980s. The TI-990 was a replacement for TI's earlier minicomputer systems, the TI-960 and the TI-980. It had several unique features, and was easier to program than its predecessors.

HP 35s Programmable scientific calculator produced by Hewlett-Packard

The HP 35s (F2215A) is a Hewlett-Packard non-graphing programmable scientific calculator. Although it is a successor to the HP 33s, it was introduced to commemorate the 35th anniversary of the HP-35, Hewlett-Packard's first pocket calculator. HP also released a limited production anniversary edition with shiny black overlay and engraving "Celebrating 35 years".

The IBM System/360 architecture is the model independent architecture for the entire S/360 line of mainframe computers, including but not limited to the instruction set architecture. The elements of the architecture are documented in the IBM System/360 Principles of Operation and the IBM System/360 I/O Interface Channel to Control Unit Original Equipment Manufacturers' Information manuals.

HP-67/-97

The HP-67 is a magnetic card-programmable handheld calculator, introduced by Hewlett-Packard in 1976 at an MSRP of $450. A desktop version with built-in thermal printer was sold as the HP-97 at a price of $750.

Numeric keypad

A numeric keypad, number pad, numpad, or ten key, is the palm-sized, usually-17-key section of a standard computer keyboard, usually on the far right. It provides calculator-style efficiency for entering numbers. The idea of a 10-key number pad cluster was originally introduced by Tadao Kashio, the developer of Casio electronic calculators.

References

  1. "Vim documentation: Repeat".