Interactive exploration of Logic and Shift Operations
The basic computer has three machine instructions for logic operations: AND, CMA (Complement), and CLA (Clear). All 16 logic operations can be implemented using software with AND and complement operations.
| A | B | AND | OR | XOR | NAND | NOR |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 |
Since OR is not available as a machine instruction, we use DeMorgan's theorem: A + B = (A' â§ B')'
Shift operations move bits left or right within a register. There are three types: circular shifts, logical shifts, and arithmetic shifts.
Logical shifts add zeros to the extreme positions.
Arithmetic shifts preserve the sign bit for signed number representation.