0% found this document useful (0 votes)
4 views

addressing modes

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

addressing modes

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Addressing modes

Addressing modes in computer organiza2on and architecture define


how the operand of an instruc2on is chosen. The operand could be a
constant value, a register, or a memory loca2on. These modes help the
CPU understand where to look for data for processing. Different
addressing modes allow for flexibility, efficiency, and op2miza2on in
execu2ng instruc2ons. Here are the common types of addressing
modes:
---

1. Immediate Addressing Mode

In immediate addressing mode, the operand is directly specified in the instruc7on itself. The
value is explicitly given, and no memory reference is needed to fetch the operand.

- Example: MOV R1, #5

This moves the immediate value `5` directly into register `R1`. The `#` symbol indicates an
immediate value.

- Use Case: Useful for small constant values.

2. Register Addressing Mode

In register addressing mode, the operand is stored in a register, and the instruc7on directly
specifies the register.
Example: MOV AX,CX (move the contents of CX register to AX register)

This moves the contents of register `CX` into register `AX`. Both operands are registers.

- Use Case: Fastest addressing mode, as it doesn't require memory access.

3. Direct Addressing Mode (Absolute Addressing)

In direct addressing mode, the memory address of the operand is specified explicitly in the
instruc7on. The CPU directly accesses the memory loca7on to fetch the data.

- Example: MOV R1, 5000

Here, `5000` is the memory address, and the contents of this address are moved to register
`R1`.

- Use Case: Simple and easy to understand but limited by the size of the address field.

4. Indirect Addressing Mode

In indirect addressing mode, the memory address of the operand is not given directly in the
instrucMon but is stored in a register. The instruc7on specifies the register or memory loca7on
that holds the address.

- Example: MOV R1, (R2)

The contents of the memory loca7on whose address is stored in register `R2` are moved to
`R1`. `(R2)` indicates indirect addressing.

- Use Case: Useful for accessing arrays or dynamic data structures.

5. Register Indirect Addressing Mode

In register indirect addressing mode, the register contains the memory address where the
operand is located. The instruc7on refers to this register, and the CPU accesses the operand
by dereferencing the register's contents.
- Example: MOV R1, [R2]

The contents of the memory loca7on pointed to by register `R2` are moved into register `R1`.

- Use Case: Efficient for accessing data stored in memory through pointers.

6. Indexed Addressing Mode

In indexed addressing mode, the effecMve address of the operand is generated by adding a
constant (offset) to the contents of a register (index register). The constant may be specified
in the instruc7on.

- Example: MOV R1, 100(R2)

The effec7ve address is computed as the sum of `100` (the offset) and the value in register
`R2`. The data at this computed memory address is moved to `R1`.

- Use Case: Commonly used for accessing elements in an array.

7. Base Register Addressing Mode

Similar to indexed addressing, but instead of adding an offset to an index register, the offset
is added to a base register. The base register contains a star7ng memory address.

- Example: MOV R1, (Base Register) + Offset

The memory address is calculated by adding the contents of the base register and the offset.
The data at that memory loca7on is moved to `R1`.

- Use Case: Efficient for working with structures or large data blocks.

8. RelaMve Addressing Mode

In rela7ve addressing mode, the effecMve address is determined by adding an offset to the
current value of the program counter (PC).

- Example: JMP 100

This jumps to the address computed by adding `100` to the current PC value.
- Use Case: Used in branch or jump instruc7ons, making it useful for loops or condi7onal
statements.

9. Implicit Addressing Mode

In implicit addressing mode, the operand is implied or implicitly understood based on the
operaMon. The instruc7on doesn’t need to specify an operand as it is inherent to the
instruc7on.

- Example: CLC ; Clear the Carry Flag

No operands are specified since the instruc7on implies that the carry flag will be cleared.

- Use Case: Frequently used in instruc7ons that manipulate CPU flags or registers directly.

10. Auto Increment / Auto Decrement Addressing Mode

In this addressing mode, the register’s value is either incremented or decremented


automa7cally aeer accessing the operand. It’s useful for traversing arrays or lists.

- Auto Increment Example: MOV R1, (R2)+

This moves the value at the address in `R2` to `R1`, and then `R2` is incremented.

- Auto Decrement Example: MOV R1, -(R2)

Here, `R2` is decremented first, and then the value at the new address is moved to `R1`.

- Use Case: Suitable for stack opera7ons or traversing arrays.

Conclusion:

Addressing modes are cri7cal to computer architecture because they define how data is
accessed and manipulated. By understanding different addressing modes, we can write
more efficient assembly code and befer understand how processors execute high-level
programming instruc7ons at the hardware level.

You might also like