8086 Microprocessor
Addressing Modes
Microprocessor Dr. Gauri Shukla 1
8086 – Programmer’s Model of 8086
ES Extra Segment
BIU
CS Code Segment
Registers
SS Stack Segment
DS Data Segment
IP Instruction Pointer
Microprocessor Dr. Gauri Shukla 2
8086 – Programmer’s Model of 8086
AX AH AL Accumulator
BX BH BL Base Register
CX CH CL Count Register
EU
DX DH DL Data Register
Registers
SP Stack Pointer
BP Base Pointer
Source Index
SI
Register
Destination Index
DI
Register
FLAGS
Microprocessor Dr. Gauri Shukla 3
8086 – Programmer’s Model of 8086
Segment Registers Offset Registers
Code Segment Instruction Pointer
Stack segment Stack Pointer
Base Pointer
Data Segment Source Index
Destination Index
Extra Segment
Microprocessor Dr. Gauri Shukla 4
8086
Addressing modes
1. Immediate Addressing mode
2. Register Addressing mode
3. Memory Addressing mode
4. String Addressing mode
5. I/O Addressing mode
6. Implied Addressing mode
Microprocessor Dr. Gauri Shukla 10
8086
Addressing
modes
Register Immediate Memory String I/O Implied
Direct port Indirect port
addressing addressing
Register
Register Relative Based
Direct Based Indexed Relative
Indirect Indexed
Microprocessor Dr. Gauri Shukla 11
8086 - Addressing modes for Data Memory
1. Immediate Addressing Mode:
In this type of addressing, immediate data is a part of instruction, and
appears in the form of successive byte or bytes.
Example: MOV AX, 0005H
The immediate data 0005H is moved into reg AX.
The immediate data may be 8-bit or 16-bit in size.
.
OPCODE Immediate Operand
Microprocessor Dr. Gauri Shukla 12
8086 - Addressing modes for Data Memory
2. Register Addressing Mode:
• In register addressing mode, the data is stored in a register and it is
referred using the particular register.
• All the registers, except IP, may be used in this mode.
• Example: MOV BX, AX.
Microprocessor Dr. Gauri Shukla 14
8086 - Addressing modes for Data Memory
3. Memory Addressing Mode:
In this addressing mode the operands in the memory must be transferred
to & fro over the BUS
Microprocessor Dr. Gauri Shukla 16
8086 - Addressing modes for Data Memory
3.1. Direct Memory Addressing Mode:
In this mode, a 16-bit memory address (offset) is directly specified in the
instruction as a part of it.
PA = segment : EA Opcode Address A
= CS
DS : Direct
Registers Memory
ES Address
SS
Segment *10 + Operand
Register
Microprocessor Dr. Gauri Shukla 20
8086 - Addressing modes for Data Memory
3.1. Direct Memory Addressing Mode:
Example: MOV [5000H], AL
The contents of AL are copied to memory location whose offset is [5000]
The effective address, here, is 10H*DS+5000H.
By default, DS segment register is used for direct addressing mode
Microprocessor Dr. Gauri Shukla 21
8086 - Addressing modes for Data Memory
3.2. Register Indirect Addressing Mode:
The EA of the memory is taken directly from one of the base register or
index register specified by the instruction.
This address is added with the segment reg*10 to generate the 20 bit
physical address. Opcode Register R
EA = (BX)/(BP)/(SI)/(DI)
PA = segment : EA Registers
CS BX Pointer to Operand
Operand +
DS : BP
SS SI
Segment *10
ES DI
Reg
If reg is SI,DI,BX DS default segment
=
Microprocessor Dr. Gauri Shukla 22
8086 - Addressing modes for Data Memory
3.3 Indexed:
In this addressing mode, the data is available at an effective address
formed by adding
i. displacement
ii. with the content of any one of the index registers SI,DI in the
default segment.
Microprocessor Dr. Gauri Shukla 24
8086 - Addressing modes for Data Memory
3.3 Indexed
(SI)
EA = (DI)
+
displacement
Mov Ax, [SI+6]
AL [SI+6]; AH <- [SI+7]
Microprocessor Dr. Gauri Shukla 25
8086 - Addressing modes for Data Memory
3.4 Based:
In this addressing mode, the data is available at an effective address
formed by adding
i. displacement
ii. with the content of any one of the registers BX, BP in the default
segment.
Microprocessor Dr. Gauri Shukla 26
8086 - Addressing modes for Data Memory
3.4 Based:
(BX)
+
EA = (BP) displacement
Mov Ax, [BP+2]
AL [BP+2]; AH <- [BP+3]
Microprocessor Dr. Gauri Shukla 27
8086 - Addressing modes for Data Memory
3.3 Base and Indexed Addressing Mode: a special case of the
register indirect addressing mode.
The offset of the operand is stored in one of the index registers.
EA = {Base register} + {Index register}
(BX) (SI) Opcod Base Register Index Register
+ e
(BP) (DI)
Registers
PA = segment : EA
Pointer to
Memory
Operand
CS (BX) (SI)
DS : (BP) + Pointer to
(DI) Operand + Operand
SS
ES
Segment
Reg
Microprocessor Dr. Gauri Shukla 28
8086 - Addressing modes for Data Memory
3.3 Base and Indexed Addressing Mode:
Example: MOV AX, [BX+SI]
Moves a word from address pointed by BX+ SI in Data Seg to DX
Here, data is available at an offset address stored in BX+SI in DS.
Microprocessor Dr. Gauri Shukla 29
8086 - Addressing modes for Data Memory
3.5 Base Indexed with Displacement
The effective address of operand is calculated as
an displacement + the bases registers + index
registers
Base registers - BX or BP and any one of the index
registers, in a default segment.
Microprocessor Dr. Gauri Shukla 30
8086 - Addressing modes for Data Memory
3.5 Base Indexed with Displacement
• EA = {Base register}+ {Index register}+{ displacement}
(BX) + (SI) +
displacement
(BP) (DI)
• PA = segment : EA
CS
DS : (BX) + (SI) +
displacement
SS (BP) (DI)
ES
Microprocessor Dr. Gauri Shukla 31
8086 - Addressing modes for Data Memory
Base Indexed with Displacement
Example:
MOV AX, [BX+SI+5}
AL [BX+SI+5], AH <- [BX+SI+6]
Microprocessor Dr. Gauri Shukla 32
8086 - Addressing modes for Data Memory
4. String addressing
SI points to 1st byte or word of source string & DS –
default segment reg
DI points to 1st byte or word of destination string &
ES – default segment reg
Do not use the normal memory addressing
modes
Microprocessor Dr. Gauri Shukla 33
8086 - Addressing modes for Data Memory
5. I/O Addressing modes:
Basically used for Ios
2 types –
Memory mapped I/O
I/O Mapped I/O
Direct port addressing
Indirect port addressing
Microprocessor Dr. Gauri Shukla 34
8086 - Addressing modes for Data Memory
6. Implied:
In this addressing mode, the operands are
implied and hence not specified in the
instruction.
Example: STC - Set Carry Flag,
CLD – Clear Direction Flag
Microprocessor Dr. Gauri Shukla 35