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 Architecture
    COMP3147
    Progress0 / 24 topics
    Topics
    1. Digital Hardware Design: Transistors and Digital logic2. Hardware description languages (Verilog)3. Instruction Set Architecture: Instruction types and mixes4. Addressing modes5. RISC vs. CISC architectures6. Exceptions in instruction sets7. Scalar Pipelines: Data dependencies8. Static scheduling9. Pipeline performance analysis10. VLIW Pipelines: Local scheduling11. Loop unrolling and Software pipelining12. Trace scheduling13. Deferred exceptions and Predicated execution14. IA64 architecture15. Dynamic Pipelines: Dynamical scheduling16. Register renaming17. Speculative execution18. Trace cache19. Thread-Level Parallelism: Cache coherency20. Sequential consistency21. Multithreading22. Symmetric multiprocessing23. Transactional memory24. Data-Level Parallelism: GPU programming
    COMP3147›Addressing modes
    Computer ArchitectureTopic 4 of 24

    Addressing modes

    4 minread
    628words
    Beginnerlevel

    ⭐ Addressing Modes

    Definition

    Addressing modes are the different ways in which a CPU identifies the location of operands (data) required for an instruction.

    An operand may be located:

    • Inside a register
    • In memory
    • Within the instruction itself
    • Relative to another address

    Addressing modes give flexibility to the programmer and allow the instruction set to express a wide variety of operations.


    ⭐ Why Addressing Modes Are Important?

    • Provide efficient ways to access data
    • Reduce the number of instructions needed
    • Support complex data structures like arrays, pointers, and stacks
    • Improve compiler efficiency
    • Make instructions more flexible

    ⭐ Common Addressing Modes

    Below are the most widely used addressing modes across architectures like MIPS, ARM, x86, RISC-V etc.


    1. Immediate Addressing Mode

    Definition

    The operand is directly specified inside the instruction.

    Example:

    ADD R1, R2, #5     ; R1 = R2 + 5
    

    Usage:

    • Constants
    • Small immediate values
    • Fast execution (no memory read)

    2. Register Addressing Mode

    Definition

    The operand is located in a register.

    Example:

    ADD R1, R2, R3     ; R1 = R2 + R3
    

    Usage:

    • Fastest access
    • Used heavily in RISC architectures

    3. Direct (Absolute) Addressing Mode

    Definition

    The instruction directly contains the memory address of the operand.

    Example:

    LOAD R1, 5000     ; R1 = Mem[5000]
    

    Usage:

    • Accessing static variables
    • Simple but not flexible

    4. Indirect Addressing Mode

    Definition

    The instruction specifies a register (or memory location) that contains the address of the operand.

    Example:

    LOAD R1, (R2)     ; R1 = Mem[ R2 ]
    

    If R2 = 3000, it loads from Mem[3000].

    Usage:

    • Pointers
    • Dynamic data structures

    5. Indexed Addressing Mode

    Definition

    The effective address is calculated by:

    Base Address + Index Register
    

    Example:

    LOAD R1, 200(R2)   ; R1 = Mem[200 + R2]
    

    Usage:

    • Arrays
    • Table lookups

    6. Base + Offset Addressing Mode

    Definition

    A constant offset is added to a base register.

    Example:

    LOAD R1, 4(R3)    ; R1 = Mem[R3 + 4]
    

    Usage:

    • Accessing structure fields
    • Stack frames

    (Indexed and Base+Offset are very similar; RISC uses Base+Offset most.)


    7. Relative (PC-Relative) Addressing Mode

    Definition

    The effective address is calculated relative to the Program Counter (PC).

    Example:

    BEQ R1, R2, LABEL    ; Jump to PC + offset
    

    Usage:

    • Branch instructions
    • Position-independent code
    • Short jumps

    8. Auto-Increment and Auto-Decrement Addressing

    Definition

    Address used for operand is taken from a register, and the register is automatically incremented or decremented.

    Auto-increment Example:

    LOAD R1, (R2)+     ; R1 = Mem[R2], then R2 = R2 + 1
    

    Auto-decrement Example:

    PUSH (–R2)         ; R2 = R2 – 1, then Mem[R2] = value
    

    Usage:

    • Stack operations
    • Iterating through arrays
    • Used in older architectures (e.g., PDP-11)

    9. Displacement Addressing Mode

    Definition

    Operand address = register + constant displacement

    Basically the same as base + offset, but used generally for:

    • Stack frames
    • Local variables
    • Function parameters

    Example:

    LOAD R1, 8(RBP)    ; Load local variable at offset 8
    

    10. Memory Indirect Addressing Mode

    Definition

    The instruction first accesses memory to get an address, then uses that address to get the operand.

    Example:

    LOAD R1, @(5000)      ; R1 = Mem[ Mem[5000] ]
    

    Usage:

    • Pointer to pointer
    • Linked structures

    ⭐ Summary Table (Exam-Friendly)

    Addressing Mode Operand Location Example Usage
    Immediate In instruction ADD R1, #5 Constants
    Register Register ADD R1, R2 Fast ops
    Direct Memory address in instruction LOAD R1, 5000 Simple access
    Indirect Register holds address LOAD R1, (R2) Pointers
    Indexed Base + index LOAD R1, 100(R3) Arrays
    Base + Offset Register + offset LOAD R1, 4(R2) Structures, stack
    PC-relative PC + offset BEQ label Branching
    Auto-inc/dec Reg used then updated LOAD R1, (R2)+ Stacks
    Memory Indirect Mem contains address LOAD R1, @(A) Pointer chains

    ⭐ Why Addressing Modes Matter in ISA Design

    • Support for high-level language constructs
    • Improves CPU flexibility
    • Reduces code size
    • Enables efficient array, stack, and structure access
    • Helps optimize instruction execution
    Previous topic 3
    Instruction Set Architecture: Instruction types and mixes
    Next topic 5
    RISC vs. CISC architectures

    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 time4 min
      Word count628
      Code examples0
      DifficultyBeginner