Introduction to CPU                                                                                                                                      Print this page
<< Previous |  First Last |  Next >>       

Concept of Program Execution

The instructions constituting a program to be executed by a computer are loaded in sequential locations in its main memory. To execute this program, the CPU fetches one instruction at a time and performs the functions specified. Instructions are fetched from successive memory locations until the execution of a branch or a jump instruction.

The CPU keeps track of the address of the memory location where the next instruction is located through the use of a dedicated CPU register, referred to as the program counter (PC). After fetching an instruction, the contents of the PC are updated to point at the next instruction in sequence.

For simplicity, let us assume that each instruction occupies one memory word. Therefore, execution of one instruction requires the following three steps to be performed by the CPU:

  1. Fetch the contents of the memory location pointed at by the PC. The contents of this location are interpreted as an instruction to be executed. Hence, they are stored in the instruction register (IR). Symbolically this can be written as:
                               IR  = [ [PC] ]
                                      
  2. Increment the contents of the PC by 1.
            
                       PC = [PC] + 1
                                     
  3. Carry out the actions specified by the instruction stored in the IR.
<< Previous |  First |  Last |  Next >>