ScholarQuill logoScholarQuillUniversity Notes
  • Notes
  • Past Papers
  • Blogs
  • Todo
Login
ScholarQuill logoScholarQuillUniversity Notes
Login
NotesPast PapersBlogsTodo
More
SubjectsDiscussionCGPA CalculatorGPA CalculatorStudent PortalCourse Outline
About
About usPrivacy PolicyReportContact
Notes
Past Papers
Blogs
Todo
Analytics
    Current Subject
    🧩
    Computer Organization and Assembly Language
    COMP3137
    Progress0 / 73 topics
    Topics
    1. Introduction to Computer Organization2. Assembly Language3. Comparison of Low-Level and High-Level Languages4. Register Types (16-bit): General Purpose and Special Purpose Registers5. Introduction and Usage of RAM6. Processor7. Registers8. System Bus9. Instruction Execution Cycle10. Assembly and Machine Language11. Assembler12. Linker and Link Libraries13. Programmer's View of a Computer System14. RISC and CISC Architecture15. Physical Address Calculation16. Basic Memory Organization17. CPU Organization18. Top Level View of Computer Function and Interconnection19. Assembler Instruction Cycle20. Execute Cycle21. Interrupts22. Interrupt Cycle23. Memory Connection24. Input/Output Connection25. CPU Connection26. MASM27. MIPS28. Defining Data in MASM Assembler29. Elements of Assembly Language30. Integer Constants31. Integer Expressions32. Real Number Constants33. Character Constants34. String Constants35. Reserved Words36. Identifiers37. Directives38. Instructions39. The NOP (No Operation) Instruction40. Adding and Subtracting Integer41. INC and DEC Instructions42. NEG Instruction43. How to Move Integer Number in Register44. Adding and Subtracting Numbers in Registers45. Declaration and Initialization of Variables46. Moving Data from Variable to Register47. Data Definition Statement48. BYTE and SBYTE Data49. WORD and SWORD Data50. Defining DWORD and SDWORD Data51. Knowledge about Different Data Types52. Operations, Array & Loops53. Division and Multiplication in Assembly54. Jumps Based on Specific Flags55. Jumps Based on Equality56. Simple Jump Statements57. Jumps Based on Specific Condition58. Code Examples59. Practice on MASM60. Procedures61. File Operations Procedures62. Labels in Procedures63. Stack64. Runtime Stack65. Conditional Control Flow Directives66. Compound Expressions67. Data Representation & Conversion68. Architecture69. Data Path70. Control Unit71. Critical Path72. General Principles of Pipelining73. Pipelined Y86 Implementations
    COMP3137›Execute Cycle
    Computer Organization and Assembly LanguageTopic 20 of 73

    Execute Cycle

    7 minread
    1,194words
    Intermediatelevel

    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)

    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 load past papers

    Click on Show Past Papers to see past papers.
    On This Page
      Reading Stats
      Est. reading time7 min
      Word count1,194
      Code examples0
      DifficultyIntermediate