The machine instruction cycle: Difference between revisions

From Computer Science Wiki
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 4: Line 4:


[[File:Fetch-execute-cycle.png|400px]]
[[File:Fetch-execute-cycle.png|400px]]
'''Data Bus:''' A data bus is a connection between the different parts of a computer that information is sent on.
'''Address Bus:''' The address bus is a data bus that is used to specify a physical address. A CPU will specify the memory location.<ref>https://compsci2014.wikispaces.com/2.1.4+Explain+the+machine+instruction+cycle</ref>


<br />
<br />
There are four fundamental steps in the instruction cycle:


The machine instruction cycle is the process a CPU follows to execute instructions stored in memory. It consists of four main stages: Fetch, Decode, Execute, and Store. Below is a breakdown of the cycle, along with the roles of key components such as the Control Unit (CU), Arithmetic Logic Unit (ALU), and various registers.
The machine instruction cycle is the process a CPU follows to execute instructions stored in memory. It consists of four main stages: Fetch, Decode, Execute, and Store. Below is a breakdown of the cycle, along with the roles of key components such as the Control Unit (CU), Arithmetic Logic Unit (ALU), and various registers.
Line 45: Line 37:
CIR (Current Instruction Register): Stores the current instruction being decoded and executed.
CIR (Current Instruction Register): Stores the current instruction being decoded and executed.
ACC (Accumulator): Holds the result of calculations performed by the ALU.
ACC (Accumulator): Holds the result of calculations performed by the ALU.
IR (Interrupt Register): Manages interrupt requests from I/O devices.


The cycle then repeats, fetching the next instruction from memory as indicated by the Program Counter (PC).
The cycle then repeats, fetching the next instruction from memory as indicated by the Program Counter (PC).


== Excellent simulations of the machine instruction cycle ==  
== Excellent simulations of the machine instruction cycle ==  

Latest revision as of 12:18, 11 September 2024

This is a basic concept in computer science
The machine instruction cycle describes the order that instructions are processed in a computer. 

Fetch-execute-cycle.png


The machine instruction cycle is the process a CPU follows to execute instructions stored in memory. It consists of four main stages: Fetch, Decode, Execute, and Store. Below is a breakdown of the cycle, along with the roles of key components such as the Control Unit (CU), Arithmetic Logic Unit (ALU), and various registers.

1. Fetch[edit]

The Control Unit (CU) initiates the fetch stage by using the Program Counter (PC) to store the address of the next instruction to be executed. This address is sent to the Memory Address Register (MAR), which holds the address of the required instruction in memory.

  • The CU signals the memory to retrieve the instruction at the address in the MAR.
  • The retrieved instruction is temporarily stored in the Memory Data Register (MDR).
  • The instruction is then transferred to the Current Instruction Register (CIR) for decoding.
  • The PC is incremented to point to the address of the next instruction in RAM.

2. Decode[edit]

Once the instruction is in the CIR, the Control Unit (CU) decodes it to determine what operation needs to be performed. The decoded instruction identifies whether data needs to be retrieved, stored, or manipulated.

3. Execute[edit]

The Arithmetic Logic Unit (ALU) performs the necessary calculations or logical operations, depending on the instruction. For example, if the instruction involves an arithmetic operation (addition, subtraction, etc.), the ALU processes the data.

  • Data required for the operation may be fetched from memory or registers.
  • The Accumulator (ACC) stores the result of operations carried out by the ALU, such as the sum of two numbers.

4. Store[edit]

After execution, the result in the ACC may need to be stored back into memory or passed to another register for further operations. If the instruction involves interacting with external devices, the Interrupt Register (IR) may be involved, handling requests from I/O devices to ensure they are serviced when required.

During the entire instruction cycle, the Control Unit (CU) coordinates the movement of data between the registers and manages the flow of control within the CPU.

Registers' Summary[edit]

PC (Program Counter): Stores the address of the next instruction to be fetched. MAR (Memory Address Register): Stores the memory address of the data or instruction to be fetched or stored. MDR (Memory Data Register): Holds the data fetched from or to be written to memory. CIR (Current Instruction Register): Stores the current instruction being decoded and executed. ACC (Accumulator): Holds the result of calculations performed by the ALU.

The cycle then repeats, fetching the next instruction from memory as indicated by the Program Counter (PC).


Excellent simulations of the machine instruction cycle[edit]

  1. It can be helpful to imagine there is a little mailman inside your computer! Click here to learn more about this technique
  2. Click here for a great simulation!
  3. This is also very good simulation (little man simulation)

References[edit]