How does CPU execute program instructions?

CPU executes instructions as follows instructions are in primary memory various steps are:

1. Place the address of instruction which is in a register called PC in another register called memory address register.

2. Memory receives the address and selects the location where the instruction is stored.

3. CPU send read signal and on receiving read signal, memory send the instruction through data bus to processor.

4. Instruction send by the memory is stored inside CPU in a register called instruction register.

5. CPU decodes the instruction in the instruction register to determine what operation is to be performed. If any data is to be fetched from memory as operand CPU will do it. To fetch data from memory, data's address is send through MAR to memory and read signal is given. Data from memory is placed in MDR.

6. Once data required for executing the instruction is available CPU perform the activity mentioned in the instruction. The result generated is stored. Results may be stored in register or in memory. If results are stored in memory, then the address of memory location where results is to be stored is placed in MAR and then places the data in MDR and then CPU send the write signal. Now data in MDR is entered in the selected memory location. If result is to be entered in registers then it is done internally.

7. Once an instruction is executed PC is incremented by the length of the instruction so that PC contains address of next generation. Now CPU can fetch and execute next instruction.

Post a Comment