Q. Show the steps of execution of instructions?
Fetch First Instruction into CPU:
Step 1: Find/calculate the address of first instruction in memory. In this machine illustration next instruction address is contained in PC register. It comprises 1 that is the address of first instruction to be executed. (Figure above part a).
Step 2: Bring binary instruction to IR register. This stage requires:
- Passing content of PC to Memory Address Registers so that instruction pointed to by PC is obtained i.e. location 1's content is fetched.
- CPU concerns 'Memory read' operation so brings contents of location pointed by MAR (1 in this particular case) to MBR register.
- Content of MBR is transferred to IR and PC is incremented to point to subsequent instruction in sequence (2 in this particular case).
Execute the Instruction
Step 3: IR has instruction LOAD A that is decoded like 'Load the content of address A in the accumulator register'.
Step 4: Address of operand which is 13 i.e. A is transferred to MAR register.
Step 5: Content of memory location (signified by MAR which is location 13) is transferred to MBR.
Step 6: Content of MBR is transferred to Accumulator Register.
So the accumulator register is loaded with content of location A that is 5. Now the instruction 1 execution is finished and the subsequent instruction which is 2 (specified by PC) is obtained and PC is incremented to 3. This instruction is ADD B that instructs CPU to add the contents of memory location B to accumulator. On execution of this instruction accumulator will comprise sum of its earlier value which is A and value stored in memory location B.
On execution of instruction at memory location 3 Program Counter becomes 4 and the accumulator results are stored in location C which is 15 and IR still comprises the third instruction. This condition is displayed in figure above part(C).
Please remember that execution of the instructions in above illustration is very simple and needs only data transfer and data processing operations in every instruction. Also these instructions need one memory reference at the time of its execution.