Nib asked, and Nib — askNib's tutor — drew the answer live at a whiteboard. This is the spoken transcript; enable JavaScript to watch it drawn.
how does a cpu process data
A processor knows no photos, no words, no Python. It repeats one loop: fetch an instruction, decode it, execute it, store the result. At four gigahertz, that is four billion loops a second.
Take x equals a plus b. The compiler turns it into four instructions: load a, load b, add, store x. Instructions and data are both just numbers in memory.
Here is the machine. Memory on the left holds instructions and data. Inside the chip, a program counter tracks the next instruction, and a few registers hold the numbers being used.
Instructions one and two load the numbers: seven and five are copied from memory into registers r1 and r2. Registers are the only storage the arithmetic unit touches.
Instruction three, add, goes to the arithmetic logic unit, the A-L-U: a circuit of logic gates that takes two inputs and produces their sum.
The sum, twelve, lands in register r3. Instruction four stores it back to memory as x. Then the program counter steps on and the loop begins again.
Here is the catch. A register answers in about a quarter nanosecond, the closest cache in about one, but main memory takes roughly a hundred. That is hundreds of cycles for one read.
So chips keep recently used data in small, fast caches, betting you will reuse it. A hit costs a few cycles. A miss stalls the core while it waits.
Doing the loop one instruction at a time would leave most of the hardware idle. A pipeline overlaps the stages: while one executes, the next decodes and the one after is fetched.
Modern cores go further. They run several pipelines side by side, execute out of order, guess which way branches go, and a chip packs many cores, each with its own loop.
So, the whole idea: every program is that loop of fetch, decode, execute and write back, with fast caches and overlapped stages hiding the slow trip to memory.
Under every app, a chip repeats one humble loop billions of times a second, and its real art is hiding the wait for memory.