===== Einzelne Bits auslesen =====
[[http://forums.parallax.com/forums/default.aspx?f=25&m=367713]]
Beispiel 1: Einzelnes Bit auslesen
PUB bittest(value, bit)
return (value & (1 << bit)) > 0
' This returns true if the bit is set, false if it is not.
Beispiel 2: Mehrere Bits mit Maske auslesen
PUB masktest(value, mask)
return (value & mask) == mask
'So if you want to check if bits 0, 3, and 7 of a value are set you could do this:
status := masktest(somevar, %10001001)
Beispiel 3: Bits mit Konstanten
CON
bit0 = |< 0
bit1 = |< 1
'...
bit30 = |< 30
bit31 = |< 31
PUB bittest | x
x := $38
if (x & bit1)
'...
Beispiel 4: Bits über Array
VAR
long bit[32]
PUB Start | i, x
repeat i from 0 to 31
bit[i] := |< i
x := $38
i := 4
if (x & bit[i])
'...