You are on page 1of 30

Addressing Modes

inn Microprocessor
8086/8088
Prof. Fayez F. M. El-Sousy
Department of Electrical Engineering
College of Engineering
Salman bin Abdulaziz University
Al-Kharj, Saudi Arabia

Prof. Fayez F. M. El-Sousy


Objectives of Addressing Modes
inin Microprocessor 8086/8088
Upon completion of this chapter, you will bee ableable to:to:

Explain the operation of each data-


addressingssing mode.
Use the data-addressing modes to form
assemblyssembly language statements.
Explain the operation of each program
memoryemory-- addressing mode.
Use the program memory-addressing modesdes toto form
assembly and machine language statementstements..
Prof. Fayez F. M. El-Sousy
Objectives of Addressing Modes
inin Microprocessor 8086/8088

Select the appropriate addressing mode


toto accomplish a given task.
Detail the difference between addressing
memory data using real mode and
protectedcted mode operation.
Describe the sequence of events that placee datadata
onto the stack or remove data from the stacktack..
Explain how a data structure is placed in
memory and used with software.

Prof. Fayez F. M. El-Sousy


Addressing Modes in
Microprocessorssor 8086/8088

Types of Addressing Modes:

(1) Data Addressing Modes


(2) Program-Memory Addressing
Modes
(3) Stack-Memory Addressing Modesodes

Prof. Fayez F. M. El-Sousy


1- Data Addressing Modes in
Microprocessor 8086/8088
An addressing mode means the method by
whichwhich an operand can be specified in a
register or aa memory location
8086/8088 provide a seven Addressing Modeses:
(1) Register Addressing
(2) Immediate Addressing
(3) Direct Addressing
(4) Register Indirect Addressing
(5) Base–Plus–Index Addressing
(6) Register Relative Addressing
(7) Base Relative–Plus–Index Addressing
Prof. Fayez F. M. El-Sousy
Opcode and Operand in
Microprocessorocessor 8086/8088
An opcode is a short of “operation code”
An opcede is a singe instruction can be executed byy thethe CPUCPU..
In machine language it is a binary or hexadecimall valuevalue
suchsuch as B7 loaded into the instruction register.
In assembly language mnemonic form an opcode isis
aa command such as MOV or ADD or JMP.
Example:
MOV AX, 1000H ; MOV is the opcode.
; AX (register) is an operandd..
Operands are manipulated by the opcode. In this example,example,
the operands are the register AX and the value 1000H00H..
8-bit 8-bit 8-bit
OP CODE OPERAND
Prof. Fayez F. M. El-Sousy 1 byte 1 to 2 byte
Register Addressing Mode

Transfers a copy of a byte or word from the sourcerce


registerregister or memory location to the destination
register orr memorymemory location.
Use of registers to hold the data to be manipulateded
Memory is not accessed when this addressing
modeode isis executed
Example:
MOV BX, DX ; copy the contents of DX into BXBX
MOV ES, AX ; copy the contents of AX into ESES
ADD AL, BH ; add the contents of BH to
contents of AL
Prof Source.FayezF.M.El-andSousy destination registers must have the sameame
sizesize
Register Addressing Mode

Prof. Fayez F. M. El-Sousy


Immediate Addressing Mode

Transfers the source, an immediate byte oror


wordword of data, into the destination register
or memoryemory location
The source operand is a constant
The operand comes immediately after the opcodeopcode
For this reason, this addressing mode
executescutes quickly
Immediate addressing mode can be used toto
loadload information into any of the registers
exceptpt thethe segment registers and flag registers.
Prof. Fayez F. M. El-Sousy
Immediate Addressing Mode

Example:
MOV AX, 2550H ; move 2550H into AX
MOV CX, 625 ; load the decimal value 62525
intointo
CX
MOV BL, 40H ; load 40H into BL

The data must first be moved to a general-purposepose


register and then to the segment register.
Example:
MOV AX, 2550H
MOV DS, AX
MOV DS, 0123H ; illegal instruction!
Prof. Fayez F. M. El-Sousy
Immediate Addressing Mode

Prof. Fayez F. M. El-Sousy


Direct Addressing Mode

Moves a byte or word between a memory


locationation andand a register.
The data is in some memory location(s) and
thethe address of the data in memory comes
immediatelyiately after the instruction
This address is the offset address
Example:
MOV AX, [2400] ; move contents of
DS:2400H2400H into AX
The physical address is calculated by combininging
thethe contents of offset location 2400 with DS
Prof. Fayez F. M. El-Sousy
Direct Addressing Mode
Example:
Find the physical address of the memory location andnd itsits
contents after the execution of the following, assuminging
thatthat DSDS = 1512H.
MOV AL, 3BH
MOV [3518], AL
Solution:
First 3BH is copied into AL,
Then in line two, the contents of AL are moved toto
logicallogical address DS:3518 which is 1512:3518.
Shifting DS left and adding it to the offset gives thethe
physicalphysical address of 18638H (15120H + 3518H = 18638H)..
After the execution of the second instruction, thee memorymemory Prof.
FayezlocationF.M.El-Susy with address 18638H will contain the valuealue 3BH3BH..
Direct Addressing Mode

Prof. Fayez F. M. El-Sousy


Register Indirect Addressing Modeode

Transfers a byte or word between a register andand aa


memory location addressed by an index or
basease register
The address of the memory location where
thee operand resides is held by a register
The registers used for this purpose are SI, DI,I, andand BXBX
They must be combined with DS in order to
generategenerate the 20-bit physical address.

Prof. Fayez F. M. El-Sousy


Register Indirect Addressing Modeode

Example:
MOV AX, [BX] ; moves into AX the contentsents ofof
the memory location pointedinted to
by DS:BX, 1000:12344
The physical address is calculated as
1000x10+1234=11234H
The same rules apply when using register SI oror
DIDI.. Example:
; move contents of DS:SI intointo CLCL ;
move contents of AH intoto DS:DIDS:DI

MOV CL, [SI]


MOV [DI], AH
Prof. Fayez F. M. El-Sousy
Register Indirect Addressing Modeode

Example:
Assume that DS = 1120, SI = 2498, and AX = 17FE7FE ShowShow
the contents of memory locations after the executioncution ofof
MOV [SI], AX ; move contents of AX into DS:SIDS:SI
Solution:
The contents of AX are moved into memory
locationslocations with logical address DS:SI and DS:SI + 1;
The physical address starts at DS (shifted left)ft) ++ SISI
== 13698. According to the little endian convention,tion,
Low address 13698H contains FE, the low byte,yte,
High address 13699H will contain 17, the highigh bytebyte..
Prof. Fayez F. M. El-Sousy
Register Indirect Addressing Modeode

Prof. Fayez F. M. El-Sousy


Base-Plus-Index Addressing Modeode

Transfers a byte or word between a register and the memoryry


locatlocationion addressed by a base register (BP or BX) plus an
index registerster ((DIDI oror SI).
Combining based and indexed addressing modes.
One base register and one index register are used.
Examples:
MOV [BX+DI], CL ; move contents of CL into DS:BX+DIDI
Physical Address = DSx10 + BX+DI

MOV CH, [BX+SI] ; move contents of the DS:BX+SI intoto CHCH


Physical Address = DSx10 + BX+SI

MOV AH, [BP+DI] ; move contents of the SS:BP+SI intoto AHAH


Physical Address = SSx10 + BP+DI

MOV [BP+SI], AL ; move contents of AL into SS:BP+SISI


Prof. Fayez PhysicalF.M.El-SousyAddress = SSx10 + BP+SI
Base-Plus-Index Addressing Modeode

Prof. Fayez F. M. El-Sousy


Register Relative Addressing Modeode

Moves a byte or word between a register and the memory locationlocation


addressed by an index or base register plus a displacement..
The data in a segment of memory are addressed by adding thethe
displacement to the contents of a base or an index register (BP,(BP,
BX,BX, DI,DI, or SI).
Examples:
MOV AX, [BX+4] ; move contents of DS:BX+4 into AX
Physical Address = DSx10 + BX+4

MOV CH, [SI+5] ; move contents of the DS:SI+5 into CHH


Physical Address = DSx10 +SI+5

MOV AH, [DI+1] ; move contents of the DS:DI+1 into AHAH


Physical Address = DSx10 + DI+1

MOV [BP+2], AL ; move contents of AL into SS:BP+2


Physical Address = SSx10 + BP+2
Prof. Fayez F. M. El-Sousy
Register Relative Addressing Modeode

Example:
Assume that DS = 4500, SS = 2000, BX = 2100, SI = 1486,486,
DIDI == 8500, BP= 7814, and AX = 2512. Show the exact
physisicalcal memory location where AX is stored in each of the
followingollowing.. AllAll values are in hex.
1- MOV [BX+20], AX
2- MOV [SI+10], AX
3- MOV [DI+4], AX
4- MOV [BP+12], AX
Solution:
Physical Address = segment reg. x 10 + (offset reg.) +
displacement
1- DS:BX+20 location 47120 = (12) and 47121 == (25)(25)
2- DS:SI+10 location 46496 = (12) and 46497 == (25(25 ))
3- DS:DI+4 location 4D504 = (12) and 4D505 == (25)(25)
Prof. Fayez F. M. El-Sousy

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


Register Relative Addressing Modeode

Prof. Fayez F. M. El-Sousy


Base Relative-Plus-Index
Addressing Mode
The base relative-plus-index addressing mode is similarlar
toto thethe base-plus-index addressing mode, but adds a
displacementement besides using a base register and an index
register to formform thethe memory address.
This type of addressing mode often addresses a two-
dimensionalimensional array of memory data.
The data in a segment of memory are addressed by addingdding
thethe displacement to the contents of a base and an index
registeregister (BP(BP,, BX, DI, or SI).
Examples:
MOV [BX+DI+1], AX ; move contents of AX into
DS:BX+DI+1
Physical Address = DSx10 + BX+DI+1H
MOV AX, [BX+SI+10] ; move contents of the DS:BX+SI+10X+SI+10
into AX
Prof. FayezPhysicalF.M.El-Sousy Address = DSx10 + BX+SI+10H
Base Relative-Plus-Index
Addressing Mode
MOV AH, [BP+DI+3] ; move contents of the
SS:BP+SI+3P+SI+3 into AH
Physical Address = SSx10 + BP+DI+3H

MOV [BP+SI+6], AL ; move contents of AL into


SS:BP+SI+6
Physical Address = SSx10 + BP+SI+6

MOV AX, FILE[BX+DI] ; move contents of the


DS:FILE+BX+DI into AXX
Physical Address = DSx10 + BX+DI+FILE

MOV LIST[BP+SI+4], DH ; move contents of DH


x
intoto SS:LIST+BP+SI+4
Prof. Fayez F. M. El-Sousy

Physical Address = SS 10 +LIST+ BP+SI+4


Base Relative-Plus-Index
Addressing Mode

Prof. Fayez F. M. El-Sousy


Offset Registers for Various Segmentsegments

The following Table provides a summary of


thethe offset registers that can be used with the
fourr segment registers of the 8086/8088.

Segment Register CS DS ES SSSS

Offset Register IP SI, DI, BX SI, DI, BX SP,SP, BPBP

Prof. Fayez F. M. El-Sousy


2- Program-Memory Addressing
ModesModes in Microprocessor 8086/8088

Program memory-addressing modes, usedd


withwith the JMP and CALL instructions,
consist ofof three distinct forms:
1- Direct Program Memory Addressingng
2- Relative Program Memory Addressingng
3- Indirect Program Memory Addressingng
These three addressing forms are introduceduced
inin the next Chapter (5) using the JMP
instructionuction to illustrate their operation.

Prof. Fayez F. M. El-Sousy


3- Stack-Memory Addressing Modesdes
inin Microprocessor 8086/8088
The stack plays an important role in all
microprocessors.
It holds data temporarily and stores return
addressesdresses for procedures.
The stack memory is a LIFO (last-in, first-out)t)
memory,memory, which describes the way that data are
stored andand removed from the stack.
Data are placed onto the stack with a PUSH
instructionnstruction and removed with a POP instruction.
The CALL instruction also uses the stack to holdold thethe
return address for procedures and a RET (return)turn)
instruction to remove the return address from thethe stackstack..
Prof. Fayez F. M. El-Sousy

You might also like