![]() |
![]() |
![]() |
![]() |
![]() |
|
Now that you know how to set the bits in a status variable, you need to
learn how to analyze those bits. First, however, you need to know about
the
bitwise-and operator, &. Given 2 bytes as operands in a
bitwise-and expression, the value produced is a byte whose bits are 1 in
exactly those positions where both operands have a 1:
*-*-*-*-*-*-*-*-*
|0|0|0|0|0|1|0|1| ----*
*-*-*-*-*-*-*-*-* |
|
v Combine with 1 using bitwise-and operator
|
*-*-*-*-*-*-*-*-* |
|0|0|0|0|0|0|0|1| -->-|
*-*-*-*-*-*-*-*-* |
|
v
|
*-*-*-*-*-*-*-*-* |
|0|0|0|0|0|0|0|1| <---*
*-*-*-*-*-*-*-*-*
*-*-*-*-*-*-*-*-*
|0|0|0|0|0|1|0|1| ----*
*-*-*-*-*-*-*-*-* |
v Combine with 2 using bitwise-and operator
*-*-*-*-*-*-*-*-* |
|0|0|0|0|0|0|1|0| -->-|
*-*-*-*-*-*-*-*-* |
v
*-*-*-*-*-*-*-*-* |
|0|0|0|0|0|0|0|0| <---*
*-*-*-*-*-*-*-*-*
*-*-*-*-*-*-*-*-*
|0|0|0|0|0|1|0|1| ----*
*-*-*-*-*-*-*-*-* |
v Combine with 4 using bitwise-and operator
*-*-*-*-*-*-*-*-* |
|0|0|0|0|0|1|0|0| -->-|
*-*-*-*-*-*-*-*-* |
v
*-*-*-*-*-*-*-*-* |
|0|0|0|0|0|1|0|0| <---*
*-*-*-*-*-*-*-*-*