BusSHR
Inputs
| Pin | Type | Description |
|---|---|---|
| A | bus8 | Input bus (8 bits) |
Outputs
| Pin | Type | Description |
|---|---|---|
| Q | bus8 | (A >>> 1) & 0xFF — shifted right by 1 |
How It Works
A right shift moves every bit of the bus one position to the right. The LSB (bit 0) falls off the edge and is lost, while a 0 arrives at the MSB (bit 7). Byte example: A = 00001100 (12) → Q = 00000110 (6).
This gives the operation its meaning: a right shift is division by 2 with the remainder discarded. The chain 12 → 6 → 3 → 1 → 0 shows how quickly the low bits burn away. In binary, shifts replace multiplication and division by powers of two — just as an extra zero on the right of a decimal number multiplies it by 10.
One nuance: BusSHR is a logical shift — a 0 is always written on the left. That is exactly what unsigned values need, but the sign bit is not preserved: an 8-bit two's-complement 11111111 (−1) turns into 01111111 (127).
8-bit Examples
| A (bin) | A (dec) | Q (bin) | Q (dec) |
|---|---|---|---|
| 00001100 | 12 | 00000110 | 6 |
| 00000001 | 1 | 00000000 | 0 |
| 10000000 | 128 | 01000000 | 64 |
| 11111111 | 255 | 01111111 | 127 |
Usage
In the ALU (level 13) a shift is a basic operation alongside AND, OR and addition. This is how the processor divides by 2, 4 and 8 without a dedicated division unit: three shifts in a row give division by 8.
The second role is bit extraction. In the Harvard architecture (level 16) an instruction fits in a single byte: the high 4 bits are the opcode, the low 4 bits the operand. Shift the instruction byte right by 4 to get the opcode; the remaining low bits are the operand. The same trick reads gamepad presses and switch states: shift right until the bit you need lands at position 0, then apply a mask with BusAND.
Related components
Related articles
Frequently Asked Questions
What happens to the shifted-out bit?
It is lost: a right shift is division by 2 with the remainder discarded.
How do I divide a number by 8 using shifts?
Three consecutive right shifts: each one halves the value, and 2 × 2 × 2 = 8. A single division becomes three cheap shifts.
What does shifting a negative number return?
BusSHR always writes 0 on the left, so the sign is not preserved: 11111111 (−1 in two's complement) becomes 01111111 (127). Signed values need an arithmetic shift that copies the sign bit — it is not part of the component set.