A CPU is surprisingly simple at its core. It just does three things in an endless loop:
This Fetch-Decode-Execute cycle happens billions of times per second!
The CPU cycle:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β βββββββββββ β
β β Fetch β Read instruction at address RIP β
β ββββββ¬βββββ β
β β β
β βββββββββββ β
β β Decode β What does this instruction do? β
β ββββββ¬βββββ β
β β β
β βββββββββββ β
β βExecute β Do the operation β
β ββββββ¬βββββ β
β β β
β RIP += instruction_size (move to next) β
β β β
β βββββββββββββββββββββββββββββββββββββββββ (repeat)
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ