Group 4_Addressing modes_BBIT2.
2D
Introduction
Addressing modes are the different ways of specifying the location of an operand (the data to be
used) in an instruction. When the CPU executes an instruction, it must know where to find the
operand to perform an operation. Addressing modes provide flexibility in how operands are
accessed, either directly, through registers, memory locations, or by calculation.
Importance of Addressing Modes:
- Makes programming easier by providing different ways of specifying operands.
- Allows efficient use of memory and CPU registers.
- Supports the implementation of different data structures such as arrays, stacks, and parameters.
- Enhances flexibility and reusability of programs.
Immediate Addressing Mode
In immediate addressing, the operand is directly specified in the instruction itself. This makes it
extremely fast since the CPU does not need to access memory to fetch data. However, its limitation
is that the value is fixed at compile-time and cannot be changed during execution.
Example: MOV AX, 5 → This loads the constant value 5 into register AX.
Advantages: Fast execution, no memory access required.
Disadvantages: Limited flexibility, operand cannot be changed dynamically.
Direct Addressing Mode
In this mode, the instruction specifies the actual memory address of the operand. The CPU fetches
the data directly from that memory location. While more flexible than immediate addressing, it is
slower since memory access is required.
Example: MOV AX, [5000H] → This copies the content at memory address 5000H into AX.
Advantages: Simple and clear, easy to use for fixed memory locations.
Disadvantages: Less flexible for dynamic data structures, slower than register operations.
Indirect Addressing Mode
Here, the instruction refers to a register (or memory location) that contains the address of the
operand. This introduces a level of indirection, making it suitable for pointer-based operations and
dynamic data structures.
Example: MOV AX, [BX] → BX contains the address, and the CPU fetches data from that address
into AX.
Advantages: Flexible, supports pointers and linked data structures.
Disadvantages: Requires two memory accesses: one for the address and one for the data.
Register Addressing Mode
The operand is located in a CPU register, making it the fastest addressing mode as no memory
access is required. Commonly used in arithmetic and data transfer between registers.
Example: MOV AX, BX → The contents of register BX are copied into AX.
Advantages: Extremely fast, efficient for temporary data manipulation.
Disadvantages: Limited by the small number of registers available.
Register Indirect Addressing Mode
In this mode, the register contains the effective memory address of the operand rather than the
operand itself. The CPU fetches the operand from the memory location specified by the register.
This mode is useful for traversing arrays.
Example: MOV AX, [SI] → If SI=2000H, operand is fetched from memory at 2000H and stored in
AX.
Advantages: Good for array and string operations, flexible for structured data.
Disadvantages: Requires additional memory access, slower than direct register addressing.
Indexed Addressing Mode
This mode calculates the effective address (EA) by adding the contents of a base register and an
index register. The CPU then uses this EA to fetch the operand. Indexed addressing is especially
useful for arrays, loops, and tables.
Example: MOV AX, [BX+SI] → Operand is located at the address formed by adding BX and SI.
Advantages: Very powerful for structured data and iterative access patterns.
Disadvantages: More complex than simple modes, requires additional calculations.
Base Register Addressing Mode
Here, the effective address is calculated as: Base Register + Displacement. This mode is
particularly common in stack frame management and accessing function parameters.
Example: MOV AX, [BP+4] → Fetches data at the memory location BP+4 into AX.
Advantages: Very useful in high-level language implementation (stack frames).
Disadvantages: Requires extra computation and is slower than direct register access.
Summary
Addressing modes are essential in computer architecture as they define how the CPU locates and
processes data. Each mode has its advantages and disadvantages depending on the use case.
Immediate and register addressing are fastest but limited in flexibility, while direct, indirect, indexed,
and base register modes provide more versatility for handling complex data structures and dynamic
memory management. A solid understanding of addressing modes is key to efficient programming
and system design.