Addressing Modes

Introduction

The term addressing mode refers to the method used to specify the operand(s) of an instruction. An addressing mode defines a rule for interpreting or modifying the address field of an instruction before the operand is accessed or used. Proper use of addressing modes is key to efficient assembly-language programming because they determine how the processor locates data in registers or memory.

Instruction format and operand components

An assembly-language instruction normally consists of two parts:

OpcodeOperand

In processors such as the 8086, the memory address of an operand (the effective address) is formed from a combination of components. The principal address components are:

Important terms

  • Starting address (segment base) - the base address of a memory segment.
  • Effective address (offset) - the 16-bit address used to access memory within a segment. The offset may be formed by adding any combination of the following address elements: displacement, base and index.
  • Displacement - an immediate value included in the instruction; it may be 8-bit or 16-bit.
  • Base - the contents of a base register, typically BX or BP in 8086.
  • Index - the contents of an index register, typically SI or DI in 8086.

Overview of addressing-mode categories for 8086

Addressing modes for 8086 instructions are commonly grouped into two categories:

  • Addressing modes for data (how the operand is located or specified)
  • Addressing modes for branch/control transfer (how the target address is calculated)

The following sections describe the common data addressing modes used by the 8086 microprocessor, their meanings, typical uses and examples.

Data addressing modes (8086)

  • Implied mode: The operand is implicit in the opcode and is not specified in the instruction fields. The data (if any) is part of the instruction encoding rather than an explicit operand field. Zero-address instruction formats and certain flag operations use implied addressing.

    Example: CLC - clear the Carry flag (no explicit operand).

  • Immediate addressing mode: The operand value is encoded directly in the instruction's operand field. Immediate mode provides the quickest way to supply constants to a register or memory location.

    Note: the range of constants is limited by the size of the instruction's immediate field (for example, 8-bit or 16-bit).

    Example: MOV AL, 35H - move the immediate value 35H into register AL.

  • Register addressing mode: The operand is located in a general-purpose register specified by the instruction. Access requires a register reference only.

    Example: MOV AX, CX - copy the contents of CX to AX.

  • Register indirect addressing mode: The instruction specifies a register (such as BX, BP, SI, DI), and the contents of that register are used as the offset (effective address) into memory. This allows memory access via a register pointer.

    Example: MOV AX, [BX] - move the word at memory location whose offset is in BX into AX.

  • Auto-indexed (post-increment) addressing mode: The effective address is the contents of a register. After accessing the operand, the register is automatically incremented to point to the next element. This mode is useful for stepping through arrays or buffers.

    Semantic example (pseudo-syntax): R1 = R1 + M[R2]; R2 = R2 + d

    Here one register reference, one memory reference and one ALU operation are required. Typical notation: (R2)+.

  • Auto-indexed (pre-decrement) addressing mode: Before accessing the operand, the register specified is decremented; the decremented value is used as the effective address. This mode is useful for stack operations (LIFO) and for stepping backwards through arrays.

    Semantic example (pseudo-syntax): R2 = R2 - d; R1 = R1 + M[R2]

    Auto decrement and auto increment modes are commonly used to implement push/pop and to traverse data structures.

  • Direct (absolute) addressing mode: The instruction contains the full offset (8-bit or 16-bit displacement) of the memory operand. The effective address is provided explicitly in the instruction.

    Example: ADD AL, [0301] - add the byte at offset 0301 to AL.

  • Indirect addressing mode: The address field of the instruction contains an address that points to the effective address; two memory references may be required. Indirect mode has two forms:

    Memory indirect: the instruction field gives a memory location whose contents are the effective address; two memory references are required.

    Register indirect: the instruction field names a register holding the effective address; one register reference and one memory reference are required.

  • Indexed addressing mode: The effective address is the sum of an index register (SI or DI) and a displacement (8-bit or 16-bit). This mode is particularly useful for array access with a fixed base or with the segment base implicit.

    Example: MOV AX, [SI + 05].

  • Based-indexed addressing mode: The effective address is the sum of a base register (BX or BP) and an index register (SI or DI), optionally plus a displacement. This mode supports access to complex data structures such as records and two-dimensional arrays.

    Example: ADD AX, [BX + SI].

Instruction
Instruction
Data addressing modes (8086)
Data addressing modes (8086)
Data addressing modes (8086)
Data addressing modes (8086)

Addressing modes used for control transfer (branch/transfer of control)

Addressing modes for control transfer determine how the target address of a branch or call is calculated. Two common forms are:

  • PC-relative addressing mode: The effective address (target) is obtained by adding a displacement (the address field) to the program counter (PC). This is typically used for intra-segment jumps and branches.

    EA = PC + (address field value)

    On execution, PC is updated relative to the branch displacement: PC = PC + relative value.

  • Base-register addressing mode: The effective address is obtained by adding a base register's contents to an address field. Base-register addressing can be used for inter-segment or position-independent code, where the base register holds a relocation offset.

    EA = Base register + (address field value)

    PC = Base register + relative value (for control transfer using base register).

    Note: Both PC-relative and base-register addressing are useful for program relocation at run time. Base-register addressing is particularly suitable for position-independent code.

Advantages of different addressing modes

  1. They provide facilities such as pointers, counters for loop control, indexing of data structures (arrays, records) and program relocation.
  2. They reduce the number of bits required in the instruction's addressing field by allowing addresses to be formed at run time from registers and displacements.

Practical uses and examples

Addressing modes make it easier to implement common programming constructs in assembly language:

  • Pointers and indirect addressing implement dynamic data structures and references (for example, linked lists).
  • Indexed and based-indexed modes implement array access and structured records efficiently.
  • Auto increment/decrement modes are useful for implementing stacks, push/pop operations and iterating through arrays with minimal instruction overhead.
  • Immediate addressing supplies constants directly into registers for arithmetic and control operations.

Sample Question

Match each of the high level language statements given on the left hand side with the most natural addressing mode from those listed on the right hand side.
1. A[1] = B[J];     a. Indirect addressing

2. while [*A++];     b. Indexed addressing

3. int temp = *x;     c. Autoincrement

(a) (1, c), (2, b), (3, a)

(b) (1, a), (2, c), (3, b)

(c) (1, b), (2, c), (3, a)

(d) (1, a), (2, b), (3, c)
Ans. c
Solution:
Sample QuestionHence (C) is correct solution.

Summary

Addressing modes define how instruction operands are specified and located. Understanding addressing modes-immediate, register, direct, indirect, indexed, based indexed, and auto-increment/decrement-lets programmers and compilers generate compact, efficient code that manipulates arrays, pointers, records and control transfers with minimal instruction overhead. The 8086 family provides a flexible set of addressing modes that support these programming patterns and make program relocation and position-independent code practical.

The document Addressing Modes is a part of the Computer Science Engineering (CSE) Course Computer Architecture & Organisation (CAO).
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)

FAQs on Addressing Modes

1. What are addressing modes in computer science engineering?
Ans. Addressing modes in computer science engineering refer to the techniques used by a computer processor to access data from memory or registers. These modes specify how the operands or data are located and accessed during the execution of instructions.
2. How many types of addressing modes are there?
Ans. There are several types of addressing modes in computer science engineering. Some commonly used addressing modes include immediate addressing mode, direct addressing mode, indirect addressing mode, indexed addressing mode, and register addressing mode.
3. What is immediate addressing mode?
Ans. Immediate addressing mode is a type of addressing mode where the operand is directly specified within the instruction itself. In this mode, the data or operand is not stored in memory or registers but is directly provided as a part of the instruction. It is typically used for constants or immediate values.
4. How does direct addressing mode work?
Ans. Direct addressing mode is a type of addressing mode where the address of the operand is directly specified in the instruction. In this mode, the data or operand is stored in a memory location, and the instruction directly references that memory location to access the data.
5. What is the purpose of indexed addressing mode?
Ans. Indexed addressing mode is a type of addressing mode where the effective address of the operand is calculated by adding an offset or index value to a base address. This mode allows for efficient access to arrays or data structures by utilizing a base address and an offset value to locate the desired data.
Explore Courses for Computer Science Engineering (CSE) exam
Get EduRev Notes directly in your Google search
Related Searches
ppt, Free, Important questions, Viva Questions, shortcuts and tricks, practice quizzes, mock tests for examination, past year papers, Previous Year Questions with Solutions, MCQs, Addressing Modes, video lectures, Addressing Modes, Objective type Questions, study material, Summary, Addressing Modes, Exam, Extra Questions, pdf , Semester Notes, Sample Paper;