TI calculator example
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 (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 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 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 (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 , which is a branch to the location marked by the ''symbolic label'' . 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 and are legitimate, provided that and have in fact been defined as labels somewhere in the program.Modifier keys
Most of the keys had multiple functions, depending on whether or had been pressed beforehand. invoked the "inverse" (whatever that meant) of the following function, and was recorded in a program as a separate keystroke (code 22), while invoked a completely different function which was written on the keypad faceplate just above the key. For example, pressing invoked the function, while (or ) 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 key itself (21 and 26) are never used as opcodes. Here is the table of the codes produced with the prefix:Merged keystrokes
The 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 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 cannot be encoded as code 40, because the code sequence 43 40 would be interpreted as , not . But, because of the use of the 00 .. 09 codes for the .. 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'' sequences: Thus, the key sequence would be encoded as 73 10. Note the use of code 92 for {{TI-5x/Keys/Brown, SBR (return from subroutine); this was not necessary for reasons of ambiguity, but was done to save space with such a common sequence.See also
* FOCAL keystroke programming *References