Page 1 of 1

Status C into Flowcode variable

Posted: Wed Dec 11, 2013 2:59 pm
by Jan Lichtenbelt
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

Re: Status C into Flowcode variable

Posted: Wed Dec 11, 2013 6:46 pm
by Jan Lichtenbelt
In the meanwhile I found a simple flowcode:
ReversMSB..LSB.jpg
ReversMSB..LSB.jpg (126.05 KiB) Viewed 10445 times

Re: Status C into Flowcode variable

Posted: Wed Dec 11, 2013 8:16 pm
by Benj
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
}

Re: Status C into Flowcode variable

Posted: Thu Dec 19, 2013 9:54 pm
by Spanish_dude

Code: Select all

Return = 0

for (idx = 0; idx < 8; idx++)
{
    Bit = !!(ByteIn & (1 << idx));
    Return |= (Bit << (7 - idx));
}
I'd do it like this :P