Unit content
Processor execution and machine instructions
A processor executes programs as sequences of machine instructions encoded in binary. Each instruction tells the processor to perform a small operation such as arithmetic, comparison, data movement or control flow.
Registers
Processors contain small, very fast storage locations called registers. Instructions commonly operate on values in registers and move data between registers and memory.
Program counter
A special register tracks the address of the next instruction to execute. Most instructions advance it to the following instruction, while branches and jumps can change it to another address.
Fetch, decode, execute
A simplified instruction cycle is
fetch instruction
↓
decode operation
↓
execute
↓
select next instruction
Real processors overlap and reorder work for performance, but this model captures the logical execution of an instruction stream.
Machine code and higher-level programs
Source code written in a programming language must ultimately be translated or interpreted into operations the processor can perform.
A single high-level statement may correspond to many machine instructions. Machine execution therefore provides the physical implementation beneath the programming abstractions of variables, functions and control flow.