CPU Instruction Cycle
From when the computer is boot-up until shutdown, it follows the cycle to process instructions.
Components
The program counter (PC) is the register that holds the memory address of the next instruction to be executed.
The memory address register (MAR) holds the address of the instruction to be executed.
The memory data register (MDR) acts as a two-way register that holds data fetched from memory or data waiting to be stored in memory (can also be known as MBR).
The current instruction register (CIR) acts as a temporary storage for the instruction fetched from memory.
The control unit (CU) decodes the instruction in the CIR and sends signals to the arithmetic logic unit (ALU) and the floating point unit (FPU)
Fetch
- The address of the
PCis copied into theMAR. - The
PCis incremented to point to the next instruction. - The instruction in address at
MARis copied to theMDR. - The instruction in
MDRis copied to theCIR.
Decode
- The encoded instruction held in the
CIRis decoded.
Execute
- The
CUof the CPU passes the decoded information as signals to the CPU (FPUorALU) to perform the instructions and storing the result back into memory, register or an output device. - Example operations: Add, Subtract, AND, OR, Branches of execution, XOR.