You are on page 1of 6

Assembly language

Addressing modes
Addressing modes define how processors access data.
Purpose: Essential for efficient data manipulation.
Immediate Addressing

Immediate addressing is an
addressing mode in assembly 1. Constants: Immediate
language where the operand is a addressing is used when you
constant value or an immediate want to load a constant value
into a register. For instance,
data. The data is provided as a initializing variables or setting
part of the instruction itself, and up constants for calculations.
it's not fetched from memory or 2. Control Flow: Immediate values
a register. can be used in control flow
instructions. For example,
specifying the target address of a
branch or jump instruction.
Register addressing
Common Use Cases:
• Register addressing is an addressing mode in Arithmetic and Logical Operations:
assembly language where operations are Register addressing is commonly used
for arithmetic operations, logical
performed directly on registers. In this mode, one operations, and data manipulation
where data is already in registers.
or more registers are specified as the operands for Data Transfer: It's used for moving data
between registers or from memory to
an instruction, and the operation is executed on registers and vice versa.

these registers.
Most commonly used addressing types
• Direct Addressing: Direct addressing is commonly used when specific
memory locations need to be accessed by specifying their addresses explicitly.
It's essential for reading from and writing to specific memory locations.
• Indirect Addressing: Indirect addressing is valuable when you want to access
data indirectly through a register or memory location. It allows for dynamic
addressing, making it useful for tasks involving pointers and addressing
modes that change during program execution.
• Indexed Addressing: Indexed addressing is crucial for working with arrays
and other data structures. It combines a base address, an index register, and
an offset to access elements in an array or a data structure efficiently.
• Relative Addressing: Similar to indexed addressing, this mode uses a base register and an offset
to access data. For example, MOV AX, [BP-4] accesses a value at the address pointed to by BP
minus 4.
• Stack Addressing: This addressing mode involves operations on a processor's stack. The stack
pointer (SP) register is commonly used in this mode. For example, PUSH AX pushes the value of
AX onto the stack.
• Base Addressing: This addressing mode combines a base address with an offset. It is common in
memory segmentation models like the x86 segmented memory model.
• Auto-increment and Auto-decrement Addressing: In these modes, the address register is
automatically incremented or decremented after data access. For example, LDA X, A+ might
load the value at address A into register X and increment A by 1.
• PC-relative Addressing: Instructions reference data or code relative to the program counter (PC)
or instruction pointer (IP). This is common in branching and jump instructions.

You might also like