Keystroke programming: Difference between revisions

Content deleted Content added
Ldo (talk | contribs)
continue example
Ldo (talk | contribs)
continue example
Line 56:
|}
 
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| + }}, {{TI-5x/Keys/Yellow| = }} and {{TI-5x/Keys/Brown|R/S}} on the grid above, but the code for the {{TI-5x/Keys/White| 2 }} is not 83 as you would expect from the grid position, but 02. This last code iswas 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| 0 }} .. {{TI-5x/Keys/White| 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 {{TI-5x/Keys/Brown|STO}} {{TI-5x/Keys/White| 4 }} {{TI-5x/Keys/White| 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 {{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’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| 3 }} {{TI-5x/Keys/White| 4 }} {{TI-5x/Keys/White| 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 {{TI-5x/Keys/Brown|GTO}} {{TI-5x/Keys/Brown| A }}, which is a branch to the ___location marked by the ''symbolic label'' {{TI-5x/Keys/Brown| 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 {{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.
 
=== The “2nd” Key ===
TBD
 
=== Merged Keystrokes ===
 
{{TI-5x/Keys/Alt|Ind}}