Bit and Byte questions. Help needed.
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
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 CR = $0D LF = $0A NULL = $00 DAT data byte %10101011 VAR OBJ pst : "Parallax Serial Terminal" PUB Main | i pst.Start(115_200) pause(500) repeat i from 0 to 7 pst.str(string("Bit ")) pst.dec(i) pst.str(string(" = ")) pst.dec(GetBit(data, i)) pst.char(CR) return PUB GetBit(value, position) if (value & |< position) return 1 else return 0 PRI pause(Duration) waitcnt(((clkfreq / 1_000 * Duration - 3932) #> 381) + cnt) returnI 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):