FREE LESSON · Machine code & execution · 1 OF 4

How Machine Code and CPU Instructions Work

State changes one instruction at a time — Registers, addresses, and control flow

Machine code is explicit state transformation.

An instruction decodes into an operation over registers, immediates, memory, flags, and the program counter. Loads and stores move data across the register–memory boundary. Branches choose the next instruction according to values or flags. The ISA defines the result even when the processor overlaps many instructions internally.

To debug low-level code, write the state before and after the instruction you distrust.

Addressing computes a location, not a value

An instruction such as load r0, [base + index×4] first computes an effective address. It then requests bytes from that address and interprets their width and signedness. Confusing the address with the stored value is the classic pointer mistake in another costume.

Every memory access has three questions: which address, how many bytes, and what interpretation?
Open this lesson in the interactive course →