2.6 Logical Operations on Bits
There are four primary logical operations we'll do with hexadecimal and binary numbers: and
, or
, xor
(exclusive-or), and not
. Unlike for the arithmetic operations, a hexadecimal calculator isn't necessary to perform these operations. It is often easier to do them by hand than to use an electronic device to compute them. The logical and
operation is a dyadic[22] operation (meaning it accepts exactly two operands). These operands are individual binary bits. The and
operation is:
0 and 0 = 0 0 and 1 = 0 1 and 0 = 0 1 and 1 = 1
A compact way to represent the logical and
operation is with a truth table. A truth table takes the form shown in Table 2-2.
Table 2-2. and
Truth Table
| 0 | 1 |
---|---|---|
0 | 0 | 0 |
1 | 0 | 1 |
This is just like the multiplication ...
Get The Art of Assembly Language, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.