Status C into Flowcode variable

For C and ASSEMBLY users to post questions and code snippets for programming in C and ASSEMBLY. And for any other C or ASM course related questions.

Moderators: Benj, Mods

User avatar
Jan Lichtenbelt
Posts: 794
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 261 times
Contact:

Status C into Flowcode variable

Postby Jan Lichtenbelt » Wed Dec 11, 2013 2:59 pm

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

User avatar
Jan Lichtenbelt
Posts: 794
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 261 times
Contact:

Re: Status C into Flowcode variable

Postby Jan Lichtenbelt » Wed Dec 11, 2013 6:46 pm

In the meanwhile I found a simple flowcode:

ReversMSB..LSB.jpg
ReversMSB..LSB.jpg (126.05 KiB) Viewed 5446 times

User avatar
Benj
Matrix Staff
Posts: 14373
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4150 times
Contact:

Re: Status C into Flowcode variable

Postby Benj » Wed Dec 11, 2013 8:16 pm

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
}

Spanish_dude
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

Postby Spanish_dude » Thu Dec 19, 2013 9:54 pm

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