## Wednesday, November 30, 2011

### HP 15C Programming Tutorial - Part 12: Memory and Indirect Registers

The Indirect Register I

Another powerful feature of the HP 15C is indirect addressing. The registers I and (i) can be used not only for loop control (for DSE/ISG) but it can also be used to call different memory registers, call different subroutines, and control flag operations.

We will work with the registers I and (i) in Parts 12 and 13. Part 12 will cover how to use the index registers with data recall and Part 13 will cover how to use the index registers for calling different subroutines.

Index Register and Memory

The HP 15C Manual names the memory register I (RI) the as the Index Register. You can store and recall values in memory register I just like any other memory register. Here is where it gets good: you can use register I to store and recall any other memory register with the integer part of I as the designated register. This is where the variable (i) comes in.

Let I = N where 0 ≤ N ≤ 19* (see Caution below)

STO (i) stores the contents in the display into register N.
RCL (i) recalls the contents of register N.

Caution: The value of N can be anywhere from 0 to 65. The upper limit of N is determined by how the memory registers are partitioned. You can check the number of registers have been partitioned by pressing [ g ] [RCL] (MEM). It is the left-most number. By default the HP 15C partitions 19 as the highest memory register number allowed. For the purposes of this tutorial we will use the default settings.

Example:

Store 2 in RI. Then store π/4 in R2 indirectly (by use of RCL (i)).

Key Strokes:
2 [STO] [TAN] ( I )
[ g ] [EEX] ( π ) 4 [ ÷ ] [STO] [COS] ( (i) )
[backspace] * To clear the display
[RCL] 2 * Display: 0.7854 ≈ π/4

Indirect Addressing - Memory Registers

`If RI contains...	STO (i) and RCL (i) will address0			R01			R12			R23			R34			R45			R56			R67			R78			R89			R910			R.011			R.112			R.213			R.314			R.415			R.516			R.617			R.718			R.819			R.920 to 65**		R20 to R65**`

On final note, storage and recall arithmetic (+, -, ×, ÷) work with RI. Now let's use RI in a couple of programs.

Memory Cycle

In this program, the user cycles through the contents of R0 through R9. One possible solution is to just line up a batch of RCL N, R/S commands. However, with indirect addressing we can considerably shorten the program by use of registers I and (i).

This program is going to use a loop that increases the counter from 0 to 9. The starting value is 0, the ending value is 9. Let I be the counter variable and I = 0.009.

Hint: STO (i) and RCL (i) uses the integer value of I as the index. (any decimal portion of I is ignored)

Labels used: A (main), 0

Program Listing

`Key Listing			Keys001	42	21	11	LBL A002			48	.003			0	0004			0	0005			9	9006		44	25	STO I	* Stores the Index register007	42	21	0	LBL 0	* Loop starts here008		45	24	RCL (i)	* Indirect recall009			31	R/S	* Stop and display010			33	R ↓ 	* Send value to T-register011	42	6	25	ISG I012		22	0	GTO 0013	43	4	9	SF 9	* Flash the display014		43	32	RTN`

Instructions:

1. Run Program A ( [ f ] [ √ ] (A) )
2. The program starts with R0. Press [R/S] to see the contents of R1. This cycles to R9.
3. When R9 is recalled, the stack is reset and the display flashes. Clear Flag 9 or press the backspace button.

Example:

Try this program with the following registers set as:
R0 = 0
R1 = 25
R2 = 15
R3 = 10
R4 = 50
R5 = 5
R6 = 45
R7 = 30
R8 = 40
R9 = 35

Wheel of Numbers

This program will "spin" the wheel using memory registers R0 through R9. Press R/S to "stop" the wheel.

Labels used: B (main), 1

Program Listing

`Key Codes			Keys001	42	21	12	LBL B002			48	.003			0	0004			0	0005			9	9006		44	25	STO I007	42	21	1	LBL 1008		45	24	RCL (i)009	42	6	25	ISG I010		22	1	GTO 1011			1	1	* If I = 10, subtract 1012			0	0	* and start over.013	44	30	25	STO- I014		22	1	GTO 1`

This program produces an endless loop, so when you do run it, be sure to press [R/S] or turn the calculator off.

Instructions:
1. Load the wheel values on registers R0 and R9.
2. Run Program B. ( [ f ] [e^x] (B) ) The calculator will display "running".
3. When you feel lucky, press [R/S]. The value of the wheel's space will be displayed.

Example:

Set the wheel with the following values:

R0 = 0
R1 = 25
R2 = 15
R3 = 10
R4 = 50
R5 = 5
R6 = 45
R7 = 30
R8 = 40
R9 = 35

Run Program B a few times. Did you stop on the 50 space? Good luck!

Hint: With modifications, the above program can simulate a very famous wheel on a very famous game show.

That concludes Part 12. As I previously mentioned, we will continue working with indirect registers in Part 13. Signing off,

Eddie

This tutorial is property of Edward Shore. © 2011

### TI-84 Plus CE Python: Drawing Shapes with the ti_plotlib module

TI-84 Plus CE Python: Drawing Shapes with the ti_plotlib module Introduction Here are four scripts to draw shapes: RECT8: rec...