Bit and Byte questions. Help needed.
Don M
Posts: 1,653
I have a byte that is comprised of these 8 bits: aabbcccc and want to be able to write to specific bits or pairs of bits.
I know (after learning from Jonny Macs help) that I can read / write to the upper and lower bits by "& $0F" or ">> 4" but I don't understand how I could read / write to the "aa" or "bb" bits.
Thanks.
Don
I know (after learning from Jonny Macs help) that I can read / write to the upper and lower bits by "& $0F" or ">> 4" but I don't understand how I could read / write to the "aa" or "bb" bits.
Thanks.
Don
Comments
[/FONT]
Bits- I'll look at your suggestion too. Thanks for your help.
Lets say I have byte abcd (a, b, c, d just represent the bit positions in the byte). Below is what I was thinking for a way to test it but was wondering if this is the best / easiest way to get a, b, c or d.
Thanks.
Don
I suspect you're making it harder than it is. This will return 1 or 0 from value.pos.
While we're at it, here are complimentary methods, set (to 1) and clear (to 0):