Program execution in CPU

One may be amazed how the CPU is programmed. A special register is contained in CPU − the instruction register − whose bit pattern determines what the CPU will do. Once that action has been completed, the bit pattern in the instruction register can be changed, and the CPU will perform the operation specified by this next bit pattern.

Most of the modern CPUs use an instruction queue. Some instructions are waiting in the queue, ready to be executed. Different electronic circuitry keeps the instruction queue full while the control unit is executing the instructions. But this is simply an implementation detail that allows the control unit to run faster. The nature of how the control unit executes a program is represented by the single instruction register model.

How Instructions Are Executed

As instructions are simply bit patterns, they can be stored in memory. The instruction pointer register (also called program counter) always has the memory address of the next instruction to be executed. To execute this instruction, the control unit copies it into the instruction register.

The Instruction Execution Cycle

The CPU follows a systematic process to execute programs −

  • A sequence of instructions is stored in memory.

  • The memory address where the first instruction is located is copied to the program counter.

  • The CPU sends the address in the program counter to memory via the address bus.

  • Memory responds by sending a copy of the state of the bits at that memory location on the data bus, which the CPU then copies into its instruction register.

  • The instruction pointer is automatically incremented to contain the address of the next instruction in memory.

  • The CPU executes the instruction in the instruction register.

  • Go to step 3.

Steps 3, 4, and 5 are called an instruction fetch. Steps 3-7 make up a complete cycle, the instruction execution cycle.

Instruction Execution Cycle Memory Instruction 1 Instruction 2 Instruction 3 CPU Program Counter Instruction Register Control Unit (Execute) Address Bus Data Bus Execution Steps: 1. PC holds address of next instruction 2. Address sent to memory via address bus 3. Instruction fetched via data bus to IR 4. PC incremented to next instruction 5. Control unit executes the instruction

Key Components

Component Function
Program Counter (PC) Holds the memory address of the next instruction to be executed
Instruction Register (IR) Stores the current instruction being executed
Address Bus Carries memory addresses from CPU to memory
Data Bus Carries instruction data from memory to CPU
Control Unit Decodes and executes the instruction

Fetch-Decode-Execute Phases

The instruction execution cycle can be broken down into three main phases −

  • Fetch − The CPU retrieves the instruction from memory using the program counter.

  • Decode − The control unit interprets the instruction and determines what operation to perform.

  • Execute − The CPU performs the required operation and updates the program counter.

Conclusion

Program execution in CPU follows a systematic fetch-decode-execute cycle. The program counter tracks the next instruction, while the instruction register holds the current instruction. This continuous cycle, supported by address and data buses, enables the CPU to execute stored programs sequentially and efficiently.

Updated on: 2026-03-17T09:01:38+05:30

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements