News:

  • May 06, 2026, 01:35:28 AM

Login with username, password and session length

Author Topic: Indirect address  (Read 7918 times)

mhw

  • Hero Member
  • *****
  • Posts: 250
Indirect address
« on: January 20, 2016, 08:05:20 AM »
How do I indirect address a SS location?

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3806
    • Host Engineering
Re: Indirect address
« Reply #1 on: January 20, 2016, 08:14:44 AM »
As with all data blocks (X, Y, C, T, user data-blocks, etc.), use a V register as an "array index".

So, if V10 = 3, then

SS[V10] references SS3 (just like C[V10] references the bit C3).

You can also reference structure MEMEBERs this way, e.g. SS[V10].Length to get the length of SS3, i.e. SS3.Length.

There are more advanced capabilities in the MATH instruction, where you can have FULL MATHEMATICAL EXPRESSIONS for the Array Index in both the Expression parameter and (as of 1.4) the Result Parameter.  So whatever you can calculate mathematically, that can be an array index, e.g. SS[(10 * D5) + 3]

Oh, you can also "offset" an array index by a positive constant 1..63 anywhere you can have simple arrays, e.g.
SS[V10 + 1] would reference SS4
SS[V10 + 20] would reference SS23

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3806
    • Host Engineering
Re: Indirect address
« Reply #2 on: January 20, 2016, 08:19:32 AM »
I forgot to mention that you can also show status in Designer via array referencing, so stick SS[V10] in a Data View and it will dynamically update the status based on the current value of V10.

So, even if you do not access SS[V10] programmatically, you could utilize this in a Data View as a simple way to access a long list of part numbers, say in a user data block called PartNum.  Just utilize an unused V register (say V999), then in your Data View, stick in
V999
PartNum[V999]

and then write to V999 in the Data View to dynamically update the status of PartNum[V999] (rather than entering PartNum5, and PartNum17, and PartNum22, just manipulate V999 to 5, then 17, then 22).  The constant offset also works, so you could do status on
PartNum[V999]
PartNum[V999 + 1]
PartNum[V999 + 2]
PartNum[V999 + 3]

Cool stuff  :D!

mhw

  • Hero Member
  • *****
  • Posts: 250
Re: Indirect address
« Reply #3 on: January 20, 2016, 08:28:09 AM »
Thanks, my problem was that I was using a DLV for the index. Why are only V locations accepted? Not that it matters, I just need to remember that it is V only.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6154
  • Yes Pinky, Do-more will control the world!
Re: Indirect address
« Reply #4 on: January 20, 2016, 09:18:03 AM »
In the MATH box, any valid expression can be used as an index. In simple parameters, only V. The reason is simply opcode efficiency and some ages old limitations in DmD's DirectSoft based architecture...there's no place to store the index type without going to considerable pain.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3607
  • Darth Ladder
Re: Indirect address
« Reply #5 on: January 20, 2016, 12:09:16 PM »
I forgot to mention that you can also show status in Designer via array referencing, so stick SS[V10] in a Data View and it will dynamically update the status based on the current value of V10.

So, even if you do not access SS[V10] programmatically, you could utilize this in a Data View as a simple way to access a long list of part numbers, say in a user data block called PartNum.  Just utilize an unused V register (say V999), then in your Data View, stick in
V999
PartNum[V999]

and then write to V999 in the Data View to dynamically update the status of PartNum[V999] (rather than entering PartNum5, and PartNum17, and PartNum22, just manipulate V999 to 5, then 17, then 22).  The constant offset also works, so you could do status on
PartNum[V999]
PartNum[V999 + 1]
PartNum[V999 + 2]
PartNum[V999 + 3]

Cool stuff  :D!


I'll say cool stuff!  This capability is hugely helpful and I use it a lot when not using a Memory View -- thanks very much!
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.