100 likes | 133 Views
20.2 The Instruction Cycle. Fetch an instruction from the main memory currently addressed by the PC and store the instruction in the IR. The PC is automatically increased by 1 so as to hold the address of the next instruction. Decode the instruction in the IR by the instruction decoder.
E N D
20.2 The Instruction Cycle • Fetch an instruction from the main memory currently addressed by the PC and store the instruction in the IR.
The PC is automatically increased by 1 so as to hold the address of the next instruction. • Decode the instruction in the IR by the instruction decoder. • Execute the instruction.
The instruction cycle is also called fetch-and-execute cycle.
Increase PC by 1 Start Fetch an instructionfrom the main memory Decode the instruction Execute the instruction
Let us now process the following instructions to make clear the concept of instruction cycle.
ALU Control unit Memory unit Main memory MAR +1 PC Adder(s) IR ACC SR Instructiondecoder MDR Fetch cycle of instruction 1 0001 0001 Instruction 1 0010 Instruction 2 0011 Instruction 3 0100 Instruction 4 0010 0001 Addressdecoder Instruction 1 Instruction 1
Control unit Memory unit ALU Main memory MAR +1 PC Adder(s) IR ACC SR Instructiondecoder MDR Execute cycle of instruction 1 1100 0001 Instruction 1 0010 Instruction 2 0011 Instruction 3 0100 Instruction 4 1100 4 1101 6 0010 Addressdecoder Instruction 1 4 4
The fetch cycle for instruction 2 and instruction 3 are similar to that of instruction 1. • The execute cycle of instruction 2 and instruction 3 are illustrated below:
ALU Control unit Memory unit Main memory MAR +1 PC Adder(s) IR ACC SR Instructiondecoder MDR Execute cycle of instruction 2 1101 0001 Instruction 1 0010 Instruction 2 0011 Instruction 3 0100 Instruction 4 1100 4 1101 6 0011 6 + 4 = 10 Addressdecoder Instruction 2 4 10 6
ALU Control unit Memory unit Main memory MAR +1 PC Adder(s) 0001 instruction 1 0010 instruction 2 0011 instruction 3 0100 instruction 4 1100 4 1101 6 1110 IR ACC SR Instruction decoder MDR Execute cycle of instruction 3 1110 0001 instruction 1 0010 instruction 2 0011 instruction 3 0100 instruction 4 1100 4 1101 6 0001 instruction 1 0010 instruction 2 0011 instruction 3 0100 instruction 4 1100 4 1101 6 1110 10 0100 Addressdecoder Instruction 3 4 10 6 10