The machine language program that is stored in the computer’s memory as a sequence of instructions would be executed in the following manner:
Each machine language instruction is first fetched from the memory and stored in an Instruction RegisterA register that stores the machine language instruction fetched from the memory. (IR). The address of the instruction to be fetched is stored in a register called Program Counter(PC) A register that holds the address of the next instruction to be fetched from the memory. or simply PC. In some computers this register is called the Instruction PointerAnother name for the program counter register. or IP.
After the instruction is fetched, the PC (or IP) is incremented to point to the address of the next instruction.
The fetched instruction is decoded (to determine what needs to be done) and executed by the CPU. The CPU also updates the PC or the IP with the address of the next instruction if there is a jump.
The above sequence of fetch-execute-fetch-execute (illustrated in Fig. m010120.1) repeats till the computer is halted. Fig. m010120.2 shows an example of a detailed fetch-execute process.
Fig. m010120.1 The Fetch-Execute Cycle
Fig. m010120.2 An example of Fetch-Execute cycles of a processor