Keystroke programming: Difference between revisions

Content deleted Content added
m Example: TI Calculators: add image of TI-58C, {{sqrt}}
Bender the Bot (talk | contribs)
m top: HTTP to HTTPS for SourceForge
 
(13 intermediate revisions by 7 users not shown)
Line 1:
{{One source|date=March 2025}}
'''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 calculator]]s, but theres—there are keystroke-programmable software applications, too, forsuch exampleas [[Vim (text editor)|Vim]].<ref>http{{Cite web|url=https://vimdoc.sourceforge.net/htmldoc/repeat.html#complex-repeat|title = Vim documentation: Repeat}}</ref>
 
== Example: TI Calculatorscalculator example ==
[[File:TI58c.jpg|thumb|The TI-58C]]
The Texas Instruments [[TI-59 / TI-58|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:
 
{| class="wikitable" style="background-color:#000000;"
{| border="1" cellpadding="2" class="wikitable"
|----
!&nbsp;||''x''1||''x''2||''x''3||''x''4||''x''5
Line 16 ⟶ 17:
|-
!3''x''
|{{TI-5x/Keys/Brown|LRN}}||{{TI-5x/Keys/Brown|x⇌t}}||{{TI-5x/Keys/Brown|x²<sup>2</sup>}}||{{TI-5x/Keys/Brown|{{sqrt|x}}}}||{{TI-5x/Keys/Brown|1/x}}
|-
!4''x''
Line 34 ⟶ 35:
|-
!9''x''
|{{TI-5x/Keys/Brown|R/S}}||{{TI-5x/Keys/White|&nbsp;0&nbsp;}}||{{TI-5x/Keys/White|&nbsp;.&nbsp;}}||{{TI-5x/Keys/White|+/-}}||{{TI-5x/Keys/Yellow|&nbsp;&#61;{{=}}&nbsp;}}
|----
|}
Line 58 ⟶ 59:
To use this program, you would enter the number ''n'' to be operated on, press {{TI-5x/Keys/Brown|RST}} to ensure the current program ___location was 000, then {{TI-5x/Keys/Brown|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 {{TI-5x/Keys/Yellow|&nbsp;+&nbsp;}}, {{TI-5x/Keys/Yellow|&nbsp;&#61;{{=}}&nbsp;}} and {{TI-5x/Keys/Brown|R/S}} on the grid above, but the code for the {{TI-5x/Keys/White|&nbsp;2&nbsp;}} 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 {{TI-5x/Keys/White|&nbsp;0&nbsp;}} .. {{TI-5x/Keys/White|&nbsp;9&nbsp;}}.
 
=== Context-Dependentdependent Interpretationsinterpretations ===
 
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 {{TI-5x/Keys/Brown|STO}} {{TI-5x/Keys/White|&nbsp;4&nbsp;}} {{TI-5x/Keys/White|&nbsp;2&nbsp;}} (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 {{TI-5x/Keys/Brown|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’sthat's what has to follow the code for the {{TI-5x/Keys/Brown|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 {{TI-5x/Keys/Brown|GTO}} {{TI-5x/Keys/White|&nbsp;3&nbsp;}} {{TI-5x/Keys/White|&nbsp;4&nbsp;}} {{TI-5x/Keys/White|&nbsp;5&nbsp;}} (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.
Line 70 ⟶ 71:
Most of the keys on the keypad can be used as symbolic labels. For example, sequences like {{TI-5x/Keys/Brown|GTO}} {{TI-5x/Keys/Brown|STO}} and {{TI-5x/Keys/Brown|GTO}} {{TI-5x/Keys/Brown|GTO}} are legitimate, provided that {{TI-5x/Keys/Brown|STO}} and {{TI-5x/Keys/Brown|GTO}} have in fact been defined as labels somewhere in the program.
 
=== Modifier Keyskeys ===
 
Most of the keys had multiple functions, depending on whether {{TI-5x/Keys/Brown|INV}} or {{TI-5x/Keys/Yellow|2nd}} had been pressed beforehand. {{TI-5x/Keys/Brown|INV}} invoked the “inverse”"inverse" (whatever that meant) of the following function, and was recorded in a program as a separate keystroke (code 22), while {{TI-5x/Keys/Yellow|2nd}} invoked a completely different function which was written on the keypad faceplate just above the key. For example, pressing {{TI-5x/Keys/Yellow|2nd}} {{TI-5x/Keys/Brown|x²<sup>2</sup>}} invoked the {{TI-5x/Keys/Alt|sin}} function, while {{TI-5x/Keys/Brown|INV}} {{TI-5x/Keys/Yellow|2nd}} {{TI-5x/Keys/Brown|x²<sup>2</sup>}} (or {{TI-5x/Keys/Brown|INV}} {{TI-5x/Keys/Alt|sin}}) 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 {{TI-5x/Keys/Yellow|2nd}} key itself (21 and 26) are never used as opcodes. Here is the table of the codes produced with the {{TI-5x/Keys/Yellow|2nd}} prefix:
 
{| class="wikitable" style="background-color:#000000;"
{| border="1" cellpadding="2" class="wikitable"
|----
!&nbsp;||''x''6||''x''7||''x''8||''x''9||''x''0
|-
!1''x''
|{{TI-5x/Keys/Alt|&nbsp;A´'&nbsp;}}||{{TI-5x/Keys/Alt|&nbsp;B´'&nbsp;}}||{{TI-5x/Keys/Alt|&nbsp;C´'&nbsp;}}||{{TI-5x/Keys/Alt|&nbsp;D´'&nbsp;}}||{{TI-5x/Keys/Alt|&nbsp;E´'&nbsp;}}
|-
!2''x''
Line 93 ⟶ 94:
|-
!5''x''
|{{TI-5x/Keys/Alt|Del}}||{{TI-5x/Keys/Alt|Eng}}||{{TI-5x/Keys/Alt|Fix}}||{{TI-5x/Keys/Alt|Int}}||{{TI-5x/Keys/Alt|&#124;{{pipe}}x&#124;{{pipe}}}}
|-
!6''x''
|{{TI-5x/Keys/Alt|Pause}}||{{TI-5x/Keys/Alt|x&#61;{{=}}t}}||{{TI-5x/Keys/Alt|Nop}}||{{TI-5x/Keys/Alt|Op}}||{{TI-5x/Keys/Alt|Deg}}
|-
!7''x''
|{{TI-5x/Keys/Alt|Lbl}}||{{TI-5x/Keys/Alt|x≥t}}||{{TI-5x/Keys/Alt|∑xΣx}}||{{TI-5x/Keys/Alt|mean(x)}}||{{TI-5x/Keys/Alt|Rad}}
|-
!8''x''
Line 109 ⟶ 110:
|}
 
=== Merged Keystrokeskeystrokes ===
 
The {{TI-5x/Keys/Alt|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 {{TI-5x/Keys/Brown|RCL}} {{TI-5x/Keys/Alt|Ind}} {{TI-5x/Keys/White|&nbsp;1&nbsp;}} {{TI-5x/Keys/White|&nbsp;0&nbsp;}} 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 {{TI-5x/Keys/Alt|Ind}} cannot be encoded as code 40, because the code sequence 43 40 would be interpreted as {{TI-5x/Keys/Brown|RCL}} {{TI-5x/Keys/White|&nbsp;4&nbsp;}} {{TI-5x/Keys/White|&nbsp;0&nbsp;}}, not {{TI-5x/Keys/Brown|RCL}} {{TI-5x/Keys/Alt|Ind}}.
Line 115 ⟶ 116:
But, because of the use of the 00 .. 09 codes for the {{TI-5x/Keys/White|&nbsp;0&nbsp;}} .. {{TI-5x/Keys/White|&nbsp;9&nbsp;}} keys, the codes 62-64, 72-74, 82-84 and 92 are available for other uses. So most of these are reallocated to represent ''op'' {{TI-5x/Keys/Alt|Ind}} sequences:
 
{| class="wikitable" style="background-color:#000000;"
{| border="1" cellpadding="2" class="wikitable"
|----
!&nbsp;||''x''2||''x''3||''x''4
Line 139 ⟶ 140:
== See also ==
*[[FOCAL keystroke programming]]
*[[Macro recorder]]
*[[Programming by demonstration]]
 
== References ==