Você está na página 1de 22

Addressing Modes in Microprocessor 8086/8088

An addressing mode means the method by which an operand can


be specified in a register or a memory location.

8086/8088 provide a seven Addressing Modes :


(1) Register Addressing
(2) Immediate Addressing
(3) Direct Addressing
(4) Register Indirect Addressing
(5) BasePlusIndex Addressing
(6) Register Relative Addressing
(7) Base RelativePlusIndex Addressing
Microprocessor System Design 3-1
Register Addressing Mode
Transfers a copy of a byte or word from the source register
or memory location to the destination register or memory
location.
Use of registers to hold the data to be manipulated
Memory is not accessed when this addressing mode is
executed
Example:
MOV BX, DX ; copy the contents of DX into BX
MOV ES, AX ; copy the contents of AX into ES
ADD AL, BH ; add the contents of BH to contents of AL
Source and destination registers must have the same size
Microprocessor System Design 3-2
Register Addressing Mode

Microprocessor System Design 3-3


Immediate Addressing Mode
Transfers the source, an immediate byte or word of data, into the
destination register or memory location
The source operand is a constant ,comes immediately after the
opcode.
For this reason, this addressing mode executes quickly
Immediate addressing mode can be used to load information into
any of the registers except the segment registers and flag
registers.
Example:
MOV AX, 2550H ; move 2550H into AX
MOV CX, 625 ; load the decimal value 625 into CX
MOV BL, 40H ; load 40H into BL
Microprocessor System Design 3-4
Immediate Addressing Mode
The data must first be moved to a general-purpose register and then to the
segment register.
Example:
MOV AX, 2550H
MOV DS, AX
MOV DS, 0123H ; illegal instruction segment reg.

Microprocessor System Design 3-5


Direct Addressing Mode
Moves a byte or word between a memory location and a register.
The data is in some memory location(s) and the address of the data in memory
comes immediately after the instruction, this address is the offset/effectiv
address.
Example: MOV AX, [2400] ; move contents of DS:2400H into AX.
The physical address is calculated by combining the contents of offset location
2400 with DS.
Example: Find the physical address of the memory location and its contents after
the execution of the following, assuming that DS = 1512H.
MOV [3518], AL
SOLUTION:
The contents of AL are moved to logical address DS:3518 which is 1512:3518.
Shifting DS left and adding it to the offset gives the physical address of 18638H
(15120H + 3518H = 18638H).
After the execution of the second instruction, the memory location with address
18638H will contain the value 3BH.
Microprocessor System Design 3-6
Direct Addressing Mode

Microprocessor System Design 3-7


Register Indirect Addressing Mode
Transfers a byte or word between a register and a memory
location addressed by an index or base register
The address of the memory location where the operand resides
is held by a register
The registers used for this purpose are SI, DI, and BX.
They must be combined with DS in order to generate the 20-bit
physical address.
Example:
MOV AX, [BX] ; moves into AX the contents of the memory
location pointed to by DS:BX, 1000:1234
The physical address is calculated as 1000x10+1234=11234H
The same rules apply when using register SI or DI.
Microprocessor System Design 3-8
Register Indirect Addressing Mode
Example:
Assume that DS = 1120, SI = 2498, and AX = 17FE.
Show the contents of memory locations after the execution of MOV [SI], AX ;
move contents of AX into DS:SI

Solution:
The contents of AX are moved into memory locations with logical address
DS:SI and DS:SI + 1;
The physical address starts at DS (shifted left) + SI = 13698. According to the
little endian convention,
Low address 13698H contains FE, the low byte,
High address 13699H will contain 17, the high byte

Microprocessor System Design 3-9


Register Indirect Addressing Mode

Microprocessor System Design 3-10


Register Indirect Addressing Mode

Microprocessor System Design 3-11


Base-Plus-Index Addressing Mode
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).
The base register holds the beginning location of the memory
array, while the index holds the relative position of an element in
array.
Used to address element in a memory array.

Examples:
MOV [BX+DI], CL ; move contents of CL into DS:BX+DI
Physical Address = DS x 10 + BX+DI
MOV CH, [BX+SI] ; move contents of the DS:BX+SI into CH
Physical Address = DS x 10 + BX+SI
3-12
Base-Plus-Index Addressing Mode

Microprocessor System Design 3-13


Register Relative Addressing Mode
Moves a byte or word between a register and the memory location addressed by
an index or base register plus a displacement.
Similar with the BPI, but the data in a segment of memory are addressed by
adding the displacement to the contents of a base or an index register (BP, BX,
DI, or SI).

Microprocessor System Design 3-14


Register Relative Addressing Mode

Example:
Assume that DS = 4500, SS = 2000, BX = 2100, SI = 1486, DI =
8500, BP= 7814, and AX = 2512. Show the exact physical
memory location where AX is stored. All values are in hex.

1- MOV [BX+20], AX
2- MOV [SI+10], AX
3- MOV [DI+4], AX
4- MOV [BP+12], AX

Microprocessor System Design 3-15


Register Relative Addressing Mode

Solution:
Physical Address = segment reg. x 10 + (offset reg.) +
displacement

1- DS:BX+20 location 47120 = (12) and 47121 = (25)

2- DS:SI+10 location 46496 = (12) and 46497 = (25 )

3- DS:DI+4 location 4D504 = (12) and 4D505 = (25)

4- SS:BP+12 location 27826 = (12) and 27827 = (25)

Microprocessor System Design 3-16


Base Relative-Plus-Index Addressing Mode

The base relative-plus-index addressing mode is similar to the


base-plus-index addressing mode, but adds a displacement besides
using a base register and an index register to form the memory
address.
This type of addressing mode often addresses a two-dimensional array of
memory data.
The data in a segment of memory are addressed by adding the displacement to
the contents of a base and an index register (BP , BX, DI, or SI).
Examples:
MOV [BX+DI+1], AX ; move contents of AX into DS:BX+DI+1
Physical Address = DS x 10 + BX+DI+1H
MOV AX, [BX+SI+10] ; move contents of the DS:BX+SI+10 into AX
Physical Address = DS x 10 + BX+SI+10H
Microprocessor System Design 3-17
Base Relative-Plus-Index Addressing Mode

Microprocessor System Design 3-18


Base Relative-Plus-Index Addressing Mode
For two dimensional array to store a record.
Example student record as name, roll no etc.
To access a data element from particular record we use base
register to hold the beginning address of the array of records,
index register to point a particular record in the array of records
and displacement to point to a particular element in the record.

Microprocessor System Design 3-19


Addressing Modes Summery
Addressing Modes Examples

Immediate addressing MOV AL, 12H

Register addressing MOV AL, BL

Direct addressing MOV [500H], AL

Register Indirect addressing MOV DL, [SI]

Based addressing MOV AX, [BX+4]

Indexed addressing MOV [DI-8], BL

Based indexed addressing MOV [BP+SI], AH

Based indexed with displacement addressing MOV CL, [BX+DI+2]


Addressing Modes in Microprocessor 8086/8088

Microprocessor System Design 3-21


Offset Registers for Various Segments

The following Table provides a summary of the offset registers


that can be used with the four segment registers of the 8086/8088

Microprocessor System Design 3-22

Você também pode gostar