7/24/2019 02 Addressing Modes
1/53
ADDRESSING MODES &
Instruction set
7/24/2019 02 Addressing Modes
2/53
Introduction
2
8086Microprocessor
ProgramA set of instructions written to solve
a problem.
InstructionDirections which a microprocessor
follows to execute a task or part of atask.
Computer language
High Level Low Level
achine Language Assembl! Language
"inar! bits #nglish Alphabets $nemonics% Assembler
nemonics achineLanguage
7/24/2019 02 Addressing Modes
3/53
ADDRESSING MODES
7/24/2019 02 Addressing Modes
4/53
&roup I ' Addressing modes forregister and immediate data
&roup I( ' )elative Addressing mode
&roup ( ' Implied Addressing mode
&roup III ' Addressing modes forI*+ ports
&roup II ' Addressing modes formemor! data
Addressing odes
5
8086Microprocessor
#ver! instruction of a program has to operate on a data.,he different wa!s in which a source operand is denotedin an instruction are known as addressing modes.
-. )egister Addressing
. Immediate Addressing
/. Direct Addressing
0. )egister Indirect Addressing
1. "ased Addressing
2. Indexed Addressing
3. "ased Index Addressing
4. 5tring Addressing
6. Direct I*+ port Addressing
-7. Indirect I*+ port Addressing
--. )elative Addressing
-. Implied Addressing
7/24/2019 02 Addressing Modes
5/53
Addressing odes
6
8086Microprocessor
-. )egister Addressing
. Immediate Addressing
/. Direct Addressing
0. )egister Indirect Addressing
1. "ased Addressing
2. Indexed Addressing
3. "ased Index Addressing
4. 5tring Addressing
6. Direct I*+ port Addressing
-7. Indirect I*+ port Addressing
--. )elative Addressing
-. Implied Addressing
,he instruction will specif! the name of theregister which holds the data to be operated b!the instruction.
#xample'
+( CL8 DH
,he content of 49bit register DH is moved toanother 49bit register CL
:CL; :DH;
&roup I ' Addressing modes forregister and immediate data
7/24/2019 02 Addressing Modes
6/53
Addressing odes
7
8086Microprocessor
-. )egister Addressing
. Immediate Addressing
/. Direct Addressing
0. )egister Indirect Addressing
1. "ased Addressing
2. Indexed Addressing
3. "ased Index Addressing
4. 5tring Addressing
6. Direct I*+ port Addressing
-7. Indirect I*+ port Addressing
--. )elative Addressing
-. Implied Addressing
In immediate addressing mode8 an 49bit or -29bitdata is specified as part of the instruction
#xample'
+( DL8 74H
,he 49bit data :74H; given in the instruction is
moved to DL
:DL; 74H
+( A
7/24/2019 02 Addressing Modes
7/53
Addressing odes ' emor! Access
9
8086Microprocessor
7 Address lines 4742 can address up to7> - b!tes of memor!
However8 the largest register is onl! -2 bits
Ph!sical Address will have to be calculatedPh!sical Address ' Actual address of a b!te inmemor!. i.e. the value which goes out onto theaddress bus.
emor! Address represented in the form ?5eg ' +ffset :#g 9 46A"'=7-;
#ach time the processor wants to accessmemor!8 it takes the contents of a segmentregister8 shifts it one hexadecimal place to the
left :same as multipl!ing b! -2-7;8 then add there@uired offset to form the 79 bit address
46A" ' =7- 46A" 46A"7 :Paragraph to b!te 46A" x -7 > 46A"7; =7- 7=7- :+ffset is alread! in b!te unit; 9999999 64AC :,he absolute address;
16 bytes ofcontiguous memory
7/24/2019 02 Addressing Modes
8/53
Addressing odes
11
8086Microprocessor
-. )egister Addressing
. Immediate Addressing
/. Direct Addressing
0. )egister Indirect Addressing
1. "ased Addressing
2. Indexed Addressing
3. "ased Index Addressing
4. 5tring Addressing
6. Direct I*+ port Addressing
-7. Indirect I*+ port Addressing
--. )elative Addressing
-. Implied Addressing
Here8 the effective address of the memor!location at which the data operand is stored isgiven in the instruction.
,he effective address is Bust a -29bit numberwritten directl! in the instruction.
#xample'
+( "
7/24/2019 02 Addressing Modes
9/53
Addressing odes
12
8086Microprocessor
-. )egister Addressing
. Immediate Addressing
/. Direct Addressing
0. )egister Indirect Addressing
1. "ased Addressing
2. Indexed Addressing
3. "ased Index Addressing
4. 5tring Addressing
6. Direct I*+ port Addressing
-7. Indirect I*+ port Addressing
--. )elative Addressing
-. Implied Addressing
In )egister indirect addressing8 name of theregister which holds the effective address :#A;will be specified in the instruction.
)egisters used to hold #A are an! of the followingregisters'
"
7/24/2019 02 Addressing Modes
10/53
Addressing odes
13
8086Microprocessor
-. )egister Addressing
. Immediate Addressing
/. Direct Addressing
0. )egister Indirect Addressing
1. "ased Addressing
2. Indexed Addressing
3. "ased Index Addressing
4. 5tring Addressing
6. Direct I*+ port Addressing
-7. Indirect I*+ port Addressing
--. )elative Addressing
-. Implied Addressing
In "ased Addressing8 "< or "P is used to hold thebase value for effective address and a signed 49bitor unsigned -29bit displacement will be specified
in the instruction.
In case of 49bit displacement8 it is sign extendedto -29bit before adding to the base value.
Ehen "< holds the base value of #A8 79bitph!sical address is calculated from "< and D5.
Ehen "P holds the base value of #A8 "P and 55 isused.
#xample'
+( A
7/24/2019 02 Addressing Modes
11/53
Addressing odes
14
8086Microprocessor
-. )egister Addressing
. Immediate Addressing
/. Direct Addressing
0. )egister Indirect Addressing
1. "ased Addressing
2. Indexed Addressing
3. "ased Index Addressing
4. 5tring Addressing
6. Direct I*+ port Addressing
-7. Indirect I*+ port Addressing
--. )elative Addressing
-. Implied Addressing
5I or DI register is used to hold an index value formemor! data and a signed 49bit or unsigned -29bit displacement will be specified in the
instruction.
Displacement is added to the index value in 5I orDI register to obtain the #A.
In case of 49bit displacement8 it is sign extendedto -29bit before adding to the base value.
#xample'
+( C
7/24/2019 02 Addressing Modes
12/53
Addressing odes
15
8086Microprocessor
-. )egister Addressing
. Immediate Addressing
/. Direct Addressing
0. )egister Indirect Addressing
1. "ased Addressing
2. Indexed Addressing
3. "ased Index Addressing
4. 5tring Addressing
6. Direct I*+ port Addressing
-7. Indirect I*+ port Addressing
--. )elative Addressing
-. Implied Addressing
In "ased Index Addressing8 the effective addressis computed from the sum of a base register :" :5I; "A > :D5; x -2-7 A > "A #A
Calculation of destination memor! location'#A#> :DI; "A# > :#5; x -2-7 A#> "A# #A#
:A#; :A;
If D= > -8 then :5I; :5I; ? - and :DI; > :DI; 9 -If D= > 78 then :5I; :5I; - and :DI; > :DI; -
&roup II ' Addressing modesfor memor! data
Note : ffecti!e address oft"e #tra segment register
7/24/2019 02 Addressing Modes
14/53
Addressing odes8086
Microprocessor
-. )egister Addressing
. Immediate Addressing
/. Direct Addressing
0. )egister Indirect Addressing
1. "ased Addressing
2. Indexed Addressing
3. "ased Index Addressing
4. 5tring Addressing
6. Direct I*+ port Addressing
-7. Indirect I*+ port Addressing
--. )elative Addressing
-. Implied Addressing
,hese addressing modes are used to access datafrom standard I*+ mapped devices or ports.
In direct port addressing mode8 an 49bit portaddress is directl! specified in the instruction.
#xample' IG AL8 76H
+perations' P+),addr> 76H :AL; :P+),;
Content of port with address 76His
moved to AL register
In indirect port addressing mode8 the instructionwill specif! the name of the register which holdsthe port address. In 47428 the -29bit port addressis stored in the D< register.
#xample' +, D
7/24/2019 02 Addressing Modes
15/53
Addressing odes
1$
8086Microprocessor
-. )egister Addressing
. Immediate Addressing
/. Direct Addressing
0. )egister Indirect Addressing
1. "ased Addressing
2. Indexed Addressing
3. "ased Index Addressing
4. 5tring Addressing
6. Direct I*+ port Addressing
-7. Indirect I*+ port Addressing
--. )elative Addressing
-. Implied Addressing
In this addressing mode8 the effective address ofa program instruction is specified relative toInstruction Pointer :IP; b! an 49bit signeddisplacement.
#xample' J 7AH
+perations'
777AH 7AH :sign extend;
If J= > -8 then
#A > :IP; 777AH
"A > :C5; x -2-7A > "A #A
If J= > -8 then the program control Bumps tonew address calculated above.
If J= > 78 then next instruction of theprogram is executed.
&roup I( ' )elativeAddressing mode
7/24/2019 02 Addressing Modes
16/53
Addressing odes
19
8086Microprocessor
-. )egister Addressing
. Immediate Addressing
/. Direct Addressing
0. )egister Indirect Addressing
1. "ased Addressing
2. Indexed Addressing
3. "ased Index Addressing
4. 5tring Addressing
6. Direct I*+ port Addressing
-7. Indirect I*+ port Addressing
--. )elative Addressing
-. Implied Addressing
Instructions using this mode have no operands.
,he instruction itself will specif! the data to beoperated b! the instruction.
#xample' CLC
,his clears the carr! flag to Kero.
&roup I( ' ImpliedAddressing mode
7/24/2019 02 Addressing Modes
17/53
INSTRUCTION SET
7/24/2019 02 Addressing Modes
18/53
-. Data ,ransfer Instructions
. Arithmetic Instructions
/. Logical Instructions
0. 5tring manipulation Instructions
1. Process Control Instructions
2. Control ,ransfer Instructions
Instruction 5et
21
8086Microprocessor
4742 supports 2 t!pes of instructions.
7/24/2019 02 Addressing Modes
19/53
-. Data ,ransfer Instructions
Instruction 5et
22
8086Microprocessor
Instructions that are used to transfer data* address in toregisters8 memor! locations and I*+ ports.
&enerall! involve two operands' 5ource operand andDestination operand of the same siKe.
5ource' )egister or a memor! location or an immediate dataDestination' )egister or a memor! location.
,he siKe should be a either a b!te or a word.
A 49bit data can onl! be moved to 49bit register* memor!and a -29bit data can be moved to -29bit register* memor!.
7/24/2019 02 Addressing Modes
20/53
-. Data ,ransfer Instructions
Instruction 5et
23
8086Microprocessor
nemonics' +(8
7/24/2019 02 Addressing Modes
21/53
-. Data ,ransfer Instructions
Instruction 5et
24
8086Microprocessor
nemonics' +(8 :55; x -2-7 5P
:A 5M A 5 -; :reg-2;
:5P; :5P; ?
A 5 > :55; x -2-7 5P
:A 5M A 5 -; :mem;
P+P reg-2* mem
P+P reg-2
P+P mem
A 5 > :55; x -2-7 5P
:reg-2; :A 5M A 5 -;
:5P; :5P;
A 5 > :55; x -2-7 5P
:mem; :A5M A
5 -;
:5P; :5P;
8086
7/24/2019 02 Addressing Modes
22/53
-. Data ,ransfer Instructions
Instruction 5et
25
8086Microprocessor
nemonics' +(8
7/24/2019 02 Addressing Modes
23/53
. Arithmetic Instructions
Instruction 5et
26
8086Microprocessor
nemonics' ADD8 ADC8 5"8 5""8 IGC8 D#C8 L8 DI(8 CP
ADD reg* mem8 reg-*mem
ADC reg8 reg-
ADC reg8 mem
ADC mem8 reg-
:reg; :reg-; :reg;
:reg; :reg; :mem;
:mem; :mem;:reg-;
ADD reg*mem8 data
ADD reg8 data
ADD mem8 data:reg; :reg; data
:mem; :mem;data
ADD A8 data
ADD AL8 data4ADD A
7/24/2019 02 Addressing Modes
24/53
. Arithmetic Instructions
Instruction 5et
27
8086Microprocessor
nemonics' ADD8 ADC8 5"8 5""8 IGC8 D#C8 L8 DI(8 CP
ADC reg* mem8 reg-*mem
ADC reg8 reg-
ADC reg8 mem
ADC mem8 reg-
:reg; :reg-; :reg;C=
:reg; :reg; :mem;C=
:mem; :mem;:reg-;C=
ADC reg*mem8 data
ADC reg8 dataADC mem8 data
:reg; :reg; dataC=
:mem; :mem;dataC=
ADDC A8 data
ADD AL8 data4
ADD A
7/24/2019 02 Addressing Modes
25/53
. Arithmetic Instructions
Instruction 5et
2$
8086Microprocessor
nemonics' ADD8 ADC8 5"8 5""8 IGC8 D#C8 L8 DI(8 CP
5" reg* mem8 reg-*mem
5" reg8 reg-
5" reg8 mem
5" mem8 reg-
:reg; :reg-; 9 :reg;
:reg; :reg; 9 :mem;
:mem; :mem; 9 :reg-;
5" reg*mem8 data
5" reg8 data
5" mem8 data:reg; :reg; 9 data
:mem; :mem; 9 data
5" A8 data
5" AL8 data45" A
7/24/2019 02 Addressing Modes
26/53
. Arithmetic Instructions
Instruction 5et
29
8086Microprocessor
nemonics' ADD8 ADC8 5"8 5""8 IGC8 D#C8 L8 DI(8 CP
5"" reg* mem8 reg-*mem
5"" reg8 reg-
5"" reg8 mem
5"" mem8 reg-
:reg; :reg-; 9 :reg; 9 C=
:reg; :reg; 9 :mem;9 C=
:mem; :mem; 9 :reg-; ?C=
5"" reg*mem8 data
5"" reg8 data5"" mem8 data
:reg; :reg; ? data 9 C=
:mem; :mem; 9 data 9 C=
5"" A8 data
5"" AL8 data4
5"" A
7/24/2019 02 Addressing Modes
27/53
. Arithmetic Instructions
Instruction 5et
3%
8086Microprocessor
nemonics' ADD8 ADC8 5"8 5""8 IGC8 D#C8 L8 DI(8 CP
IGC reg* mem
IGC reg4
IGC reg-2
IGC mem
:reg4; :reg4; -
:reg-2; :reg-2; -
:mem; :mem; -
D#C reg* mem
D#C reg4
D#C reg-2
D#C mem
:reg4; :reg4; 9 -
:reg-2; :reg-2; 9 -
:mem; :mem; 9 -
8086
7/24/2019 02 Addressing Modes
28/53
. Arithmetic Instructions
Instruction 5et
31
8086Microprocessor
nemonics' ADD8 ADC8 5"8 5""8 IGC8 D#C8 L8 DI(8 CP
L reg* mem
L reg
L mem
=or b!te ' :A
7/24/2019 02 Addressing Modes
29/53
. Arithmetic Instructions
Instruction 5et
32
8086Microprocessor
nemonics' ADD8 ADC8 5"8 5""8 IGC8 D#C8 L8 DI(8 CP
DI( reg* mem
DI( reg
DI( mem
=or -29bit '9 49bit '
:AL; :A
7/24/2019 02 Addressing Modes
30/53
. Arithmetic Instructions
Instruction 5et
33
8086Microprocessor
nemonics' ADD8 ADC8 5"8 5""8 IGC8 D#C8 L8 DI(8 CP
IDI( reg* mem
IDI( reg
IDI( mem
=or -29bit '9 49bit '
:AL; :A
7/24/2019 02 Addressing Modes
31/53
. Arithmetic Instructions
Instruction 5et
34
8086Microprocessor
nemonics' ADD8 ADC8 5"8 5""8 IGC8 D#C8 L8 DI(8 CP
CP reg*mem8 reg-* mem
CP reg8 reg-
CP reg8 mem
CP mem8 reg-
odif! flags :reg; ? :reg-;
If :reg; O :reg-; then C=>78 J=>78 5=>7
If :reg; :reg-; then C=>-8 J=>78 5=>-If :reg; > :reg-; then C=>78 J=>-8 5=>7
odif! flags :reg; ? :mem;
If :reg; O :mem; then C=>78 J=>78 5=>7If :reg; :mem; then C=>-8 J=>78 5=>-
If :reg; > :mem; then C=>78 J=>-8 5=>7
odif! flags :mem; ? :reg-;
If :mem; O :reg-; then C=>78 J=>78 5=>7
If :mem; :reg-; then C=>-8 J=>78 5=>-
If :mem; > :reg-; then C=>78 J=>-8 5=>7
8086
7/24/2019 02 Addressing Modes
32/53
. Arithmetic Instructions
Instruction 5et
35
8086Microprocessor
nemonics' ADD8 ADC8 5"8 5""8 IGC8 D#C8 L8 DI(8 CP
CP reg*mem8 data
CP reg8 data
CP mem8 data
odif! flags :reg; ? :data;
If :reg; O data then C=>78 J=>78 5=>7
If :reg; data then C=>-8 J=>78 5=>-If :reg; > data then C=>78 J=>-8 5=>7
odif! flags :mem; ? :mem;
If :mem; O data then C=>78 J=>78 5=>7
If :mem; data then C=>-8 J=>78 5=>-
If :mem; > data then C=>78 J=>-8 5=>7
8086
7/24/2019 02 Addressing Modes
33/53
. Arithmetic Instructions
Instruction 5et
36
8086Microprocessor
nemonics' ADD8 ADC8 5"8 5""8 IGC8 D#C8 L8 DI(8 CP
CP A8 data
CP AL8 data4
CP A78 J=>78 5=>7
If :AL; data4 then C=>-8 J=>78 5=>-If :AL; > data4 then C=>78 J=>-8 5=>7
odif! flags :A78 5=>7
If :mem; data-2 then C=>-8 J=>78 5=>-
If :mem; > data-2 then C=>78 J=>-8 5=>7
i 58086
7/24/2019 02 Addressing Modes
34/53
/. Logical Instructions
Instruction 5et
37
8086Microprocessor
nemonics' AGD8 +)8
7/24/2019 02 Addressing Modes
35/53
/. Logical Instructions
Instruction 5et
3$
8086Microprocessor
nemonics' AGD8 +)8
7/24/2019 02 Addressing Modes
36/53
/. Logical Instructions
Instruction 5et
39
8086Microprocessor
nemonics' AGD8 +)8
7/24/2019 02 Addressing Modes
37/53
/. Logical Instructions
Instruction 5et
4%
8086Microprocessor
nemonics' AGD8 +)8
7/24/2019 02 Addressing Modes
38/53
/. Logical Instructions
Instruction 5et
41
8086Microprocessor
nemonics' AGD8 +)8
7/24/2019 02 Addressing Modes
39/53
/. Logical Instructions
Instruction 5et
42
8086Microprocessor
nemonics' AGD8 +)8
7/24/2019 02 Addressing Modes
40/53
/. Logical Instructions
Instruction 5et
43
Microprocessor
nemonics' AGD8 +)8
7/24/2019 02 Addressing Modes
41/53
/. Logical Instructions
Instruction 5et
44
Microprocessor
nemonics' AGD8 +)8
7/24/2019 02 Addressing Modes
42/53
0. 5tring anipulation Instructions
Instruction 5et
45
Microprocessor
5tring ' 5e@uence of b!tes or words
4742 instruction set includes instruction for string movement8 comparison8scan8 load and store.
)#P instruction prefix ' used to repeat execution of string instructions
5tring instructions end with 5or 5"or 5E.5represents string8 5"string b!te and 5Estring word.
+ffset or effective address of the source operand is stored in 5Iregister andthat of the destination operand is stored in DIregister.
Depending on the status of D=8 5Iand DIregisters are automaticall!updated.
D= > 7 5I and DI are incremented b! - for b!te and for word.
D= > - 5I and DI are decremented b! - for b!te and for word.
Instruction 5et8086
7/24/2019 02 Addressing Modes
43/53
0. 5tring anipulation Instructions
Instruction 5et
46
Microprocessor
nemonics' )#P8 +(58 CP58 5CA58 L+D58 5,+5
)#P
)#PJ* )#P#
:)epeat CP5 or 5CA5 untilJ= > 7;
)#PGJ* )#PG#
:)epeat CP5 or 5CA5 until
J= > -;
Ehile C< 7 and J= > -8 repeat execution of
string instruction and
:C
7/24/2019 02 Addressing Modes
44/53
0. 5tring anipulation Instructions
Instruction 5et
47
Microprocessor
nemonics' )#P8 +(58 CP58 5CA58 L+D58 5,+5
+(5
+(5"
+(5E
A > :D5; x -2-7 :5I;
A#> :#5; x -2-7 :DI;
:A#; :A;
If D= > 78 then :DI; :DI; -M :5I; :5I;
-
If D= > -8 then :DI; :DI; 9 -M :5I; :5I; 9 -
A > :D5; x -2-7 :5I;
A#> :#5; x -2-7 :DI;
:A#M A# -; :AM A -;
If D= > 78 then :DI; :DI; M :5I; :5I;
> 9 9
Instruction 5et8086
7/24/2019 02 Addressing Modes
45/53
0. 5tring anipulation Instructions
Instruction 5et
4$
Microprocessor
nemonics' )#P8 +(58 CP58 5CA58 L+D58 5,+5
CP5
CP5"
CP5E
A > :D5; x -2-7 :5I;
A#> :#5; x -2-7 :DI;
odif! flags :A; 9 :A#;
If :A; O :A#;8 then C= > 7M J= > 7M 5= > 7
If :A; :A#;8 then C= > -M J= > 7M 5= > -
If :A; > :A#;8 then C= > 7M J= > -M 5= > 7
=or b!te operation
If D= > 78 then :DI; :DI; -M :5I; :5I;
-
If D= > -8 then :DI; :DI; 9 -M :5I; :5I; 9 -
=or word operation
If D= > 78 then :DI; :DI; M :5I; :5I;
> 9 9
Compare two string b!te or string word
Instruction 5et8086
7/24/2019 02 Addressing Modes
46/53
0. 5tring anipulation Instructions
Instruction 5et
49
Microprocessor
nemonics' )#P8 +(58 CP58 5CA58 L+D58 5,+5
5CA5
5CA5"
5CA5E
A#> :#5; x -2-7 :DI;
odif! flags :AL; 9 :A#;
If :AL; O :A#;8 then C= > 7M J= > 7M 5= > 7If :AL; :A#;8 then C= > -M J= > 7M 5= > -
If :AL; > :A#;8 then C= > 7M J= > -M 5= > 7
If D= > 78 then :DI; :DI; -
If D= > -8 then :DI; :DI; ? -
A#> :#5; x -2-7 :DI;
odif! flags :AL; 9 :A#;
If :A 7M J= > 7M 5= > 7
If :A -M J= > 7M 5= > -
If :A :A#
M A#
-;8 then C= > 7M J= > -M 5= > 7
5can :compare; a string b!te or word with accumulator
Instruction 5et8086
7/24/2019 02 Addressing Modes
47/53
0. 5tring anipulation Instructions
Instruction 5et
5%
Microprocessor
nemonics' )#P8 +(58 CP58 5CA58 L+D58 5,+5
L+D5
L+D5"
L+D5E
A > :D5; x -2-7 :5I;
:AL; :A;
If D= > 78 then :5I; :5I; -
If D= > -8 then :5I; :5I; ? -
A > :D5; x -2-7 :5I;
:A 78 then :5I; :5I;
If D= > -8 then :5I; :5I; ?
Load string b!te in to AL or string word in to A