You are on page 1of 11

1) DATA ADDRESSING MODES

Addressing modes used by most instructions except Program Transfer


Instructions, Processor Control Instructions and Stack Operations are as
follows:

1.1. Register addressing


- The data is in the register that is specified by the instruction. In this
addressing mode, the operand is an internal register.
e.g.
MOV CX, DX {copies the 16-bit content of source register DX into
destination register CX}

Destination Operand Source Operand


Addressing Mode Register Addressing Register Addressing

1.2. Immediate addressing


- The 8-bit or 16-bit immediate data is part of the instruction. In this
addressing mode, the source operand is constant data.
e.g.
MOV CX, 1234H {copies a word-sized data 1234H to register CX}

Destination Operand Source Operand


Addressing Mode Register Addressing Immediate Addressing

1.3. Direct addressing


- The 16-bit direct effective or offset address of the data is part of the
instruction.
e.g.
MOV CL, [1000H] {copies the 8-bit data from memory location [DS x
10H + 1000H] to register CL}
Given:

page 1
Upon execution:

Destination Operand Source Operand


Addressing Mode Register Addressing Direct Addressing

MOV [3000H], AL {copies the byte-sized data from register AL to


memory location [DS x 10H + 3000H]}
Given:

page 2
Upon execution:

Destination Operand Source Operand


Addressing Mode Direct Addressing Register Addressing

1.4. Register indirect addressing


- Under this addressing mode, the data operand is found in the memory
location pointed to by either base (BX/BP) or index registers (SI/DI).
e.g.
MOV AX, [BX] {copies the word-sized data from data segment
memory location pointed by BX to register AX}
Given:

Upon execution:

Destination Operand Source Operand


Addressing Mode Register Addressing Register Indirect Addressing

page 3
MOV [DI], BX {moves the 16-bit contents of register BX to two
memory locations in the data segment memory location indexed by
DI.}
Given:

Upon execution:

Destination Operand Source Operand


Addressing Mode Register Indirect Addressing Register Addressing

1.5. Base-plus-index addressing


- Under this addressing mode, the effective or offset address of the data
is calculated as the sum of contents of base register (BX or BP) and
index register (SI or DI).
e.g.
MOV [BX + DI], CL {transfers byte-sized data from register CL to
memory location [DS x 10H + BX + DI]}
Given:

page 4
Upon execution:

Destination Operand Source Operand


Addressing Mode Base plus Index Addressing Register Addressing

1.6. Register relative addressing


- Under this addressing mode, the effective or offset address of the data
is calculated as the sum of an 8-bit or 16-bit displacement and the
contents of base register or an index register.
e.g.
MOV CL, [BX + 02H] {loads CL with 8-bit data from data segment
memory location addressed by BX plus an 8-bit displacement 02H}
Given:

Upon execution:

Destination Operand Source Operand


Addressing Mode Register Addressing Register Relative Addressing

MOV [SI + 1000H], AX {moves the 16-bit data from register AX to


the data segment memory location addressed by SI plus a 16 bit
displacement 1000H}

page 5
Given:

Upon execution:

Destination Operand Source Operand


Addressing Mode Register Relative Addressing Register Addressing

1.7. Base-relative plus index addressing


- Under this addressing mode, the data operand is found in the memory
location addressed by base register (BX or BP) and index register (SI
or DI) plus an 8-bit or 16-bit displacement.
e.g.
MOV AX, [BP + SI + 02H] {loads AX with 16-bit data from a stack
segment memory location addressed by BP, DI plus an 8-bit
displacement 02H}
Given:

page 6
Upon execution:

Destination Operand Source Operand


Addressing Mode Register Addressing Base-Relative plus Index
Addressing

1.8. Scaled- Index addressing


- This addressing mode is unique to 80386 through Pentium 4
microprocessors.
- It uses to two 32-bit registers (a base register and an index register) to
access the memory. The second 32-bit register (index register) is
multiplied by a scaling factor. The scaling factor can be 1X, 2X, 4X or
8X. A scaling factor of 2X is used to address word-sized memory
arrays, a scaling factor of 4X is used to address doubleword-sized
memory arrays, and a scaling factor of 8X is used to address
quadword-sized memory arrays.
e.g.
MOV AX, [EBX+2*ESI] {Copies the word content of data segment
memory location addressed by the sum of 2 times ESI plus EBX into
AX}
Given:

page 7
Upon execution:

Destination Operand Source Operand


Addressing Mode Register Addressing Scaled-Index Addressing

1.9 String addressing


- Addressing mode used for string instructions. Instructions involving
strings usually uses the source and destination index registers (SI and
DI) to specify the effective addresses of the source and destination
operands respectively.
e.g.
MOVSB {Moves byte-sized data from data segment memory location
pointed by SI to the memory location in the extra segment pointed by
DI}
Given:

Upon execution:

If DF = 0, SI = SI+1 = 0901H and DI = DI +1 = 1001H


If DF =1, SI = SI-1 = 08FFH and DI = DI-1 = 0FFFH

page 8
1.10 Port addressing
- For reading and writing data to/from the I/O devices, this addressing
mode is used. Under this addressing mode, the I/O port address of an
I/O device is part of the instruction.
e.g.
IN AL, 3FH {the input device having port address of 3FH will move
data to register AL}

Destination Operand Source Operand


Addressing Mode Register Addressing Port Addressing

OUT 40H, AL {the contents of register AL is transferred to an output


device with port address 40H}

Destination Operand Source Operand


Addressing Mode Port Addressing Register Addressing

page 9
Example:
Identify the addressing modes used by the following instructions:
INSTRUCTION ADDRESSING MODE
DESTINATION SOURCE
MOV WORDPTR [DI], 1234H Register Indirect Immediate
addressing addressing
XOR BX, AX Register addressing Register addressing
ADD [SI + 02H], DX Register Relative Register addressing
addressing
XCHG [BX+DI], CX Base + Index Register addressing
addressing
CALL NEAR[SI] Intrasegment Indirect addressing
JGE F3H Intrasegment Direct addressing
IN AL, 40H Register addressing Port addressing
STD Implied addressing
LODSW String addressing
SUB AX, [BX+DI+02H] Register addressing Base-Relative plus
Index addressing
POP DX Register addressing Stack Memory
addressing
OUT 40H, AL Port addressing Register addressing
JMP 5000:1234 Intersegment Direct addressing
SHL AX, CL Register addressing Register addressing
CMC Implied addressing
LEA CX, [1002H] Register addressing Direct addressing
PUSH WORD PTR[BX+1111H] Stack Memory Register Relative
addressing addressing

page 10
page 11

You might also like