TI59 Programming Guide

Introduction

The TI59 Programmable Calculator will store a sequence of instructions and execute them accordingly. In this way, the TI59 is a bona fide computing devide. It will store values, perform conditional branching, and do many other things that conventional computers do. The programming language that the TI59 uses is essentially the keys on the calculator itself. Each is stored as a separate instruction. As TI59 programs unfold, they bear a striking resemblance to assembly language programs.

How to Program

When in calculator mode, the TI59 functions just like an ordinary calculator. It is in the Learn mode that instructions are stored. Press the LRN key to enter the learn mode. Note that the display changes. There are 3 zeroes, a space, and then 2 zeroes:
000 00
The first set of zeroes is the step number. Since programs are comprised of a series of steps, the sequence is vital. The step number keeps track of this.

The second set of zeroes indicates the code of the instruction at that sequence. As previously stated, the programming language of the TI59 is simply the calculator keys available. Each key is given a numeric code. Note that the keypad is 5 keys across, and 9 keys down. This makes it possible to identify each key with a 2-digit number, or "instruction code." For example, the square root key would be represented by the instruction code 34, because it is in the 3rd row down, and the 4th key across.

Note also that the TI59 assigns multiple functions to the same key. Utilizing the 2nd key will perform a diferent function. For example, pressing the 2nd key and then the square root key will effect the cos function. In this case, a similar instruction code is generated, but it is 5 + the number of keys across. For example the instruction code for the cos key is 39.

Entering a Program

Let's enter a simple program. We'll create a program that multiplies a value by 2. Turn on the calculator, press the LRN key, and press the multiplication key, the two key, and the equals key. Each time you press a key, note that the sequence number increments. This is because you're adding instruction sequences each time you press a key.

You can step through a program using the SST and BST keys, which are single step and back step respectively. Press BST and the sequence number will move back to 002. Note that the instruction code is 95. This makes sense because the equals key is on the 9th row and 5th column of the key pad. Pressing BST and SST will back step and single step all the way through the program.

Consider our program in this representation:

000 65 x
001 02 2
002 95 =

Note a couple of things. First of all, the first instruction has the sequence 000. Might as well get used to counting from zero right away. Zero is a number. Although it has a numerical value of nothing, it is a valid identifier. The first instruction has the sequence 000. Note also that the instruction code for the digit 2 is not what you'd expect. Normally it would be 83, for the 8th row and 3rd column. But instead it's represented as 02. I don't know why. Since the first row on the keypad is considered row 1, anything beginning with 0 can be considered to be a digit. Since each digit is stored separately, all ten digits can be represented in this way.

Flow Control

There are a couple of other keys you must understand before being able to execute a program. One is the RST key. This stands for reset, and it puts the sequence pointer back to 000. Try it. Press SST or BST until you're on sequence 002. Press the LRN key to get out of learn mode. Press LRN again to get back into learn mode. Note that you're still on sequence 002. Press LRN again to get out of learn mode. Now press the RST key. Press the LRN key again to get back into learn mode. Notice that the sequence pointer is no longer on step 002, but that it has been "reset" back to step 000. Generally after you input a program you're going to want to reset the sequence pointer back to the beginning before execution.

The other important key is the R/S key. This stands for "Run/Stop". Pressing this will cause the program to begin or stop execution.

Executing the Program

To execute a program you must be out of learn mode. If you are in learn mode, press the LRN key to get back into calculator mode. Press the RST key to ensure that the sequence pointer is back at the beginning of the program. Our program is designed to muliply a number by two. Let's start small. Press the 6 key. With the number 6 in the display, this is the number that will be operated upon by our program when execution starts. It's no different than if we started manually pressing they keys that comprise our program. It's just that the TI59 will execute these instructions automatically for us.

Press the R/S key to begin executing the program. Note that the calculator seems to go off into never-never land. If you let it run long enough the number 0 will begin to flash in the display. Press the LRN key to enter learn mode. Note that you're at sequence 479. This is the maximum number of steps available to the TI59 programmable calculator.

What went wrong? Well if you look closely at the program, you'll note that we never told execution to stop. The calculator will dutifully execute our instructions of multiplying by two, but then it continues executing null instructions until it runs out of sequence numbers.

The solution is to use the R/S as an actual programming instruction. This will cause execution to stop when the instruction is encountered. To do this, get out of learn mode and press RST to reset the sequence pointer. Get back into learn mode, and you'll see that the sequence pointer is back on 000. Press SST until we're on sequence 003. Note that this is an unused sequence number because the instruction code is 00. Now simply press the R/S key. This will set insctruction 003 to be the run/stop function.

Our program now looks like this:

000 65 x
001 02 2
002 95 =
003 91 R/S

Let's try it again. Get out of learn mode and reset the instruction pointer. Enter the digit 6 into the display, and press R/S. Look at that! The TI59 has multiplied our number by 2 and stopped execution. Great! Now lets try it again. Press CLR to clear the display, and then enter a number of your own choosing. Press the R/S key.

What happened? It went off into never-never land again. Why? The problem is that the TI59 stopped execution at sequence 003 where we had our R/S instruction. The next time we initiated execution, it picked right up at sequence 004. This, like the first time, caused it to fly through a whole lot of null instructions until it ran out of sequences.

How do we account for this behavior? The solution is simple. The RST key, like the R/S key, can be entered as an executable instruction. Press the CLR key to get the display to stop blinking. Press the RST key to reset the sequence pointer. Press LRN to get into learn mode. Press SST until you're at sequence 004. Now press the RST key to assign the reset function to sequence 004.

Our program now looks like this:

000 65 x
001 02 2
002 95 =
003 91 R/S
004 81 RST

Get back out of learn mode and reset the sequence pointer. New lets try it again. Enter 6 and press R/S. Like before it will multiply 6 by 2. Now enter a number of your own choosing and press R/S again. This time it works. The second time you press R/S, it will continue on and execute instruction sequence 004. But new sequence 004 tells the instruction pointer to go back to 000. This will begin execution of the program from the beginning, which will multiply the display value by 2 and stop execution.