• Any program you’ve ever run has a corresponding machine code in a file somewhere
  • The operating system loads this into RAM and instructs the CPU to jump the Instruction Pointer to that position in RAM
  • The CPU continues running its fetch-execute cycle and the program begins executing!
  • CPUs have a super basic worldview; they only see the current instruction pointer and a bit of internal state. Processes are entirely OS abstractions, not something CPUs natively understand or keep track of.

Warning

The CPU always reads machine code directly from RAM, and code can’t be run if it isn’t loaded into RAM.


Fetch-execute cycle

The CPU stores an instruction pointer which points to the location in RAM where it’s going to fetch the next instruction. After executing each instruction, the CPU moves the pointer and repeats. This is the fetch-execute cycle


Refs

  1. https://cpu.land/the-basics