The central processing unit (CPU) or processor is the component that executes instructions stored in Main Memory. At its core is a register called the program counter (PC), which holds the address of the current instruction.
From power-on to power-off, the processor continuously executes the instruction pointed to by the PC and updates the PC to the next instruction. This process follows a simple instruction execution model defined by the instruction set architecture, where instructions execute in sequence. The processor reads an instruction from memory, interprets it, performs the specified operation, and updates the PC to point to the next instruction, which might not be contiguous in memory.
The CPU performs a limited set of operations involving main memory, the register file, and the arithmetic/logic unit (ALU). The Register file consists of a collection of word-sized registers, each with a unique name. The ALU performs calculations and manipulations of data. Some examples of the basic operations the CPU might perform include:
- Load: Copy a byte or a word from main memory into a register, overwriting the previous contents of the register.
Store: Copy a byte or a word from a register to a location in main memory, overwriting the previous contents of that location.
Operate: Copy the contents of two registers to the ALU, perform an arithmetic operation on the two words, and store the result in a register, overwriting the previous contents of that register.
Jump: Extract a word from the instruction itself and copy that word into the program counter (PC), overwriting the previous value of the PC.
Although a processor seems to follow a straightforward instruction set architecture (ISA), modern processors employ complex mechanisms to enhance performance. The ISA defines what each machine-code instruction does, while the microarchitecture details how these instructions are implemented in hardware.