Chapter 6
Chapter 6
Chapter 6
Addressing Modes
DATA-ADDRESSING MODES
The MOV instruction is a very common and
flexible instruction, it provides a basis for the
explanation of the data-addressing modes.
The source is to the right and the
destination is to the left, next to the opcode
MOV.
The comma always separates the
destination from the source in an instruction.
The figure below The MOV instruction
showing the source, destination, and
direction of data flow.
The Data-addressing modes :
Register
Register Immediate Direct
indirect
addressing addressing addressing
addressing
Base-plus- Register
Scaled-index RIP relative
index relative
addressing addressing
addressing addressing
The data-addressing modes are as follows:
Register addressing transfers a copy of a byte or
word from the source register or contents of a
memory location to the destination register or
memory location.
Example: The MOV CX, DX
instruction copy DX into CX.
Exercise
What do the following MOV instructions
accomplish?
(a) MOV AX,BX
(b) MOV BX,AX
(c) MOV BL,CH
(d) MOV ESP,EBP
(e) MOV RAX,RCX
Exercise
Select an instruction for each of the following tasks:
(a) copy EBX into EDX
(b) copy BL into CL
(c) copy SI into BX
(d) copy DS into AX
Immediate addressing transfers the
source, an immediate byte, word,
doubleword, or quadword of data, into
the destination register or memory
location.
• Direct addressing moves a byte or
word between a memory location
and a register. The instruction set
does not support a memory to
memory transfer.
Register indirect addressing transfers a
byte or word between a register and a
memory location addressed by an index or
base register.
The index and base registers are BP, BX, DI,
and SI.
Base-plus-index addressing transfers a byte or
word between a register and the memory
location addressed by a base register (BP or BX)
plus an index register (DI or SI).
Example: The MOV [BX+DI],CL instruction copies
the register CL into the data segment memory
location addressed by BX plus DI.
Register relative addressing moves
a byte or word between a register and
the memory location addressed by an
index or base register plus a
displacement.
Scaled-index addressing is available only in
the 80386 through the addressing Pentium 4
microprocessor. The second register of a pair of
registers is modified by the scale factor of 2×,
4×, or 8× to generate the operand memory
address.
RIP relative addressing
This addressing mode is only
available to the 64-bit extensions on
the Pentium 4 or Core2.
• For example, if
RIP = 1000000000H
and a 32-bit displacement is 300H,
the location accessed is
1000000300H
1000000000H+
300H
1000000300H
Register Addressing
Register addressing is the
most common form of data
addressing and, once the
register names are learned, is
the easiest to apply.
The Programming Model
The microprocessor contains the
following 8-bit register names used
with register addressing: AH, AL, BH,
BL, CH, CL, DH, and DL.
Also present are the following
16-bit register names: AX, BX,
CX, DX, SP, BP, SI, and DI.
In the 80386 and above, the
extended 32-bit register names
are: EAX, EBX, ECX, EDX,
ESP, EBP, EDI, and ESI.
• In the 64-bit mode of the Pentium
4, the register names are: RAX,
RBX, RCX, RDX, RSP, RBP,
RDI, RSI.
Immediate Addressing
Another data-addressing mode is
immediate addressing. The term immediate
implies that the data immediately follow the
hexadecimal opcode in the memory.
In the 80386 through the Core2
microprocessors, immediate addressing also
operates on doubleword data.
The MOV immediate instruction transfers a
copy of the immediate data into a register or a
memory location.
Direct Data Addressing
Most instructions can use the direct data-
addressing mode. In fact, direct data
addressing is applied to many instructions in a
typical program.
There are two basic forms of direct data
addressing:
1. Direct addressing, which applies to a MOV
between a memory location and AL, AX, or
EAX.
2. Displacement addressing, which
applies to almost any instruction in
the instruction set.
Register Indirect Addressing
Register indirect addressing
allows data to be addressed at any
memory location through an offset
address held in any of the following
registers: BP, BX, DI, and SI.
Base-Plus-Index Addressing
Base-plus-index addressing is similar to
indirect addressing because it indirectly
addresses memory data.
In the 8086 through the 80286, this type
of addressing uses one base register (BP or
BX) and one index register (DI or SI) to
indirectly address memory.
Locating Data with Base-Plus-Index
Addressing