||This article may require cleanup to meet Wikipedia's quality standards. (September 2008)|
|This article needs additional citations for verification. (October 2009)|
An instruction cycle (sometimes called fetch-and-execute cycle, fetch-decode-execute cycle, or FDX) is the basic operation cycle of a computer. It is the process by which a computer retrieves a program instruction from its memory, determines what actions the instruction requires, and carries out those actions. This cycle is repeated continuously by the central processing unit (CPU), from bootup to when the computer is shut down.
In simpler CPUs, the instruction cycle is executed sequentially: each instruction is completely processed before the next one is started. In most modern CPUs, the instruction cycle is instead executed concurrently in parallel, as an instruction pipeline: the next instruction starts being processed before the previous instruction is finished, which is possible because the cycle is broken up into separate steps.
The circuits used in the CPU during the cycle are:
- Program counter (PC) - an incrementing counter that keeps track of the memory address of the instruction that is to be executed next or in other words, holds the address of the next instruction to be executed next.
- Memory address register (MAR) - holds the address of a memory block to be read from or written to.
- Memory data register (MDR) - a two-way register that holds data fetched from memory (and ready for the CPU to process) or data waiting to be stored in memory.
- Instruction register (IR) - a temporary holding ground for the instruction that has just been fetched from memory.
- Control unit (CU) - decodes the program instruction in the IR, selecting machine resources such as a data source register and a particular arithmetic operation, and coordinates activation of those resources.
- Arithmetic logic unit (ALU) - performs mathematical and logical operations.
Each computer's CPU can have different cycles based on different instruction sets, but will be similar to the following cycle:
1. Fetching the instruction
The next instruction is fetched from the memory address that is currently stored in the program counter (PC), and stored in the instruction register (IR). At the end of the fetch operation, the PC points to the next instruction that will be read at the next cycle.
2. Decode the instruction
The decoder interprets the instruction. During this cycle the instruction inside the IR (instruction register) gets decoded.
3.In case of a memory instruction (direct or indirect) the execution phase will be in the next clock pulse.
If the instruction has an indirect address, the effective address is read from main memory, and any required data is fetched from main memory to be processed and then placed into data registers(Clock Pulse: T3). If the instruction is direct, nothing is done at this clock pulse. If this is an I/O instruction or a Register instruction, the operation is performed (executed) at clock Pulse.
4. Execute the instruction
The control unit of the CPU passes the decoded information as a sequence of control signals to the relevant function units of the CPU to perform the actions required by the instruction such as reading values from registers, passing them to the ALU to perform mathematical or logic functions on them, and writing the result back to a register. If the ALU is involved, it sends a condition signal back to the CU.
The result generated by the operation is stored in the main memory, or sent to an output device. Based on the condition of any feedback from the ALU, Program Counter may be updated to a different address from which the next instruction will be fetched.
The cycle is then repeated.
Initiating the cycle
The cycle starts immediately when power is applied to the system using an initial PC value that is predefined for the system architecture (in Intel IA-32 CPUs, for instance, the predefined PC value is
0xfffffff0). Typically this address points to instructions in a read-only memory (ROM) which begins the process of loading the operating system. (That loading process is called booting.) 
Step 1 of the Instruction Cycle is called the Fetch Cycle. These steps are the same for each instruction. The fetch cycle processes the instruction from the instruction word which contains an opcode.
Step 2 of the instruction Cycle is called the Decode Cycle. The opcode fetched from the memory is decoded for the next steps and moved to the appropriate registers.
Read the effective address
Step 3 is deciding which operation it is. If this is a Memory operation - in this step the computer checks if it's a direct or indirect memory operation:
- Direct memory instruction - Nothing is being done.
- Indirect memory instruction - The effective address is being read from the memory.
If this is a I/O or Register instruction - the computer checks its kind and executes the instruction.
Step 4 of the Instruction Cycle is the Execute Cycle. These steps will change with each instruction.
Data is transferred between the CPU and the I/O module. Next, arithmetic and logical operations given in the instructions are executed.
- Bosky Agarwal (2004). "Instruction Fetch Execute Cycle". Retrieved 2012-10-14.