News:

  • May 02, 2026, 04:17:32 PM

Login with username, password and session length

Author Topic: Deeper nesting for indirect addressing  (Read 47036 times)

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Deeper nesting for indirect addressing
« on: December 17, 2012, 03:19:52 PM »
I don't know how much trouble it would be, but I could sure use another layer of indirect addressing in the result field for the MATH instruction. For now I am using a MOVE instruction before the MATH instruction. It is part of a FIFO.

Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3806
    • Host Engineering
Re: Deeper nesting for indirect addressing
« Reply #1 on: December 17, 2012, 03:42:46 PM »
Please provide example.  Do you mean
R[N[V10]]
or do you want to index the various tables indirectly, and the index (see REFWRITE for this capability)

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3607
  • Darth Ladder
Re: Deeper nesting for indirect addressing
« Reply #2 on: December 17, 2012, 06:27:23 PM »
My guess is he wants the first thing.  I know in the Control Logix for example you can't do ThisArray[ThatArray[5]], so you have to do it in two steps and preload a scratch variable and it's an ugly kludge and it's very annoying.
« Last Edit: December 18, 2012, 08:18:14 AM by Controls Guy »
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: Deeper nesting for indirect addressing
« Reply #3 on: December 17, 2012, 09:43:04 PM »
I was looking for: MATH Result ArrayOne[MyIndex[V1]]
Right now I had to: MOVE from MyIndex[V1] to V2
Then I could do: MATH result ArrayOne[V2]
It is a little clunky but it works.
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6154
  • Yes Pinky, Do-more will control the world!
Re: Deeper nesting for indirect addressing
« Reply #4 on: December 18, 2012, 01:03:06 AM »
Don't know if it is helpful or relevant, but remember that we can do displaced references: array[index + displacement] where displacement can be 1 to 31.
"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

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3806
    • Host Engineering
Re: Deeper nesting for indirect addressing
« Reply #5 on: December 18, 2012, 07:18:18 AM »
Don't know if it is helpful or relevant, but remember that we can do displaced references: array[index + displacement] where displacement can be 1 to 31.
1..63, e.g. R[V10 + 63] as ANY input or output parameter whenever it takes an element reference, e.g. contact, coil, TMR preset, etc., not just inside MATH.

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: Deeper nesting for indirect addressing
« Reply #6 on: December 18, 2012, 09:30:39 AM »
On a similar note, will you be able use arrays for user defined Data types? If so can you have Arrays defined in the data type?

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: Deeper nesting for indirect addressing
« Reply #7 on: December 18, 2012, 09:43:12 AM »
Don't know if it is helpful or relevant, but remember that we can do displaced references: array[index + displacement] where displacement can be 1 to 31.

Can the "displacement" be a variable?
(I'm not where I can try it in the software right now)
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3806
    • Host Engineering
Re: Deeper nesting for indirect addressing
« Reply #8 on: December 18, 2012, 09:46:10 AM »
On a similar note, will you be able use arrays for user defined Data types? If so can you have Arrays defined in the data type?
ALL data-blocks are available to be arrays.  This includes user defined data-blocks.

So basically, if there is a number suffix as the ID, you can replace the ID with [Vnnnn] Vnnn register is the array index.
X[V11]  // if V11 equals 32, then this would reference X32
R[V22+17]  // if V22 is 3, then this would reference R20 (3 + 17)
T[V10].Acc  // yes, structure field reference (e.g. V10 is 99, this would reference T99.Acc)
D[V8+4]:0  // even casts (e.g. V8 is 42, this would reference the LSBit of D46 (42+4)

The one limitation on the array index is that it MUST be a V data type, which is an UNSIGNED INT with a range of 0..65535.  You cannot declare something else to be an array index EXCEPT in a MATH expression, which allows for ANY mathematical expression to be an array index (e.g. Y[SQRT(R2)], so when R2 is 81, this would reference Y9).
« Last Edit: December 18, 2012, 09:50:22 AM by franji1 »

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3806
    • Host Engineering
Re: Deeper nesting for indirect addressing
« Reply #9 on: December 18, 2012, 09:49:47 AM »
Can the "displacement" be a variable?
Only inside a MATH expression, where it can be ANY math expression like R[CT6.Acc + WX[CT[V22+5].Acc]]

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6154
  • Yes Pinky, Do-more will control the world!
Re: Deeper nesting for indirect addressing
« Reply #10 on: December 18, 2012, 10:04:12 AM »
Don't know if it is helpful or relevant, but remember that we can do displaced references: array[index + displacement] where displacement can be 1 to 31.
1..63, e.g. R[V10 + 63] as ANY input or output parameter whenever it takes an element reference, e.g. contact, coil, TMR preset, etc., not just inside MATH.

I have 5 bits stuck in the brain...this is probably the 3rd time I've done this...:sigh: Yes, 1 to 63.
"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

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: Deeper nesting for indirect addressing
« Reply #11 on: December 18, 2012, 10:28:54 AM »
Can the "displacement" be a variable?
Only inside a MATH expression, where it can be ANY math expression like R[CT6.Acc + WX[CT[V22+5].Acc]]

I don't think that will help me then. But I will look things over again this afternoon.
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: Deeper nesting for indirect addressing
« Reply #12 on: December 18, 2012, 05:36:43 PM »
Sorry, I didn't ask the right question. 

When you have the capability to add user defined structures, will you have the ability to have arrays in the structures and make arrays of the structures and be able to specify variables for both the indices of the main array and the elements in the arrays located in structure?

For instance. A user defined data structure called PN consisting of:

strName                string
bSwitchData[128]       Boolean
intRecipe[100]         integer


so create an array of type PN called PartNumber[1000]


Would you be able to access the element in this way:  PartNumber[V200].intRecipe[V35]




franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3806
    • Host Engineering
Re: Deeper nesting for indirect addressing
« Reply #13 on: December 18, 2012, 08:13:09 PM »
No.  Our data structures will just allow simple data types (e.g. BIT, UNSIGNED BYTE, REAL, etc.)

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3607
  • Darth Ladder
Re: Deeper nesting for indirect addressing
« Reply #14 on: December 20, 2012, 10:48:40 AM »
No.  Our data structures will just allow simple data types (e.g. BIT, UNSIGNED BYTE, REAL, etc.)

In that case let me put in a strong request for that capability in some future revision.  I definitely use arrays inside user defined types.

I also frequently create fundamental low level UDT's and nest them inside higher level ones, sometimes up to three levels deep, which sounds like it's out of bounds for the current concept as well.  It's a very useful ability to have, if you guys would be willing to do it.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.