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 PortalCOMP3137Execute Cycle
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 20 of 73
    Topic Study Note Illustration
    20

    Execute Cycle

    The execute cycle is a critical phase of the instruction cycle in which the CPU performs the actual operations specified by the instruction. Once an instruction is...

    Execute Cycle

    The execute cycle is a critical phase of the instruction cycle in which the CPU performs the actual operations specified by the instruction. Once an instruction is fetched from memory and decoded, the execute cycle is responsible for performing the action—whether it's a mathematical computation, data movement, or control transfer.

    In essence, the execute cycle is where the CPU does the "work" based on the instruction it has decoded.


    Overview of the Execute Cycle

    The execute cycle can vary in its complexity depending on the type of instruction. There are different types of instructions like arithmetic operations, logical operations, data transfer, branching, and I/O operations, and each type of instruction requires a specific set of actions during the execute cycle.

    Generally, the execute cycle involves:

    1. Performing Arithmetic or Logical Operations (e.g., addition, subtraction, logical AND/OR).
    2. Memory Access (e.g., reading or writing data to/from memory).
    3. Control Operations (e.g., modifying the program flow with jumps or branches).
    4. I/O Operations (e.g., reading from or writing to input/output devices).

    The CPU uses its various internal components (like the ALU, registers, control unit, and bus system) to carry out the necessary tasks in the execute cycle.


    Step-by-Step Breakdown of the Execute Cycle

    1. ALU Operations (Arithmetic and Logic Operations)

    Arithmetic logic unit
    Visual ReferenceArithmetic Logic Unit
    Wikipedia

    One of the most common tasks during the execute cycle is performing arithmetic and logical operations. The Arithmetic Logic Unit (ALU) is responsible for these operations. These can include:

    • Arithmetic operations:
      • Addition, subtraction, multiplication, and division.
    • Logical operations:
      • AND, OR, NOT, XOR (exclusive OR), etc.
    • Comparison operations:
      • For conditional branching (e.g., checking if two values are equal or if one is greater than the other).

    Example:
    For an instruction like ADD R1, R2, R3 (which means "Add the contents of registers R2 and R3 and store the result in R1"), the ALU would:

    • Take the values in R2 and R3.
    • Perform the addition.
    • Store the result in R1.

    2. Memory Operations (Read/Write from/to Memory)

    Some instructions involve reading data from or writing data to memory. The Memory Management Unit (MMU) and memory bus manage this interaction.

    • Load: Reading data from memory into a register.
    • Store: Writing data from a register to memory.

    Example:
    For an instruction like MOV R1, [1000] (move data from memory address 1000 to register R1), the CPU would:

    • Access memory location 1000.
    • Read the data stored there.
    • Load the data into register R1.

    In this case, memory access can involve a single cycle or multiple cycles depending on whether the memory is fast (cache) or slow (main RAM).

    3. Control Operations (Branching and Jumping)

    Control operations alter the flow of the program. The Control Unit (CU) will evaluate the condition specified in the instruction and update the Program Counter (PC) if necessary.

    • Conditional Branch: If an instruction specifies a conditional jump (e.g., BEQ for "branch if equal"), the CPU checks a condition (like whether two registers are equal) and, based on the result, updates the PC to jump to a new instruction address.
    • Unconditional Branch: A jump that happens no matter what, for example, to repeat a loop or skip over code.

    Example:
    For an instruction like BEQ R1, R2, 10 (branch if R1 equals R2, jump 10 instructions ahead), the CPU would:

    • Compare the values in R1 and R2.
    • If they are equal, the PC is updated to the new address, which is 10 instructions ahead.

    4. I/O Operations (Input/Output)

    Some instructions involve interacting with input/output (I/O) devices. The I/O controller and associated buses handle these operations. These operations may involve:

    • Reading input data from a keyboard, mouse, or file.
    • Sending output data to a display, printer, or network.

    Example:
    For an instruction like IN R1, 0xFF (input from port 0xFF into register R1), the CPU would:

    • Communicate with the I/O controller.
    • Transfer data from the specified I/O port (e.g., a keyboard input or data from a sensor) into R1.

    I/O operations may involve a significant amount of time compared to other operations since I/O devices are typically slower than CPU and memory.


    Key Components Involved in the Execute Cycle

    Several key components inside the CPU and system architecture participate in the execute cycle:

    1. ALU (Arithmetic Logic Unit):

      • Performs arithmetic and logical operations on data.
    2. Control Unit (CU):

      • Decodes the instruction, generates control signals, and orchestrates the operation by coordinating with the ALU, memory, and I/O devices.
    3. Registers:

      • Temporary storage locations in the CPU where data is held during execution. Examples include General-Purpose Registers (GPRs), Status Registers, and Program Counter (PC).
    4. Memory:

      • Stores data and instructions. RAM is typically used for active data, while secondary memory (HDD/SSD) holds long-term data.
    5. Program Counter (PC):

      • Keeps track of the address of the next instruction to be executed. It is often updated during the execute cycle if the instruction involves a branch or jump.
    6. Bus System:

      • The data bus transfers data between components (CPU, memory, I/O devices), while the address bus specifies memory locations or I/O addresses.

    Example of the Execute Cycle

    Let's break down a simple instruction like ADD R1, R2, R3 (add the values of registers R2 and R3 and store the result in R1) to see the steps involved in the execute cycle:

    1. Fetch: The instruction ADD R1, R2, R3 is fetched from memory.
    2. Decode: The Control Unit (CU) decodes the instruction and identifies that an addition operation is required. It determines that it needs to:
      • Read the values in R2 and R3.
      • Perform the addition.
      • Store the result in R1.
    3. Execute: The ALU adds the values in R2 and R3. If the instruction involved a memory operation, the result would be written to memory. But in this case, the result is written back to R1.
    4. Write Back: The result of the addition is written to R1, completing the execution of the instruction.

    Types of Execute Operations

    Depending on the type of instruction, the execution phase can be different:

    • Arithmetic Operations (e.g., ADD, SUB, MUL):

      • Involve the ALU performing calculations.
    • Logical Operations (e.g., AND, OR, XOR):

      • The ALU performs bitwise logical operations.
    • Data Transfer (e.g., MOV, LOAD, STORE):

      • Data is transferred between registers or between registers and memory.
    • Control Flow (e.g., JMP, BEQ, BNE):

      • The Control Unit updates the Program Counter (PC) to jump to a different memory address.

    Summary of the Execute Cycle

    The execute cycle is a crucial phase in the CPU’s instruction cycle, where the CPU performs the operation specified by the instruction. The main steps involved in the execute cycle are:

    1. Performing Arithmetic or Logical Operations using the ALU.
    2. Memory Operations such as reading from or writing to memory.
    3. Control Operations, including updating the Program Counter (PC) for jumps or branches.
    4. I/O Operations for interacting with external devices.

    Each instruction’s execution might involve different steps, depending on whether it’s performing arithmetic, manipulating data, jumping to another part of the program, or interacting with I/O devices. The execute cycle allows the CPU to process each instruction and move closer to completing a program's task.

    ← Previous topic 19
    Assembler Instruction Cycle
    Next topic 21 →
    Interrupts

    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.2kwords
    Intermediatelevel
    On This Page

    No headings found

    Study Toolkit

    Subject Portal

    Computer Organization and Assembly Language