Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: Bolt on December 20, 2021, 10:14:24 AM

Title: SUMR on a UDT
Post by: Bolt on December 20, 2021, 10:14:24 AM
Is there a simple way to do SUMR on a group of values in a UDT?  If I have my memory lay out as V0=Value0, V1=Value1,... V9=Value9 it is easy, SUMR(V0,10).  Now if I do MemBlock0.Value, MemBlock1.Value,... MemBlock9.Value, it becomes trickier.  Do I need to do a FOR loop to create a SUM, or something else?
Title: Re: SUMR on a UDT
Post by: Greg on January 18, 2022, 12:49:02 PM
Sorry you never received a reply on this. You probably figured it out already, that the only way to do this is a FOR/NEXT loop with a MATH instruction that indexes using V0 for your MemBlock[V0].Value structure. If there's a better way, I'd like to see it too.
Title: Re: SUMR on a UDT
Post by: Controls Guy on January 19, 2022, 05:35:44 PM
It kind of relates to the need for a syntax for subsetting n-D arrays and slicing in arbitrary direction.
Title: Re: SUMR on a UDT
Post by: Bolt on January 20, 2022, 03:07:26 PM
Yes, I ended up doing a loop with some MATH instructions to summarize everything.  It works out alright, some values in the UDT needed to be minimum/maximum calculations, others sums or averages, so some extra syntax in a loop isn't the end of the world.  Keeps the brain sharpened.