ScholarQuill logoScholarQuillUniversity Notes
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
Study Tools
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
Contact
ScholarQuill logo
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
ScholarQuill logoScholarQuillUniversity Notes
Study PortalCOMP3137Instruction Execution …
Ctrl + K
Login
Explore
Search
Semester
Papers
CGPA
    COMP3137

    Computer Organization and Assembly Language

    Progress0 / 73 done
    Topics73
    1Introduction to Computer Organization2Assembly Language3Comparison of Low-Level and High-Level Languages
    4General Purpose and Special Purpose Registers5Introduction and Usage of RAM6Processor7Registers8System Bus9Instruction Execution Cycle10Assembly and Machine Language11Assembler12Linker and Link Libraries13Programmer's View of a Computer System14RISC and CISC Architecture15Physical Address Calculation16Basic Memory Organization17CPU Organization18Top Level View of Computer Function and Interconnection19Assembler Instruction Cycle20Execute Cycle21Interrupts22Interrupt Cycle23Memory Connection24Input/Output Connection25CPU Connection26MASM27MIPS28Defining Data in MASM Assembler29Elements of Assembly Language30Integer Constants31Integer Expressions32Real Number Constants33Character Constants34String Constants35Reserved Words36Identifiers37Directives38Instructions39The NOP (No Operation) Instruction40Adding and Subtracting Integer41INC and DEC Instructions42NEG Instruction43How to Move Integer Number in Register44Adding and Subtracting Numbers in Registers45Declaration and Initialization of Variables46Moving Data from Variable to Register47Data Definition Statement48BYTE and SBYTE Data49WORD and SWORD Data50Defining DWORD and SDWORD Data51Knowledge about Different Data Types52Operations, Array & Loops53Division and Multiplication in Assembly54Jumps Based on Specific Flags55Jumps Based on Equality56Simple Jump Statements57Jumps Based on Specific Condition58Code Examples59Practice on MASM60Procedures61File Operations Procedures62Labels in Procedures63Stack64Runtime Stack65Conditional Control Flow Directives66Compound Expressions67Data Representation & Conversion68Architecture69Data Path70Control Unit71Critical Path72General Principles of Pipelining73Pipelined Y86 Implementations
    7 min read
    Topic 9 of 73
    Topic Study Note Illustration
    09

    Instruction Execution Cycle

    The Instruction Execution Cycle (also called the Machine Cycle ) is the sequence of steps that the CPU follows to execute a single instruction in a program....

    Instruction Execution Cycle

    The Instruction Execution Cycle (also called the Machine Cycle) is the sequence of steps that the CPU follows to execute a single instruction in a program. This cycle is fundamental to how a CPU processes instructions and is essential for understanding how a computer runs software.

    The cycle typically consists of multiple phases, each of which corresponds to a specific task needed to fetch, decode, and execute an instruction. This process is repeated for each instruction in a program until the program finishes executing.

    The cycle can be broken down into the following main stages:

    1. Fetch: Retrieve the instruction from memory.
    2. Decode: Interpret the instruction to determine what action to take.
    3. Execute: Perform the operation specified by the instruction.
    4. Store: Optionally, store the result of the operation back into memory or a register.

    Let’s go through each step in more detail:


    1. Fetch

    The fetch phase is the first step in the instruction cycle, where the CPU retrieves the next instruction to be executed from memory (usually RAM).

    Steps in the Fetch Phase:

    • The Program Counter (PC), which holds the address of the next instruction, is used to find the instruction in memory.
    • The CPU sends the address from the Program Counter (PC) to the Memory Address Register (MAR) via the address bus.
    • The memory then sends the instruction located at that address back to the CPU over the data bus.
    • The instruction is placed into the Instruction Register (IR), which holds the instruction to be decoded and executed.
    • After the instruction is fetched, the Program Counter (PC) is updated to point to the next instruction, usually by incrementing the address by the size of the instruction (often 4 bytes for modern architectures).

    Key Components Involved:

    • Program Counter (PC)
    • Memory Address Register (MAR)
    • Data Bus
    • Instruction Register (IR)

    Example:

    • Suppose the PC holds the address 0x2000. The CPU fetches the instruction from memory at address 0x2000, places it into the IR, and increments the PC to 0x2004 (assuming each instruction is 4 bytes long).

    2. Decode

    Once the instruction has been fetched, it must be decoded to determine what the CPU needs to do. During the decode phase, the instruction is analyzed, and the Control Unit (CU) generates the appropriate control signals to carry out the operation specified by the instruction.

    Steps in the Decode Phase:

    • The Instruction Register (IR) holds the fetched instruction, which is typically in machine language (binary).
    • The Control Unit (CU) decodes the instruction by breaking it into its components:
      • The opcode (operation code), which specifies what kind of operation the CPU should perform (e.g., addition, subtraction, load data).
      • The operands, which specify the data or memory locations to be used in the operation.
    • The Control Unit (CU) generates control signals that direct other parts of the CPU to carry out the operation. These control signals can indicate whether to perform an arithmetic operation, access memory, or interact with I/O devices.

    Key Components Involved:

    • Instruction Register (IR)
    • Control Unit (CU)
    • Decoder Logic

    Example:

    • If the instruction is ADD R1, R2, R3, the CU decodes it to:
      • Opcode: ADD (perform an addition)
      • Operands: R1, R2, and R3 (registers where data will be taken from and stored in).

    3. Execute

    The execute phase is where the actual operation specified by the instruction is carried out. Depending on the instruction, this could involve arithmetic or logical operations, memory access, or I/O interactions.

    Steps in the Execute Phase:

    • If the instruction involves an arithmetic or logical operation, the Arithmetic and Logic Unit (ALU) performs the operation.
      • Example: If the instruction is ADD, the ALU will add the values in the specified registers (e.g., R2 and R3), and store the result in R1.
    • If the instruction involves memory access, the CPU either loads data from memory into a register or stores data from a register into memory.
      • Example: If the instruction is MOV R1, 0x1000, the CPU will load data from memory address 0x1000 into R1.
    • If the instruction involves an I/O operation, the CPU communicates with I/O devices to send or receive data.

    Key Components Involved:

    • Arithmetic and Logic Unit (ALU)
    • Registers (e.g., R1, R2, R3)
    • Memory (for load/store operations)

    Example:

    • For the instruction ADD R1, R2, R3, the ALU adds the contents of R2 and R3, and the result is stored in R1.

    4. Store (Optional)

    In the store phase, the result of the execution is either written back to a register or written to memory, depending on the instruction. Not all instructions require a store phase, but many will.

    Steps in the Store Phase:

    • If the instruction modifies a register (like ADD or SUB), the result is placed into the appropriate general-purpose register.
    • If the instruction is a memory store (e.g., STORE), the CPU writes the data to a specific memory address.
    • If the instruction involves an I/O operation, the result may be sent to or received from an I/O device.

    Key Components Involved:

    • Registers
    • Memory (if data needs to be stored)
    • I/O Devices (if involved)

    Example:

    • After executing ADD R1, R2, R3, the result is stored in R1.

    Summary of the Instruction Execution Cycle

    The Instruction Execution Cycle (or Fetch-Decode-Execute Cycle) is a repetitive process that the CPU follows to execute each instruction in a program. Here’s a simplified overview of the cycle:

    1. Fetch: The CPU fetches the instruction from memory using the Program Counter (PC).
    2. Decode: The instruction is decoded to determine the operation and operands, and the appropriate control signals are generated by the Control Unit (CU).
    3. Execute: The CPU executes the operation, which could involve arithmetic, memory access, or I/O operations. The ALU may be used for calculations, and memory or I/O devices may be accessed.
    4. Store: If needed, the result is stored in a register or written back to memory.

    Each step is crucial for the CPU to perform the correct task and move to the next instruction, ensuring that the computer executes programs as expected.


    Instruction Cycle in Modern Processors

    Modern processors often have features like pipelines and superscalar execution that improve the efficiency of the instruction cycle:

    • Pipelining: In a pipeline, different stages of multiple instructions are processed simultaneously. While one instruction is being decoded, another may be fetched, and another may be executed. This increases throughput and reduces overall execution time.
    • Superscalar Execution: Some CPUs can execute multiple instructions at once, utilizing more than one ALU or core to handle different instructions concurrently, further improving performance.

    Despite these optimizations, the basic steps of the instruction execution cycle (fetch, decode, execute, store) remain fundamental to how a processor works.

    ← Previous topic 8
    System Bus
    Next topic 10 →
    Assembly and Machine Language

    Past Papers

    Open this section to view and download past papers

    Click on Show Past Papers to load available exam papers.

    Reading Progress
    0%
    7mremaining
    1.1kwords
    Intermediatelevel
    On This Page

    No headings found

    Study Toolkit

    Subject Portal

    Computer Organization and Assembly Language