How CPUs Actually Work
Before writing a single line, you need a mental model of what the CPU is doing. Everything in assembly makes sense once you understand registers, memory, and the fetch-decode-execute cycle.
A CPU is a machine that reads instructions from memory one at a time, executes them, and moves to the next. An instruction might be "add two numbers," "copy a value from memory," or "jump to a different instruction." That's it. Everything your computer does — 3D games, video calls, AI — reduces to sequences of these tiny operations.
Registers are small, fast storage locations inside the CPU itself. x86-64 has 16 general-purpose registers: rax, rbx, rcx, rdx, rsi, rdi, rbp, rsp, and r8–r15. Each holds 64 bits (8 bytes). Operations on registers are the fastest thing the CPU can do — no memory access required.
Memory is a huge array of bytes, each with an address (a 64-bit number on x86-64). To use data in memory, you load it into a register, operate on it, then store it back. The stack is a region of memory that grows downward — rsp points to the current top. The heap is where malloc lives. Code lives in the text segment.
Assembly is architecture-specific. x86-64 (what you run on your laptop and most servers) is what we cover here. ARM64 (your phone, Apple Silicon, Raspberry Pi) has a cleaner instruction set but different syntax and conventions. The concepts transfer; the specifics do not.