BusOR
Inputs
| Pin | Type | Description |
|---|---|---|
| A | bus8 | First input bus (8 bits) |
| B | bus8 | Second input bus (8 bits) |
Outputs
| Pin | Type | Description |
|---|---|---|
| Q | bus8 | Bitwise OR: A | B |
How It Works
BusOR also compares two buses position by position, but the rule is different: a 1 appears on the output wherever there is at least one 1 — on bus A, on bus B, or on both at once. A zero comes out of exactly one combination: 0 OR 0 = 0. A familiar picture: two switches wired in parallel to one lamp — close either one and the light is already on.
The key property is setting bits. Where the mask bit is 0, the value from A passes to the output unchanged; where it is 1, the bit is forced to one. A byte example: 10000000 OR 00001111 = 10001111 — the mask switched on the four low bits without touching the rest. And gluing nibbles looks like this: 11110000 OR 00001111 = 11111111 — two halves merge into a whole byte without a single conflict.
A subtlety: OR cannot erase — you cannot remove a one by feeding something into the second input. A OR 11111111 always gives 255: the byte floods with ones. That is why "set bit" and "clear bit" are separate operations in processors: the first is OR with a mask, the second is AND with an inverted mask.
8-bit Examples
| A (bin) | B (bin) | Q (bin) | Q (dec) |
|---|---|---|---|
| 11110000 | 00001111 | 11111111 | 255 |
| 10000000 | 00001111 | 10001111 | 143 |
| 10101010 | 00000000 | 10101010 | 170 |
| 00001111 | 00001111 | 00001111 | 15 |
Usage
In the ALU (level 13), bus OR stands alongside AND, XOR and addition — the basic toolkit for byte operations. Inside the processor, OR is in charge of setting flags and statuses: lay down a mask with a 1 in the right position, and the status bit switches on while the rest stay untouched. This is how the "carry", "zero" and "overflow" status bytes get built.
The main design role is assembling a byte out of pieces. In the Harvard architecture (level 16) an instruction is an opcode in the high nibble and an operand in the low one. Shifting the opcode left by 4 positions through BusSHL, the processor glues the halves together with a single OR: (opcode << 4) OR operand — a finished byte ready to be written into program memory. The same trick assembles pixel coordinates on the MatrixDisplay and merges status bits of several devices into one shared byte.
Related components
Related articles
Frequently Asked Questions
Where is bitwise OR used?
For setting bits of a number and merging flags: a single 1 bit is enough.
How do I set one bit to 1 without touching the others?
Use a mask with a 1 only in the right position: 10101010 OR 00000100 = 10101110 — bit 2 is on, the other bits are unchanged.
How does OR differ from exclusive OR?
OR switches a bit on and keeps it on: 1 OR 1 = 1. XOR works as a toggle: 1 XOR 1 = 0, and applying the same mask a second time restores everything as it was.