I have to read the bits of a byte in the following order: MSB..LSB. The best option for me is to read the staus of the C-register after roll left (Byte<<1).
I have 2 questions:
1) How can I get the status of C into a Flowcode vaiable (boolean of byte)?
2) or is there an other, easier way to change the bit oder in opposite direction?
Kind regards
Jan Lichtenbelt
Status C into Flowcode variable
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Status C into Flowcode variable
Hi Jan,
Yep that looks good. I was going to suggest a way of doing it but your way is more efficient so I would use the method your currently using.
My method was going to look like this.
Return = 0
Index = 0
While Index < 8
{
Bit = (ByteIn & (1 << Index)) >> Index
Return = Return | (Bit << (7 - Index))
Index = Index + 1
}
Yep that looks good. I was going to suggest a way of doing it but your way is more efficient so I would use the method your currently using.
My method was going to look like this.
Return = 0
Index = 0
While Index < 8
{
Bit = (ByteIn & (1 << Index)) >> Index
Return = Return | (Bit << (7 - Index))
Index = Index + 1
}
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
- Contact:
Re: Status C into Flowcode variable
Code: Select all
Return = 0
for (idx = 0; idx < 8; idx++)
{
Bit = !!(ByteIn & (1 << idx));
Return |= (Bit << (7 - idx));
}