Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: mhw on January 20, 2016, 08:05:20 AM

Title: Indirect address
Post by: mhw on January 20, 2016, 08:05:20 AM
How do I indirect address a SS location?
Title: Re: Indirect address
Post by: franji1 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
Title: Re: Indirect address
Post by: franji1 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!
Title: Re: Indirect address
Post by: mhw 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.
Title: Re: Indirect address
Post by: BobO 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.
Title: Re: Indirect address
Post by: Controls Guy 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!