Addressing Modes of 8086: Navila Rahman Nadi

Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

Addressing Modes of

8086
Navila Rahman Nadi
• Processor will get the data of the
user through different sources.
• The different ways in which a
processor can access data are called
addressing modes.
• In other words, the different ways
in which a source operand is
denoted in an instruction is known
as addressing modes
How 8086 accesses data?
• 8086 assembly language instructions
can be used to illustrate the
addressing modes
• Format of MOV instruction
MOV destination, source
• Source of data can be
– Immediate data
– A specified register
– A memory location specified in
different ways
• Destination of data can be
– A specified register
– A memory location specified in
different ways
Classification of
Addressing Modes
1. Register addressing mode and
Immediate addressing mode
2. Memory addressing mode
3. Port addressing mode
4. Relative addressing mode
5. Implied addressing mode
1. Register addressing mode
• The instruction will specify the name of the register which holds the data to

be operated by the instruction .


• Source/destination can be one of the 8086 registers

• MOV AX, BX ; 16-bit data transfer


• MOV AL, BL ; 8-bit data transfer
2. Immediate addressing mode
• 8 or 16-bit data can be specified as
part of the instruction
3. Memory addressing mode
• One of the operands is in memory
• 8086 must use
– a segment register
– A 16-bit offset (effective address)
• By default, DS register is used for accessing data
from memory
Different ways of
specifying offset
• Direct memory addressing
• Register Indirect addressing
• Based addresing
• Indexed addressing
• Based Indexed addressing
• String addressing
a. Direct Memory addressing
• Effective address is specified directly in the instruction
Example MOV BX, [5062]

• 20-bit physical address of memory location is calculated


using DS and offset value 5062.

• If DS=1000H then the memory location will be: 15062.

• When executed, this instruction will copy the contents


of the memory location 15062 into BX register.

• This addressing mode is called direct because the


displacement of the operand from the segment base is
specified directly in the instruction.
b. Register indirect addressing
• Name of the register which holds the effective address
(EA) or offset, will be specified in the instruction.
• Registers used to hold EA are any of the following
registers:
BX, BP, DI and SI.
Example MOV CX, [BX]
• Content of the DS register is used for base address
calculation.
• If DS = 2000H, BX = 0004H
• THEN contents of memory location 20004H are copied to
register CX
Operations:
EA = (BX)
BA = (DS) x 10
PA = BA + EA
(CX)  (PA) or, (CL)  (PA)
(CH)  (PA+1)
c. Based addressing
• BX or BP is used to hold the base value for effective address
and a signed 8-bit or unsigned 16-bit displacement will be
specified in the instruction.
• Effective address is sum of
– signed 8-bit or unsigned 16-bit displacement given in
instruction
– Base value from BX or BP
• Segment register is DS or SS
• In case of 8-bit displacement, it is sign extended to 16-bit
before adding to the base value
Example: MOV AX, [BX + 08H]
Operations:
0008H  08H (Sign extended)
EA = (BX) + 0008H
BA = (DS) x 10
PA = BA + EA
(AX) (PA) or, (AL)  (PA)
• (AH)  (PA+1)
d. Indexed addressing
• SI or DI is used to hold the base value for effective address and a signed
8-bit or unsigned 16-bit displacement will be specified in the instruction
• Effective address is sum of
– signed 8-bit or unsigned 16-bit displacement given in instruction
– Contents of index register SI or DI
• Segment register is DS .
• Example:
• MOV CX, [SI + A2H]
Operation
FFA2H A2H (Sign extended)
EA or offset = (SI) + FFA2H
BA = (DS) x 1610
PA = BA + EA
(CX)  (PA) or, (CL) (PA)
• (CH) (PA+1)

e. Based Indexed addressing
• In Based Index Addressing, the effective address is computed from the
sum of a base register (BX or BP), an index register (SI or DI) and a
displacement.

• Effective address is sum of


– signed 8-bit or unsigned 16-bit displacement given in instruction
– Contents of index register SI or DI
– Base value from BX or BP
• Segment register is DS
Example: MOV DX, [BX + SI + 0AH]
Operations:
000AH  0AH (Sign extended)
EA = (BX) + (SI) + 000AH
BA = (DS) x 1610
PA = BA + EA
(DX)  (PA) or, (DL)  (PA)
(DH)  (PA + 1)
f. String addressing
• Used when string related instructions are executed
Uses index registers
• SI register points to the first byte or word of the source string
• DI register points to the first byte or word of the destination string.
• Segment register for calculating base address of source data is DS and
that of the destination data is ES

• Example: MOVS BYTE


Operations:
Calculation of source memory location:
EA S = (SI) BA S = (DS) x 1610 PA S = BA S + EA S

Calculation of destination memory location:


EA D = (DI) BA D = (ES) x 1610 PA D = BA D + EA D
4. Port addressing
These addressing modes are used to access data from standard I/O
mapped devices or ports.
In direct port addressing mode, an 8-bit port address is directly
specified in the instruction.
Example: IN AL, [09H]
Operations: PORT(addr) = 09H
(AL)  (PORT)
Content of port with address 09H is moved to AL register
5. Relative addressing mode

Example JNC 08H


IF CF = 0 ??
(DO IT)
6. Implied addressing mode
• No operands are specified
• E.g. CLC
• Means clear carry flag
• The instruction itself will specify the
data to be operated by the
instruction.

You might also like