How to set / reset bit in the variable? (Spin)
Alarus
Posts: 48
How to set / reset any bit in the variable?
And how to test a bit in a variable?
Regards Alarus
And how to test a bit in a variable?
Regards Alarus

Comments
v |= |< bit ' set v ^= |< bit ' toggle v &= !|< bit ' reset if v & |< bit ' test ' do somethingThank you!
I wanted to use such construction: but your beautiful.
pub rd_bit(target, pos) '' returns bit value (0..1) of target.pos if ((pos => 0) and (pos =< 31)) return (target >> pos) & 1 else return 0 pub wr_bit(target, pos, value) '' writes value.0 to target.pos if (value & 1) return target | (1 << pos) else return target & !(1 << pos)<voice of Roger Rabbit> Pleeeease, Jonny? </Rabbit off>
My personal favorite way is to use the normally unused DIRB, INB, or OUTB registers...
Just like with INA, you can test and set bits in any of these...
Thanks for the idea Rayman.