Indirect Storage (STO IND) ELI5 what and why?
|
03-14-2021, 03:24 PM
Post: #1
|
|||
|
|||
Indirect Storage (STO IND) ELI5 what and why?
I have been digging into storing objects in registers on the HP42s/DM42/Free42. Exploring the ins and outs. I keep reading about STO IND and indirect storage.
What does this mean and why would I want to store something indirectly? Any explanation on this would be appreciated. HP48GX, HP42s and DM42. |
|||
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. |
|||
03-14-2021, 04:58 PM
(This post was last modified: 03-14-2021 04:59 PM by DM48.)
Post: #3
|
|||
|
|||
RE: Indirect Storage (STO IND) ELI5 what and why?
Eddie, thank you for the explanation. I'm still not quite grasping it, but I suspect that is because I am mixing up "register" terminology. X, Y, Z, T, A, L registers vs a memory register.
My first real calculator was a TI-85 and then an HP48GX when I saw it in 1994. I came in after the 42s and am slow on the pickup of a new language. I will study your example and post back with questions. HP48GX, HP42s and DM42. |
|||
03-14-2021, 05:57 PM
Post: #4
|
|||
|
|||
RE: Indirect Storage (STO IND) ELI5 what and why?
(03-14-2021 04:58 PM)DM48 Wrote: Eddie, thank you for the explanation. I'm still not quite grasping it, but I suspect that is because I am mixing up "register" terminology. X, Y, Z, T, A, L registers vs a memory register. In TI-85 land, the analog of indirect addressing would be using list/matrix indexes, e.g. Code: 10->dimL D In this case, the X is sort of like the register that you're using with "STO IND". |
|||
03-14-2021, 05:59 PM
Post: #5
|
|||
|
|||
RE: Indirect Storage (STO IND) ELI5 what and why?
(03-14-2021 05:57 PM)Dave Britten Wrote:(03-14-2021 04:58 PM)DM48 Wrote: Eddie, thank you for the explanation. I'm still not quite grasping it, but I suspect that is because I am mixing up "register" terminology. X, Y, Z, T, A, L registers vs a memory register. What is it in 48G land? HP48GX, HP42s and DM42. |
|||
03-14-2021, 06:05 PM
Post: #6
|
|||
|
|||
RE: Indirect Storage (STO IND) ELI5 what and why?
(03-14-2021 05:59 PM)DM48 Wrote: What is it in 48G land? The 48G has various commands like GET, GETI, PUT, and PUTI for reading or writing list and matrix elements, and the indexes you use might come from other variables. But the RPL stack works a bit differently, and there isn't really the same STO IND concept. Rather, you put a name object on the stack, e.g. 'MYVAR', and then execute STO or RCL, which then uses that name. So you could have a name stored in a variable, or use various mechanisms to convert a string to a name and use that. |
|||
03-27-2021, 01:23 AM
Post: #7
|
|||
|
|||
RE: Indirect Storage (STO IND) ELI5 what and why?
I am writing a small program and understand Indirect Addressing, enough to be dangerous. Makes complete sense.
I am getting "Size Error" when trying to run the following: 55 is in the x register and I want to store it IND in register 01. x: 55 STO . IND 01 Size Error I then ran - Size 25 ENTER to make sure I had a 25x1 REGS No code at this point. I'm just trying to do this via keypad. What's up with the "Size Error"? HP48GX, HP42s and DM42. |
|||
03-27-2021, 01:25 AM
Post: #8
|
|||
|
|||
RE: Indirect Storage (STO IND) ELI5 what and why?
(03-27-2021 01:23 AM)DM48 Wrote: I am writing a small program and understand Indirect Addressing, enough to be dangerous. Makes complete sense. What's in register 01 when you do STO IND 01? The integer portion of R01 will be the register you're attempting to store 55 into. |
|||
03-27-2021, 01:56 AM
(This post was last modified: 03-27-2021 10:37 PM by DM48.)
Post: #9
|
|||
|
|||
RE: Indirect Storage (STO IND) ELI5 what and why?
RCL 01
"Exit" I cleared R01. Seems to work as desired. :facepalm: I am trying to write a program that ask how many points you have (x,y) and then runs a loop so you can enter each point, and after the loop is complete, runs some calculations with the points. I plan on storing the y and x registers as complex numbers so I can pull them out for calcs easy. (After I have this program running, I will try the same using a [X x 2] matrix for storing the numbers and recalling them from the matrix. I am trying to make it user friendly for myself. This is what I have so far. I believe Indirect Addressing is what I need to store point one in R01, point two in R02, etc. Code: 00 { 150-Byte Prgm} HP48GX, HP42s and DM42. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)