You are on page 1of 20

ADDRESSING MODES

Addressing modes
• The term addressing modes refers to the way in
which the operand of an instruction is specified.
• Addressing modes provide flexible access to
memory, allowing you to easily access variables,
arrays, records and pointers.
• Addressing mode describes the type of operand
and how they are accessed for execution.
Categories of instructions
Instructions may be categorized as:
• Sequential control flow instruction
• Control transfer instructions
Sequential control flow instructions
• Sequential control flow instructions are the
instructions which after execution, transfer
control to the next instruction appearing
immediately after it in the program.
• For example, the arithmetic, logical, data
transfer and processor control instructions.
Control transfer instructions
• The control transfer instructions, on the other
hand , transfer control to the address
somehow specified in the instruction, after
their execution.
• For example INT, CALL, RET and JUMP
instructions
Program instruction
An assembly language program instruction
consists of two parts:
- Opcode
- Operand
OPCODE OPERAND
Addressing modes
• Immediate
• Direct
• Indirect
• Register
• Register Indirect
• Displacement (Index)
Immediate addressing
• An immediate operand has a value after the
opcode.
• When an instruction with two operands uses
immediate addressing, the first operand may
be a register or memory location, and the
second operand is an immediate constant
value.
• Example: MOV AX,10 OPCODE VALUE
Direct addressing
• It is direct access to main memory by
specifying operands in memory addressing
mode, usually requiring specifying of data
segment.
• This mode of addressing results to slower
processing of data.
• No additional calculations to find the effective
address of the operand.
OPCODE ADDRESS

ADD AX,4000
• Where 4000 is the effective address of the operand.
• Effective Address is the location where operand is
present.
Indirect addressing
• In this, the address field of instruction gives the
address where the effective address is stored in
memory.
• This slows down the execution, as this includes
multiple memory lookups to find the operand.
• Indirect addressing is generally used for
variables containing several elements like,
arrays. Starting address of the array is stored in,
say, the EBX register.
• E.g. MOV [EBX], 110
Register addressing
• In this addressing mode, a register contains
the operand.
• Depending upon the instruction, the register
may be the first operand, the second operand
or both.
• It provides fast processing of data as it does
not involve the memory.
• E.g. MOV EAX, EBX
Register indirect addressing
• In this mode, the address of the memory location which
contains data or operand is
determined in an indirect way, using the offset registers.
• For instance, the offset address of data is in either BX or
SI or DI register.
• The default segment is either DS or ES.
• The data is supposed to be available at the
address pointed to by the content of any of the above
registers in the default data segment.
• E.g. MOV AX,[BX]
Displacement addressing
• In this, the contents of the indexed register is
added to the Address part of the instruction,
to obtain the Effective Address (EA) of
operand.
• EA = A + (R), In this the address field holds two
values, A(which is the base value) and R(that
holds the displacement), or vice versa.
Memory Access
• To access the memory we use 4 registers namely:
BX, SI, DI, BP
• Combining these memory inside [ ] symbols
allow access to different memory locations.
• Displacement can be a immediate value or offset
of a variable, or even both.
• If there are several values, assembler evaluates
all values and calculates a single immediate
value.
• Displacement can be inside or outside of the
[ ] symbols.
• Assembler generates the same machine code
for both ways.
• Displacement is a signed value, so it can be
both positive or negative.
Example
• For example, let's assume that DS = 100, BX =
30, SI = 70.
The following addressing mode:
•  [BX + SI] + 25
Is calculated by processor to this physical
address: 
• 100 * 16 + 30 + 70 + 25 = 1725.
• By default DS segment register is used for all
modes except those with BP register, for
these SS segment register is used.
• Below is a how the registers are combined.
Segment and Offset values
• The value in segment register (CS, DS, SS, ES)
is called a segment.
• On the other hand, the value in general
purpose register (BX, SI, DI, BP) is called
an offset.
Example
• When DS contains value 1234h and SI contains
the value 7890h it can be also recorded
as 1234:7890.
• The physical address will be 1234h * 10h + 7890h
= 19BD0h.
• If zero is added to a decimal number it is
multiplied by 10, however 10h = 16.
• So If zero is added to a hexadecimal value, it is
multiplied by 16.

You might also like