How do I represent a byte array position value into binary string?
Let's say I have a byte array of 16 bytes and also a 2 byte array. If any one of those 16 bytes is an $FF then I would want the corresponding position of one of the bits set in the 2 byte array. I know it's hard to explain.
Byte array of 16: $00, $03, $05, $FD, $FF, $FF, $EE, $FF, $09, $00, $03, $05, $FD, $FF, $50, $09
then the 2 byte array would look like this in binary: 0000 1101 0000 01000
So how do I go about testing the bytes in the array and then setting a bit in the 2 byte array (or 1 word) if it's an $FF?

Comments
In spin (probably much more efficient ways to do this, but this explains how):
'' Test RE: https://forums.parallax.com/discussion/173110/how-do-i-represent-a-byte-array-position-value-into-binary-string con _clkmode = xtal1 + pll16x _clkfreq = 80_000_000 obj term : "fullduplexserial" var byte arrayBytes[16] word bitArray dat dataBytes byte $00, $03, $05, $FD, $FF, $FF, $EE, $FF, $09, $00, $03, $05, $FD, $FF, $50, $09 pub main() | idx, mask term.start(63, 62, 0, 115_200) '' terminal setup term.str(string("Testing...")) term.tx(13) term.tx(10) bytemove(@arrayBytes, @dataBytes, 16) repeat idx from 15 to 0 if arrayBytes[idx] == $FF mask := 1 << (15 - idx) bitArray |= mask term.bin(bitArray, 16)dgately
Thanks. Much appreciated.
One more question.. leaving the dataBytes in the order they are in your example how do I reverse the order in the bitArray so it comes out 0010000010110000 ? I tried reversing the "repeat idx from 15 to 0" to "0 to 15" but it was still the same.
Figured it out. Changed mask := 1 << (15 - idx) to mask := 1 << ( idx)
Thanks.
Welcome...