Mikroelektronika MIKROE-442 데이터 시트
220
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
Logical Operations on Bit Level
and
0
1
0
0
0
1
0
1
or
0
1
0
0
1
1
1
1
xor
0
1
0
0
1
1
1
0
not
0
1
1
0
The bitwise operators
and, or,
and
xor
perform logical operations on the appropriate pairs of bits of their oper-
ands. The operator
not
complements each bit of its operand. For example:
$1234 and $5678 ‘ equals $1230
‘ because ..
‘ $1234 : 0001 0010 0011 0100
‘ $5678 : 0101 0110 0111 1000
‘ ----------------------------
‘ and : 0001 0010 0011 0000
‘ .. that is, $1230
‘ Similarly:
$1234 or $5678 ‘ equals $567C
$1234 xor $5678 ‘ equals $444C
not $1234 ‘ equals $EDCB
Unsigned and Conversions
If a number is converted from less complex to more complex data type, the upper bytes are filled with zeroes. If a
number is converted from more complex to less complex data type, the data is simply truncated (the upper bytes are
lost).
For example:
dim a as byte
dim b as word
‘ ...
a = $AA
b = $F0F0
b = b and a
‘ a is extended with zeroes; b becomes $00A0