BusZero
Inputs
| Pin | Type | Description |
|---|---|---|
| A | bus8 | Input bus to check (8 bits) |
Outputs
| Pin | Type | Description |
|---|---|---|
| Q | bit | 1 if A = 0 (all bits zero), 0 otherwise |
How It Works
BusZero compresses a whole byte into a single verdict bit: "is the bus empty or not?". Inside, it is an eight-input NOR: all the bits are first gathered through an OR, and the result is inverted. A 1 appears on the output in exactly one case — when all eight bits are zero. At least one 1 anywhere on the bus — and the verdict is already 0: even a single bit in the low position breaks the check.
The key property: BusZero tests "is it equal to zero" without breaking the byte into separate bits. You do not need to route eight wires and build a cascade of gates — one node produces a ready-made flag. It shines even brighter in tandem with BusXOR: run A XOR B through the detector and you get a comparator — a 1 on the output means A = B. This is how the processor compares two numbers without having a dedicated comparison unit.
A subtlety: BusZero is combinational — it does not remember its result. The bus changes and the flag is recomputed within the same tick; the node keeps no history. And do not expect anything extra from it: it knows nothing about sign or magnitude, it answers exactly one question — are all the bits empty.
8-bit Examples
| A (bin) | A (dec) | Q |
|---|---|---|
| 00000000 | 0 | 1 |
| 00000001 | 1 | 0 |
| 10000000 | 128 | 0 |
| 11111111 | 255 | 0 |
Usage
This is the zero flag Z itself — one of the most important processor status bits. After arithmetic, the ALU result runs through the zero detector, and the Z flag records: "the result was zero". Conditional jumps JZ and JNZ and "while not zero" loops are built on it: a counter decreases by one per iteration, and as soon as it hits zero, the processor leaves the loop. This is how delays and step counting work.
The second role is checking values without corrupting them: the detector taps into the bus from the side and changes nothing on it. In level 25, "Negative Check", flags help the processor branch on the state of a number. Equality of two values is tested with the BusXOR + BusZero combo: first the XOR, then the zero check. The same flag stands behind assembler commands: "if the result is zero — jump", otherwise keep going in order.
Related components
Related articles
Frequently Asked Questions
How do you detect a zero bus?
BusZero outputs 1 only when all 8 bits are 0. It is handy for the JZ conditional jump.
How is BusZero different from the ALU8 Zero flag?
The built-in ALU8 flag checks only arithmetic results, while BusZero attaches to any bus: data from RAM, gamepad state, the current counter. It shows zero where you need it, not only where the ALU computes.
How do I compare two numbers using BusZero?
XOR first: A XOR B gives zero only when the values match. Feed the result into BusZero: a 1 means "the numbers are equal", a 0 means "they differ". That is the comparator circuit.