The accumulator
The one register the machine computes into
The accumulator is the single working register at the center of an accumulator-machine CPU: arithmetic and logic operations implicitly use it as one operand and write their result back into it, so an instruction like ADD means add a memory value to the accumulator.
Our CPU is an accumulator machine: it has one special register, the accumulator (
ACC), that every arithmetic instruction reads and writes without having to name it. LOAD puts a memory value into ACC; ADD adds a memory value to whatever is in ACC and leaves the sum in ACC; STORE copies ACC out to memory. The accumulator is where a computation accumulates, hence the name.Register plus ALU, wired in a loop
Physically the accumulator is a register whose output feeds one input of the ALU, and the ALU's result feeds back into the register's
D input. Each clock, the ALU combines ACC with the other operand (a byte from memory) and the register loads the result. Because the register only captures on the clock edge, that feedback loop is safe: the new value is written cleanly on each tick, exactly like the register bit feeding itself.on each ADD: ACC <- ACC + memory[addr]
ACCALU): the register ACC feeds the ALU, the ALU result loops back into ACC. Drive the function code (F0, F1) and the B operand and pulse the clock to run operations through it. Open it in the lab and step a sequence, clear, add 5, add 10, subtract 15, watching ACC show 0, 5, 15, 0. The ZERO flag lights when ACC is 0.Why one register?
Naming a single implicit register keeps instructions tiny. Because
ADD always means "add to ACC", the instruction does not need to spell out where the result goes, so one operand field (a memory address) is enough, and a whole instruction fits in one byte. That is the design behind our machine code. The tradeoff is that everything funnels through one register, so more values shuttle to and from memory; bigger CPUs add a register file of many general registers to reduce that traffic.Common mistakes. The accumulator is a single register, not memory: it holds one byte at a time, so a value you want to keep must be stored before the next
LOAD or ADD overwrites ACC. Do not confuse it with the program counter (which holds an address, not data). And in an accumulator machine the destination of arithmetic is implicit (always ACC), unlike register-file machines where you name the destination register.Try it
In our instruction set, where does the result of
ADD 0x2 land, and what was one of its operands?Answer
The result lands in the accumulator (
ACC). ADD 0x2 computes ACC + memory[0x2] and writes the sum back into ACC. One operand is the byte read from memory address 0x2; the other operand is the accumulator's current value, used implicitly.Frequently asked
What is an accumulator in a CPU?
The accumulator is the single working register an accumulator-machine CPU computes into. Arithmetic and logic instructions use it implicitly as one operand and write their result back into it, so
ADD addr means ACC = ACC + memory[addr].Why use an accumulator instead of many registers?
One implicit register keeps instructions small: since the destination is always the accumulator, an instruction only needs to name the other operand, so it fits in a single byte. The cost is more memory traffic; larger CPUs add a register file of many registers to cut that down.
How is the accumulator connected to the ALU?
The accumulator's output feeds one input of the ALU, and the ALU's result feeds back into the accumulator's data input. Each clock edge the ALU combines the accumulator with the other operand and the register captures the result, a safe feedback loop because the register only samples on the edge.
The accumulator is the target of the execute phase: once an instruction is fetched and decoded, execute routes an operand to the ALU and lands the result here.
Every lesson here builds toward one thing: a working CPU, from the transistor up.
Open the free lab →