Program execution in CPU

Operating SystemWindowsMCA

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 details 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.

As instructions are simply bit patterns, they can be stored in memory. Instruction pointer register always has the memory address of (points to) the next instruction to be executed. To execute this instruction for the control unit, it is copied into the instruction register.

The situation is as follows −

  • 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. Here, steps 3 - 7 make up a cycle, the instruction execution cycle. It is shown graphically in below figure −

raja
Published on 17-Oct-2019 14:47:23
Advertisements