Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: RBPLC on December 30, 2020, 06:28:30 PM

Title: Indirect Bit Reference
Post by: RBPLC on December 30, 2020, 06:28:30 PM
Should it be possible to do: VWord:IndirectBit#. I was trying to do this in a for loop and it will not work. Direct reference VWord:B0, no issues.
Title: Re: Indirect Bit Reference
Post by: BobO on December 31, 2020, 01:24:57 AM
Should it be possible to do: VWord:IndirectBit#. I was trying to do this in a for loop and it will not work. Direct reference VWord:B0, no issues.

No. There is no indirection in casts.
Title: Re: Indirect Bit Reference
Post by: franji1 on December 31, 2020, 10:09:44 AM
Instead of interpreting a word as bits, use 16 bits and interpret as WORDs when needed.

By doing bits as the "native" size, you can do indirect bit number (i.e. use it in a FOR loop), but still reference it as a WORD when needed by doing a :UW cast.

To cast 16 bits as a WORD, the starting bit must be WORD aligned, e.g. C0:UB, C16:UB, C32:UB, C48:UB
Title: Re: Indirect Bit Reference
Post by: ATU on December 31, 2020, 10:34:38 AM
If you still want to keep your data in non boolean memory, you can do an intermediate copy over to a temporary bit array, and then reference the bits that way.  Although, if you can keep it in a bit array, its one less step.
Title: Re: Indirect Bit Reference
Post by: Controls Guy on January 01, 2021, 12:09:55 AM
Word & 1 << idx