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

Post Reply
User avatar
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:

Status C into Flowcode variable

Post 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

User avatar
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:

Re: Status C into Flowcode variable

Post by Jan Lichtenbelt »

In the meanwhile I found a simple flowcode:
ReversMSB..LSB.jpg
ReversMSB..LSB.jpg (126.05 KiB) Viewed 10130 times

User avatar
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

Post 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
}

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

Post 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

Post Reply