News:

  • October 13, 2025, 03:40:07 AM

Login with username, password and session length

Author Topic: Indirect Bit Reference  (Read 1943 times)

RBPLC

  • Hero Member
  • *****
  • Posts: 585
Indirect Bit Reference
« 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.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6126
  • Yes Pinky, Do-more will control the world!
Re: Indirect Bit Reference
« Reply #1 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.
"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: 3761
    • Host Engineering
Re: Indirect Bit Reference
« Reply #2 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

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: Indirect Bit Reference
« Reply #3 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.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3601
  • Darth Ladder
Re: Indirect Bit Reference
« Reply #4 on: January 01, 2021, 12:09:55 AM »
Word & 1 << idx
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.