Shop
OBEX
P1 Docs
P2 Docs
Learn
Events
addressing bits of a variable — Parallax Forums
toggle menu
Categories
Discussions
Sign In
·
Register
Sign In
·
Register
Categories
Discussions
Sign In
·
Register
×
Home
›
Propeller 1
addressing bits of a variable
agfa
Posts:
295
2008-08-31 13:31
edited 2008-09-01 01:53
in
Propeller 1
can an individual bit of variable be set, reset, or tested: if variable/bit2=1 then do something?
Comments
John Abshier
Posts:
1,116
2008-08-31 14:09
edited 2008-08-31 14:09
1) To set a bit "n": x |= |< n
2) To clear a bit "n": x &= ! |< n
3) To toggle a bit "n": x ^= |< n
4) To test for bit "n" true: IF x & |< n <> 0
5) To test for bit "n" false: IF x & |< n == 0
John Abshier
agfa
Posts:
295
2008-09-01 01:53
edited 2008-09-01 01:53
thanks John.
Sign In
or
Register
to comment.
Comments
2) To clear a bit "n": x &= ! |< n
3) To toggle a bit "n": x ^= |< n
4) To test for bit "n" true: IF x & |< n <> 0
5) To test for bit "n" false: IF x & |< n == 0
John Abshier