addressing modes
addressing modes
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.
This moves the immediate value `5` directly into register `R1`. The `#` symbol indicates an
immediate value.
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.
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.
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.
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.
The contents of the memory loca7on whose address is stored in register `R2` are moved to
`R1`. `(R2)` indicates indirect addressing.
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.
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.
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`.
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.
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.
In rela7ve addressing mode, the effecMve address is determined by adding an offset to the
current value of the program counter (PC).
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.
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.
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.
This moves the value at the address in `R2` to `R1`, and then `R2` is incremented.
Here, `R2` is decremented first, and then the value at the new address is moved to `R1`.
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.