Mikroelektronika MIKROE-742 데이터 시트

다운로드
페이지 532
Bitwise Operators
Use bitwise operators to modify individual bits of numerical operands. Operands
need to be either both signed or both unsigned.
Bitwise operators associate from left to right. The only exception is the bitwise com-
plement operator not which associates from right to left.
Bitwise Operators Overview
Logical Operations on Bit Level
Bitwise operators and, or, and xor perform logical operations on the appropriate pairs of
bits of their operands. not operator complements each bit of its operand. For example:
158
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroPASCAL PRO for AVR
CHAPTER 5
Operator
Operation
and
bitwise AND; compares pairs of bits and generates a 1 result if both
bits are 1, otherwise it returns 0
or
bitwise (inclusive) OR; compares pairs of bits and generates a 1
result if either or both bits are 1, otherwise it returns 0
xor
bitwise exclusive OR (XOR); compares pairs of bits and generates a
1 result if the bits are complementary, otherwise it returns 0
not
bitwise complement (unary); inverts each bit
shl
bitwise shift left; moves the bits to the left, discards the far left bit
and assigns 0 to the right most bit.
shr
bitwise shift right; moves the bits to the right, discards the far right bit
and if unsigned assigns 0 to the left most bit, otherwise sign extends
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