Assembly & the CPU

the CPU, ALU, and control unit

Picture a tiny, tireless worker sitting inside the chip. It does only one kind of thing: pick up the next instruction, do exactly what it says, then reach for the next one. It cannot get bored, it cannot improvise, and it does this billions of times a second. That worker is the CPU, the central processing unit, the part of the computer that actually runs your program.

Inside the CPU two pieces do most of the visible work. The ALU, the arithmetic logic unit, is the calculator: it adds, subtracts, compares two numbers, and performs bitwise operations like x & 0xFF or x << 3. The control unit is the foreman: it reads each instruction, figures out what it means, and tells the rest of the CPU what to do and in what order — which register to read, whether the ALU should add or subtract, where to write the result, and which instruction comes next. Neither part decides what your program should do; they only carry out the instructions the compiler already produced.

Everything higher up — your C code, the operating system, a web browser — ultimately turns into a stream of these tiny machine instructions that the control unit feeds to the ALU and other units, one after another. Knowing that the machine is this literal-minded is the foundation for the rest of this field: a register, an instruction, the stack, a calling convention all describe how that one small worker is kept fed and organised.

To compute c = a + b: the control unit fetches the add instruction, hands a and b to the ALU, the ALU produces the sum, and the control unit writes it back to where c lives.

The control unit directs; the ALU computes. Each is dumb alone, and together they run everything.

Real CPUs add caches, pipelines, multiple cores, and out-of-order execution, but none of that changes the contract: the visible result is as if instructions ran one at a time in order. The ALU/control-unit split is a teaching model, not the literal floor plan of a modern chip.

Also called
processorcentral processing unit處理器中央處理單元