Post Reply 
Indirect Storage (STO IND) ELI5 what and why?
03-14-2021, 04:20 PM
Post: #2
RE: Indirect Storage (STO IND) ELI5 what and why?
Indirect storage, known as indirect addressing, allows you to designate a target register based the value of a designated register.

For example:
Register R00 contains 5.
I want to store 3.1415 in R05 using indirect storage.

Register R00 is my designated register, while register R05 is my target register.

3.1415 STO IND 00
RCL 05 returns 3.1415

Indirect storage is good if you need to determine which target register to use dynamically. It's like the precursor to using lists on a graphing calculator.

Note: Indirect addressing can include named variables (up to six characters) or stacks X, Y, Z, T, or L. If a numerical value is used, only the integer portion is used. Hence STO IND 00 stores a value to register R05 when int(R00) = 5.

Example:
Let f(n) = n^3 + 5 for n = 1 through X and store the results in R01 through RX. For instance, if X = 4 then the program stores f(4) in R04, f(3) in R03, f(2) in R02, and f(1) in R01.


Program:
00 {25-Byte Prgm}
01 LBL "INDEXP" // example
02 STO 00 // stores x (assuming x is an integer)
03 LBL 00 // begin local loop
04 RCL 00
05 3 // calculate f(n)
06 Y^X
07 5
08 +
09 STO IND 00 // indirect storage
10 DSE 00 // decrement R00 by 1, if R00 = 0 skip the next step
11 GTO 00
12 END


4 INDEXP
R04 = 69 (stored when R00 = 4)
R03 = 32 (stored when R00 = 3)
R02 = 13 (stored when R00 = 2)
R01 = 6 (stored when R00 = 1)
R00 = 0

Indirect addressing on the 42S when using stack levels is very useful because it can save you from having a storage register.

Example:
Stack X contains 77.21
STO IND ST T ( [ STO ] [ . ] (ST T) )
Now stack T also contains 77.21

Indirect addressing also works for recalling values and storage arithmetic on the 42S.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Indirect Storage (STO IND) ELI5 what and why? - Eddie W. Shore - 03-14-2021 04:20 PM



User(s) browsing this thread: 3 Guest(s)