BusSHL
Inputs
| Pin | Type | Description |
|---|---|---|
| A | bus8 | Input bus (8 bits) |
Outputs
| Pin | Type | Description |
|---|---|---|
| Q | bus8 | (A << 1) & 0xFF — shifted left by 1 |
How It Works
BusSHL moves all eight bits of the bus one position to the left. The low bit (bit 0) is vacated, and a zero arrives in its place, while the high bit (bit 7) is pushed off the edge and lost. A byte example: A = 00000011 (3) → Q = 00000110 (6). It helps to watch a shift like a ticker tape: every bit moves one seat to the left, and the tail is refilled with zeros.
This gives the operation its meaning: a left shift is multiplication by 2. In binary, each digit weighs twice as much as its right neighbor, so moving a bit left doubles its contribution to the value. The chain 3 → 6 → 12 → 24 doubles the number at every step. Three shifts in a row give multiplication by 8 — without a single multiplication unit, just wires.
A subtlety: the bus is eight bits wide, so the result is taken modulo 256. If the high bit was a one, it falls off — an overflow: 10000000 (128) becomes 00000000 (0) after the shift. Every value from 128 up gets multiplied "with clipping", so before a long series of shifts, estimate whether the result will exceed 255.
8-bit Examples
| A (bin) | A (dec) | Q (bin) | Q (dec) |
|---|---|---|---|
| 00000011 | 3 | 00000110 | 6 |
| 00000101 | 5 | 00001010 | 10 |
| 10000000 | 128 | 00000000 | 0 |
| 11111111 | 255 | 11111110 | 254 |
Usage
In the ALU (level 13) the left shift stands next to AND, OR and addition, covering multiplication by powers of two: ×2 is one shift, ×4 is two, ×8 is three. Multiplication by an arbitrary number decomposes into a sum of shifts: A × 5 = (A << 2) + A — that is two shifts and one addition. The processor does not need a real multiplier at all.
The second role is assembling and parsing bytes. In level 19, "Step Forward", a shift doubles the program counter step from +1 to +2: instructions occupy two bytes, and the PC has to jump over both. And when forming an instruction in the Harvard architecture (level 16), the opcode is shifted left by 4 positions — moving from the low nibble to the high one — and glued to the operand with BusOR. Without the shift, the opcode and the operand would still be neighbors in the same nibble.
Related components
Related articles
Frequently Asked Questions
Why does a left shift multiply a number by 2?
Each shift appends a zero bit on the right — in binary that doubles the number.
Where does the high bit go?
It leaves the 8-bit bus and is lost. For values from 128 this distorts the result: 10000000 (128) becomes 00000000. A value escaping the digit grid is called an overflow.
How do I multiply a number by 4 using shifts?
Two BusSHL units in a row: the first gives ×2, the second another ×2 — ×4 in total. The rule is simple: N shifts = multiplication by 2 to the power of N.