8086 UNIT-2

85
7/23/2019 8086 UNIT-2 http://slidepdf.com/reader/full/8086-unit-2 1/85 Architecture of 8086 Microprocessor Architecture of 8086 Microprocessor 

Transcript of 8086 UNIT-2

Page 1: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 1/85

Architecture of 8086 Microprocessor Architecture of 8086 Microprocessor 

Page 2: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 2/85

Architecture of 8086 Microprocessor Architecture of 8086 Microprocessor 

Architecture is divided into two PartsArchitecture is divided into two Parts

Bus Interface Unit (BIU)Bus Interface Unit (BIU)

Execution Unit (EU)Execution Unit (EU)

BIUBIU

o Contains the circuit for phsica! address ca!cu!ations and aContains the circuit for phsica! address ca!cu!ations and a

 predecodin" instruction #te $ueue (6 #tes !on") predecodin" instruction #te $ueue (6 #tes !on")

o Ma%es the sste&'s #us avai!a#!e for externa! interfacin" ofMa%es the sste&'s #us avai!a#!e for externa! interfacin" of

devicesdevices

o BIU has a separate adder to perfor& the procedure forBIU has a separate adder to perfor& the procedure for

o#tainin" a phsica! address whi!e addressin" &e&oro#tainin" a phsica! address whi!e addressin" &e&or

o Incase of 808 once the opcode is fetched and decodedIncase of 808 once the opcode is fetched and decoded

the externa! #us re&ains free for so&e ti&e whi!e thethe externa! #us re&ains free for so&e ti&e whi!e the

 processor interna!! executes the instruction* +he ti&es!ot processor interna!! executes the instruction* +he ti&es!ot

is used in 8086 to achieve the over!apped fetch andis used in 8086 to achieve the over!apped fetch and

execution cc!esexecution cc!es

Page 3: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 3/85

Architecture of 8086Architecture of 8086o ,hi!e the BIU fetches the opcode Execution unit executes,hi!e the BIU fetches the opcode Execution unit executes

the previous! decoded instruction concurrent!the previous! decoded instruction concurrent!

BIU a!on" with EU for&s a pipe!ineBIU a!on" with EU for&s a pipe!ine

BIU &ana"es the co&p!ete interface of EU with &e&orBIU &ana"es the co&p!ete interface of EU with &e&or

and I-. devices under the contro! of ti&in" and contro! unitand I-. devices under the contro! of ti&in" and contro! unit

Execution Unit (EU)Execution Unit (EU)

Contains the re"ister set of 8086 except se"&ent re"istersContains the re"ister set of 8086 except se"&ent re"isters

and IP*and IP*

/as a 6 #it A1U to perfor& arith&etic and !o"ica!/as a 6 #it A1U to perfor& arith&etic and !o"ica!

operationsoperations

6 #it f!a" ref!ects the resu!ts of execution # A1U6 #it f!a" ref!ects the resu!ts of execution # A1U

2ecodin" unit decodes the opcode #tes issued fro&2ecodin" unit decodes the opcode #tes issued fro&

instruction #te $ueueinstruction #te $ueue

+i&in" and Contro! unit derives the necessar contro!+i&in" and Contro! unit derives the necessar contro!si"na!s to execute the instruction opcodesi"na!s to execute the instruction opcode

Page 4: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 4/85

3E4I5+E3 .34AI5A+I.3E4I5+E3 .34AI5A+I.

7 +PE5 .9 6 BI+ 3E4I5+E357 +PE5 .9 6 BI+ 3E4I5+E35

4EE3A1 PU3P.5E 3E4I5+E35 (8 #it)4EE3A1 PU3P.5E 3E4I5+E35 (8 #it) /.125 2A+A :A3IAB1E5 A2 +EMP.3A3 2A+A/.125 2A+A :A3IAB1E5 A2 +EMP.3A3 2A+A

5PECIA1 9UC+I. 3E4I5+E355PECIA1 9UC+I. 3E4I5+E35

CA+E4.3I;E2 A5 9.U3 +PE5CA+E4.3I;E2 A5 9.U3 +PE5

U5E2 A5 5E4ME+ 3E4I5+E35 P.I+E35U5E2 A5 5E4ME+ 3E4I5+E35 P.I+E35

I2E< 3E4I5+E35 or .995E+ 5+.3A4EI2E< 3E4I5+E35 or .995E+ 5+.3A4E

3E4I5+E353E4I5+E35

Page 5: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 5/85

3e"isters of 80863e"isters of 8086

Page 6: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 6/85

4EE3A1 2A+A 3E4I5+E354EE3A1 2A+A 3E4I5+E35

A<A<

B<B<

C<C<

2<2<

A< = 6 BI+ ACCUMU1A+.3 3E4I5+E3 A< = 6 BI+ ACCUMU1A+.3 3E4I5+E3 

A/ = 8 BI+5 > A1 = 8 BI+5 > 1 = 1.,E3 > / ? /I4/E3 A/ = 8 BI+5 > A1 = 8 BI+5 > 1 = 1.,E3 > / ? /I4/E3 B< = U5E2 A5 .995E+ 5+.3A4E 9.3 9.3MI4B< = U5E2 A5 .995E+ 5+.3A4E 9.3 9.3MI4

P/5ICA1 A223E55E5 I CA5E .9 5.ME AM'5P/5ICA1 A223E55E5 I CA5E .9 5.ME AM'5

C< = C.U+E3 (9.3 1..P @ 5+3I4 .PE3A+I.5)C< = C.U+E3 (9.3 1..P @ 5+3I4 .PE3A+I.5)

2< = IMP1ICI+ .PE3A2 - 2E5+IA+I.2< = IMP1ICI+ .PE3A2 - 2E5+IA+I.

 AH AH   AL AL

BHBH   BLBL

CHCH   CLCL

DHDH   DLDL

Page 7: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 7/85

Page 8: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 8/85

5e"&ent 3e"isters5e"&ent 3e"isters

Phsica! Address is divided into two partsPhsica! Address is divided into two parts

5e"&ent Address5e"&ent Address = Contains 6 #it se"&ent #ase addresses = Contains 6 #it se"&ent #ase addresses

re!ated to different se"&entsre!ated to different se"&ents

.ffset.ffset = An of the pointers and index re"isters or B< &a = An of the pointers and index re"isters or B< &acontain the offset of the !ocation to #e addressedcontain the offset of the !ocation to #e addressed

Advanta"e of havin" this is that instead of havin" a 70 #itAdvanta"e of havin" this is that instead of havin" a 70 #it

re"ister for phsica! address the processor ust &aintains twore"ister for phsica! address the processor ust &aintains two

6 #it re"isters which are within the word !en"th capacit of6 #it re"isters which are within the word !en"th capacit of

the &achinethe &achine

Page 9: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 9/85

Pointers and Index 3e"istersPointers and Index 3e"isters

Pointers contain offset within the particu!ar se"&entsPointers contain offset within the particu!ar se"&ents

Pointers IP BP and 5P usua!! contain offsets within the codePointers IP BP and 5P usua!! contain offsets within the code

(DP) and stac% (BP @ 5P) se"&ents(DP) and stac% (BP @ 5P) se"&ents

Index re"isters are used as "enera! purpose re"isters as we!!Index re"isters are used as "enera! purpose re"isters as we!!for offset stora"e in case of indexed #ased indexed andfor offset stora"e in case of indexed #ased indexed and

re!ative #ased indexed addressin" &odes*re!ative #ased indexed addressin" &odes*

3e"ister 5I is used to store the offset of source data in data3e"ister 5I is used to store the offset of source data in data

se"&entse"&ent

3e"ister 2I is used to store the offset of destination in data or3e"ister 2I is used to store the offset of destination in data or

extra se"&entextra se"&ent

Index re"isters are used for strin" &anipu!ationsIndex re"isters are used for strin" &anipu!ations

Page 10: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 10/85

FLAG REGISTER OF 8086FLAG REGISTER OF 8086

Page 11: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 11/85

9unctions of 8086 9!a"s9unctions of 8086 9!a"s

Carry Flag (CF)Carry Flag (CF) ? this f!a" is set to? this f!a" is set to 11 when there is anwhen there is an unsignedunsigned

overlo!overlo!

* 9or exa&p!e when ou add #tes* 9or exa&p!e when ou add #tes

"## $ 1"## $ 1

 (resu!t is not in(resu!t is not in

ran"e 0***7)* ,hen there is no overf!ow this f!a" is set toran"e 0***7)* ,hen there is no overf!ow this f!a" is set to 00**

%ari&y Flag (%F)%ari&y Flag (%F) ? this f!a" is set to? this f!a" is set to 11 when there is even nu&#er ofwhen there is even nu&#er ofone #its in resu!t and toone #its in resu!t and to 00 when there is odd nu&#er of one #its*when there is odd nu&#er of one #its*

Au'iliary Flag (AF)Au'iliary Flag (AF) ? set to? set to 11 when there is anwhen there is an unsigned overlo!unsigned overlo! for !ow ni##!e ( #its)*for !ow ni##!e ( #its)*

ero Flag (F)ero Flag (F) ? set to? set to 11 when resu!t iswhen resu!t is eroero* 9or non?ero resu!t* 9or non?ero resu!t

this f!a" is set tothis f!a" is set to 00**

Sign Flag (SF)Sign Flag (SF) ? set to? set to 11 when resu!t iswhen resu!t is nega&ivenega&ive* ,hen resu!t is* ,hen resu!t is*osi&ive*osi&ive it is set toit is set to 00* (+his f!a" ta%es the va!ue of the &ost* (+his f!a" ta%es the va!ue of the &ostsi"nificant #it*)si"nificant #it*)

Page 12: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 12/85

9unctions of 8086 9!a"s9unctions of 8086 9!a"s

Tra* Flag (TF)Tra* Flag (TF) ? Used for on?chip de#u""in"*? Used for on?chip de#u""in"*

In&erru*& ena+le Flag (IF)In&erru*& ena+le Flag (IF) ? when this f!a" is set to? when this f!a" is set to 11 CPUCPUreacts to interrupts fro& externa! devices*reacts to interrupts fro& externa! devices*

,ire-&ion Flag (,F),ire-&ion Flag (,F) ? this f!a" is used # so&e instructions to? this f!a" is used # so&e instructions to process data chains when this f!a" is set to process data chains when this f!a" is set to 00 ? the processin"? the processin"is done forward when this f!a" is set tois done forward when this f!a" is set to 11 the processin" isthe processin" isdone #ac%ward*done #ac%ward*

Overlo! Flag (OF)Overlo! Flag (OF) ? set to? set to 11 when there is awhen there is a signedsignedoverlo!overlo!* 9or exa&p!e when ou add #tes* 9or exa&p!e when ou add #tes 100 $ #0100 $ #0 (resu!t(resu!tis not in ran"e ?78***7F)*is not in ran"e ?78***7F)*

Page 13: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 13/85

A,,RESSI.G /O,ES OF 8086A,,RESSI.G /O,ES OF 8086

I&&ediate Addressin" ModeI&&ediate Addressin" Mode 2irect Addressin" Mode2irect Addressin" Mode 3e"ister Addressin" Mode3e"ister Addressin" Mode 3e"ister Indirect Mode3e"ister Indirect Mode

Indexed Addressin" ModeIndexed Addressin" Mode 3e"ister 3e!ative Addressin" Mode3e"ister 3e!ative Addressin" Mode Based Indexed Addressin" ModeBased Indexed Addressin" Mode 3e!ative Based Indexed Addressin" Mode3e!ative Based Indexed Addressin" Mode

Intrase"&ent 2irect ModeIntrase"&ent 2irect Mode Intrase"&ent Indirect ModeIntrase"&ent Indirect Mode Interse"&ent 2irect Addressin" ModeInterse"&ent 2irect Addressin" Mode Interse"&ent Indirect Addressin" ModeInterse"&ent Indirect Addressin" Mode

Page 14: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 14/85

Addressin" Modes of 8086Addressin" Modes of 8086

I&&ediate Addressin" ModeI&&ediate Addressin" Mode

I&&ediate data is a part of instruction and appears in the for&I&&ediate data is a part of instruction and appears in the for&of successive #te or #tesof successive #te or #tes

ExGExG M.: A< 000/M.: A< 000/

2irect Addressin" Mode2irect Addressin" Mode6 #it &e&or address (.ffset) is direct! specified in the6 #it &e&or address (.ffset) is direct! specified in theinstruction as a part of itinstruction as a part of it

ExGExG M.: A<H000/M.: A<H000/ 3e"ister Addressin" Mode3e"ister Addressin" Mode

2ata is stored in a re"ister and it is referred usin" the2ata is stored in a re"ister and it is referred usin" the particu!ar re"ister  particu!ar re"ister 

ExG M.: B<A<ExG M.: B<A<

Page 15: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 15/85

Addressin" Modes of 8086Addressin" Modes of 8086 3e"ister Indirect Addressin" Mode3e"ister Indirect Addressin" Mode

+he offset address of data is in either B< or 5I or 2I re"ister +he offset address of data is in either B< or 5I or 2I re"ister 

2efau!t se"&ent is either 25 or E52efau!t se"&ent is either 25 or E5 E<GE<G M.: A<HB<M.: A<HB<

Indexed Addressin" ModeIndexed Addressin" Mode

.ffset of the operand is stored in one of Index re"ister .ffset of the operand is stored in one of Index re"ister 

25 is defau!t se"&ent for index re"isters 5I and 2I25 is defau!t se"&ent for index re"isters 5I and 2I 9or 5trin"s 25 and E5 are defau!t se"&ents for 5I and 2I9or 5trin"s 25 and E5 are defau!t se"&ents for 5I and 2I

E<GE<G M.: A< H5IM.: A< H5I

3e"ister 3e!ative Addressin" Mode3e"ister 3e!ative Addressin" Mode

2ata is avai!a#!e at an effective address for&ed # addin" an 82ata is avai!a#!e at an effective address for&ed # addin" an 8 #it or 6 #it disp!ace&ent with the content of an one of the #it or 6 #it disp!ace&ent with the content of an one of the

re"isters B<BP5I and 2I in defau!t se"&entre"isters B<BP5I and 2I in defau!t se"&ent

E<GE<G A<0/HB<A<0/HB<

Page 16: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 16/85

Addressin" Modes of 8086Addressin" Modes of 8086

Based Indexed Addressin" 3e"ister Based Indexed Addressin" 3e"ister  Effective address of data is for&ed # addin" content ofEffective address of data is for&ed # addin" content of

 #ase re"ister to content of Index re"ister  #ase re"ister to content of Index re"ister  2efau!t se"&ent re"ister &a #e E5 or 252efau!t se"&ent re"ister &a #e E5 or 25 E<GE<G M.: A<HB<H5IM.: A<HB<H5I

3e!ative Based Indexed3e!ative Based Indexed Effective address is for&ed # addin" an 8 or 6 #itEffective address is for&ed # addin" an 8 or 6 #it

disp!ace&ent with the su& of contents of an one of #asedisp!ace&ent with the su& of contents of an one of #ase

re"isters (B< or BP) and an one of Index re"isters in are"isters (B< or BP) and an one of Index re"isters in adefau!t se"&entdefau!t se"&ent

E<GE<G M.: A<0/ HB< H5IM.: A<0/ HB< H5I

Page 17: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 17/85

Addressin" Modes of 8086Addressin" Modes of 8086

Intrase"&ent 2irect ModeIntrase"&ent 2irect Mode Effective address to which the contro! is to #e transferred isEffective address to which the contro! is to #e transferred is

"iven # the su& of 8 or 6 #it disp!ace&ent and current"iven # the su& of 8 or 6 #it disp!ace&ent and currentcontent of IPcontent of IP

E<G 9or DMP if si"ned disp!ace&ent is 8 #its it is ter&ed asE<G 9or DMP if si"ned disp!ace&ent is 8 #its it is ter&ed as

short u&p and if it is 6 #its it is ter&ed as 1on" u&pshort u&p and if it is 6 #its it is ter&ed as 1on" u&p Intrase"&ent Indirect ModeIntrase"&ent Indirect Mode

+he disp!ace&ent to which the contro! is to #e transferred+he disp!ace&ent to which the contro! is to #e transferredis in the sa&e se"&ent in which the contro! transferis in the sa&e se"&ent in which the contro! transferinstruction !ies #ut it is passed to the instruction indirect!instruction !ies #ut it is passed to the instruction indirect!

Used in Unconditiona! #ranch instructionsUsed in Unconditiona! #ranch instructions E<GE<G DMP HB<>DMP HB<>

Add i d fAdd i M d f 8086

Page 18: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 18/85

Addressin" Modes of 8086Addressin" Modes of 8086 Interse"&ent 2irect Addressin" ModeInterse"&ent 2irect Addressin" Mode

Address to which the contro! is to #e transferred is in aAddress to which the contro! is to #e transferred is in a

different se"&entdifferent se"&ent

C5 and IP of the destination address are specified direct!C5 and IP of the destination address are specified direct!in the instructionin the instruction

E<GE<G DPM 000/ G 7000/DPM 000/ G 7000/

Interse"&ent Indirect Addressin" ModeInterse"&ent Indirect Addressin" Mode Address to which the contro! is to #e transferred !ies in aAddress to which the contro! is to #e transferred !ies in a

different se"&ent and it is passed to the instructiondifferent se"&ent and it is passed to the instructionindirect!indirect!

Contents of &e&or #!oc% contains #tes (IP(15B)Contents of &e&or #!oc% contains #tes (IP(15B)

IP(M5B) C5(15B) C5(M5B))IP(M5B) C5(15B) C5(M5B)) 5tartin" address of the &e&or #!oc% &a #e referred5tartin" address of the &e&or #!oc% &a #e referred

usin" an of the addressin" &odes except i&&ediate &odeusin" an of the addressin" &odes except i&&ediate &ode E<GE<G DMP H7000/DMP H7000/

Page 19: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 19/85

8086 /i-ro*ro-essor8086 /i-ro*ro-essor

Ins&ru-&ion Se& o 8086Ins&ru-&ion Se& o 8086

Page 20: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 20/85

S&ru-&ure o an Asse+ly Language %rograS&ru-&ure o an Asse+ly Language %rogra

*&ode! s&a!!*&ode! s&a!! > 5e!ect a &e&or &ode!> 5e!ect a &e&or &ode!

*stac% stac%Jsie*stac% stac%Jsie > 2efine the stac% sie> 2efine the stac% sie

*data*data

> :aria#!e and arra dec!arations> :aria#!e and arra dec!arations

> 2ec!are varia#!es at this !eve!> 2ec!are varia#!es at this !eve!

*code*code&ain proc&ain proc

> ,rite the pro"ra& &ain code here> ,rite the pro"ra& &ain code here

&ain endp&ain endp

>.ther Procedures>.ther Procedures

> A!was or"anie our pro"ra&> A!was or"anie our pro"ra&

> into procedures> into procedures

end &ainend &ain > +o &ar% the end of the source fi!e> +o &ar% the end of the source fi!e

Page 21: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 21/85

Simple Assembly Language ProgramSimple Assembly Language Program

/O,EL S/ALL/O,EL S/ALL

STAC2 63STAC2 63,ATA,ATA

,ATA1,ATA1 ,4 #"5,4 #"5

,ATA",ATA" ,4 "5,4 "5

S7/S7/ ,4 ,4

CO,ECO,E

/AI./AI. %ROC FAR %ROC FAR /O9 A:;<,ATA/O9 A:;<,ATA

/O9 ,S;A:/O9 ,S;A:

/O9 AL;,ATA1/O9 AL;,ATA1

/O9 4L;,ATA"/O9 4L;,ATA"

A,, AL;4LA,, AL;4L

/O9 S7/;AL/O9 S7/;AL/O9 A=;3C5/O9 A=;3C5

I.T "15I.T "15

/AI./AI. E.,%E.,%

E., /AI.E., /AI.

Page 22: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 22/85

Ti&le dire-&ive>Ti&le dire-&ive>

+he tit!e directive is optiona! and specifies the tit!e of the+he tit!e directive is optiona! and specifies the tit!e of the

 pro"ra&* 1i%e a co&&ent it has no effect on the pro"ra& pro"ra&* 1i%e a co&&ent it has no effect on the pro"ra&** 

T5e /odel dire-&ive>T5e /odel dire-&ive>

+he &ode! directive "ives infor&ation on how &uch &e&or+he &ode! directive "ives infor&ation on how &uch &e&or

the asse&#!er wou!d a!!ocate for the pro"ra&* +his depends onthe asse&#!er wou!d a!!ocate for the pro"ra&* +his depends on

the sie of the data and the sie of the pro"ra& or code*the sie of the data and the sie of the pro"ra& or code*

Page 23: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 23/85

Segen& dire-&ives>Segen& dire-&ives>

5e"&ents are dec!ared usin"5e"&ents are dec!ared usin" dire-&ivesdire-&ives* +he fo!!owin"* +he fo!!owin"directives are used to specif the fo!!owin" se"&entsGdirectives are used to specif the fo!!owin" se"&entsG

S&a-? Segen&>S&a-? Segen&>  *stac%*stac%

*stac% fo!!owed # a va!ue that indicates the sie of the stac%*stac% fo!!owed # a va!ue that indicates the sie of the stac%

5tac% addresses are co&puted as offsets into this se"&ent5tac% addresses are co&puted as offsets into this se"&ent

,a&a Segen&s>,a&a Segen&s> datadata

**data fo!!owed # dec!arations of varia#!es or definitions ofdata fo!!owed # dec!arations of varia#!es or definitions ofconstants*constants*

Used to set aside stora"e for varia#!es*Used to set aside stora"e for varia#!es*

Constants are defined within this se"&ent in the pro"ra&Constants are defined within this se"&ent in the pro"ra&source*source* 

Code Segen&>Code Segen&> codecode

+he code se"&ent contains executa#!e instructions and ca!!s to+he code se"&ent contains executa#!e instructions and ca!!s to*ro-edures*ro-edures** 

Page 24: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 24/85

Data Types and Data DefinitionData Types and Data Definition,ATA1,ATA1 ,4 "# @ ,e-,4 "# @ ,e-

,ATA",ATA" ,4 10001001+,4 10001001+,ATA,ATA ,4 1"5,4 1"5

ORG 00105ORG 00105

,ATA3,ATA3 ,4 B"#1,4 B"#1

ORG 00185ORG 00185,ATA#,ATA# ,4 ,4

T5is is 5o! da&a is ini&ialied in &5e da&a segen&T5is is 5o! da&a is ini&ialied in &5e da&a segen&

0000 10000 1

0001 80001 8000" 1"000" 1"

0010 " # 10010 " # 1

00180018

Page 25: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 25/85

MnemonicMnemonic   MeaningMeaning   FormatFormat   OperationOperation FlagsFlagsaffectedaffected

MovMov MoveMove Mov D,SMov D,S   (s) (D)(s) (D)   NoneNone

,a&a Transer Ins&ru-&ions D /O9,a&a Transer Ins&ru-&ions D /O9

,es&ina&ion,es&ina&ion Sour-eSour-e

/eory/eory A--uula&orA--uula&or

A--uula&orA--uula&or /eory/eory

Regis&erRegis&er Regis&erRegis&er

Regis&erRegis&er /eory/eory

/eory/eory Regis&erRegis&er

Regis&erRegis&er Iedia&eIedia&e

/eory/eory Iedia&eIedia&e

Seg regSeg reg Reg 16Reg 16

Seg regSeg reg /e 16/e 16

Reg 16Reg 16 Seg regSeg reg

/eory/eory Seg regSeg reg

.O /O9

Memmm

Seg !eg

Mem

Seg !eg

Seg reg

"#$ MO% AL, BL

Page 26: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 26/85

,a&a Transer Ins&ru-&ion D %7S=,a&a Transer Ins&ru-&ion D %7S=

%us5 !ord on&o s&a-? %us5 !ord on&o s&a-? 

 5ntaxG5ntaxG  push op6 push op6

op6G 6?#it re"ister or &e&orop6G 6?#it re"ister or &e&or

ActionG Push op6 onto the stac% ActionG Push op6 onto the stac%   (i*e* 5P K 5P ? 7(i*e* 5P K 5P ? 7then H55G5P K op6)*then H55G5P K op6)*

 9!a"s AffectedG one9!a"s AffectedG one

 otesG Pushin" and poppin" of 55 and 5P are a!!owed #ut otesG Pushin" and poppin" of 55 and 5P are a!!owed #ut

stron"! discoura"ed*stron"! discoura"ed*

Page 27: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 27/85

,a&a Transer Ins&ru-&ion D %O%,a&a Transer Ins&ru-&ion D %O%

%o* !ord ro s&a-? %o* !ord ro s&a-?  

5ntaxG pop op65ntaxG pop op6

re"6G 6?#it re"ister or &e&orre"6G 6?#it re"ister or &e&or

 ActionG Pop word off the stac% and p!ace it in op6 (i*e* op6ActionG Pop word off the stac% and p!ace it in op6 (i*e* op6K H55G5P then 5P K 5P L 7)*K H55G5P then 5P K 5P L 7)*

9!a"s AffectedG one9!a"s AffectedG one

 otesG Pushin" and poppin" of 55 and 5P are a!!owed #ut otesG Pushin" and poppin" of 55 and 5P are a!!owed #ut

stron"! discoura"ed*stron"! discoura"ed*

Page 28: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 28/85

,a&a Transer Ins&ru-&ions D :C=G,a&a Transer Ins&ru-&ions D :C=G

MnemonicMnemonic   MeaningMeaning   FormatFormat   OperationOperation Flags affectedFlags affected

#CH&#CH&   "'cange"'cange #CH& D,S#CH& D,S   (s) (D)(s) (D)   NoneNone

,es&ina&ion,es&ina&ion Sour-eSour-e

A--uula&orA--uula&or Reg 16Reg 16

/eory/eory Regis&erRegis&er

Regis&erRegis&er Regis&erRegis&er

Regis&erRegis&er /eory/eory

E'a*le> :C=G 1"35; 4:

NO #CH&M"Ms

S"& !"&s

Page 29: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 29/85

,a&a Transer Ins&ru-&ions LEA; L,S; LES,a&a Transer Ins&ru-&ions LEA; L,S; LES

MnemonicMnemonic   MeaningMeaning   FormatFormat   OperationOperation FlagsFlags

affectedaffectedL"AL"A   LoadLoad

"ffective"ffective Address Address

L"A !eg*,"AL"A !eg*,"A   "A (!eg*)"A (!eg*)   NoneNone

LDSLDS   LoadLoad!egister!egister

 And DS And DS

LDS !eg*,M"M+LDS !eg*,M"M+   (M"M+)(M"M+)(!eg*)(!eg*)

(Mem+-) (DS)(Mem+-) (DS)

NoneNone

L"SL"S   LoadLoad!egister!egister

and "Sand "S

L"S !eg*,M"M+L"S !eg*,M"M+   (M"M+)(M"M+)(!eg*)(!eg*)

(Mem+-) (DS)(Mem+-) (DS)

NoneNone

1EA 5I 2A+A  or M.: 5I .ffset 2A+A

Page 30: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 30/85

E'a*les or LEA; L,S; LESE'a*les or LEA; L,S; LES

1E5 si&i!ar to 125 except that it !oads E5

Page 31: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 31/85

E'a*les or LEA; L,S; LESE'a*les or LEA; L,S; LES

DA.A# D/ 000HDA.A# D/ 000H

DA.A1 D/ 2000HDA.A1 D/ 2000H 3COD"3COD" L"A S, DA.A#L"A S, DA.A# MO%" D, OFFS". DA.A14MO%" D, OFFS". DA.A14 .HS S MO!" "FFC"N..HS S MO!" "FFC"N.  L"A B#,5D64L"A B#,5D64 S .H" SAM" ASS .H" SAM" AS  MO% B#,D4MO% B#,D4 .HS 78S. .A9"S L"SS C1CL"S3.HS 78S. .A9"S L"SS C1CL"S3 L"A B#,D4L"A B#,D4 N%ALD:N%ALD:

L"S similar to LDS e'cept tat it loads "S

LDS BX, [DI];

1"HA1"HABX

10001000DI

000000 DS 

HAHA

1"1"

0000

00

 

!!!

!!

!!"

!!#

Page 32: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 32/85

T5e :LAT Ins&ru-&ionT5e :LAT Ins&ru-&ion

MnemonicMnemonic   MeaningMeaning   FormatFormat   OperationOperation   FlagsFlags

#LA.#LA.   .ranslate.ranslate   #LA.#LA.   ((AL)-(B#)-((AL)-(B#)-

(DS)0)(DS)0)

(AL)(AL)

NoneNone

Exa&p!eG Assu&e (25) K 000/ (B<)K000/ and

(A1)K02/

<1A+ rep!aces contents of A1 # contents of &e&or

!ocation withPAK(25)0 L(B<) L(A1)

  K 0000/ L 000/ L 02/ K 002/

+hus

(002/)

 (A1)

Page 33: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 33/85

Ari&5e&i- Ins&ru-&ionsAri&5e&i- Ins&ru-&ionsA,,; A,C; I.C; AAA; ,AAA,,; A,C; I.C; AAA; ,AA

If t$e sum is %&, A'

is in(remented by

;ac<ed BCD

Page 34: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 34/85

Ari&5e&i- Ins&ru-&ionsAri&5e&i- Ins&ru-&ionsA,,; A,C; I.C; AAA; ,AAA,,; A,C; I.C; AAA; ,AA

MnemonicMnemonic   MeaningMeaning   FormatFormat   OperationOperation FlagsFlagsaffectedaffected

 ADD ADD   Addition Addition  ADD D,S ADD D,S   (S)-(D) (D)(S)-(D) (D)

 carr= (CF)carr= (CF)

 ALL ALL

 ADC ADC   Add >it Add >itcarr=carr=

 ADC D,S ADC D,S   (S)-(D)-(CF) (D)(S)-(D)-(CF) (D)

 carr= (CF)carr= (CF)

 ALL ALL

NCNC   ncrementncrement?= one?= one

NC DNC D   (D)- (D)(D)- (D)  ALL ?@t C1 ALL ?@t C1

 AAA AAA   ASC ASCad@st forad@st foradditionaddition

 AAA AAA   f te s@m is , AHf te s@m is , AH

is incremented ?= is incremented ?=

 AF,CF AF,CF

DAADAA   DecimalDecimalad@st forad@st foradditionaddition

DAADAA   Ad@st AL for decimal Ad@st AL for decimal;ac<ed BCD;ac<ed BCD

 ALL ALL

Page 35: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 35/85

 ALE AH 0, AL 0E

 A# ++E

Page 36: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 36/85

"'amples$"'amples$

"'3"'3  ADD A#, ADD A#,

 ADC A#, ADC A#,

"'3"'3 NC B#NC B#

  NC /O!D ;.! 5B#6NC /O!D ;.! 5B#6

"'3+"'3+  ASC COD" 0 +0+ ASC COD" 0 +0+  MO% A#,+GH4 (ASC code for n@m?er G)MO% A#,+GH4 (ASC code for n@m?er G)

  ADD AL,+H4 (ASC code for n@m?er ) ADD AL,+H4 (ASC code for n@m?er ) ALE ALE

  AAA4 @sed for addition AAA4 @sed for addition  AH0, AL0E AH0, AL0E

  ADD A#,+0+0H4 ans>er to ASC 00E ADD A#,+0+0H4 ans>er to ASC 00E  A#++E A#++E

"'3  AL contains 2 (pac<ed BCD)

  BL contains 2* (pac<ed BCD)

  ADD AL, BL

  DAA

 

2

- 2*

EB G

E'a*le>E'a*le>

Page 37: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 37/85

E'a*le>E'a*le>*M.2E1 5MA11*M.2E1 5MA11 > pro"ra& that adds two &u!tiword nu&#ersG> pro"ra& that adds two &u!tiword nu&#ersG

*5+AC 6*5+AC 6

*2A+A*2A+A

2A+A 2N 89OO6CEFh2A+A 2N 89OO6CEFh >a!!ocate 8 #tes>a!!ocate 8 #tes

.34 000h.34 000h

2A+A7 2N 9C29A7B82h2A+A7 2N 9C29A7B82h > a!!ocate 8 #tes> a!!ocate 8 #tes

.34 0070h.34 0070h

2A+A 2N 2A+A 2N

*C.2E*C.2E

  MAI P3.C 9A3 MAI P3.C 9A3 

  M.: A<Q2A+AM.: A<Q2A+A > receive the startin" address for 2A+A> receive the startin" address for 2A+A

  M.: 25A<M.: 25A<

  C1CC1C > c!ear carr> c!ear carr  M.: 5I.995E+ 2A+AM.: 5I.995E+ 2A+A > 1EA for 2A+A> 1EA for 2A+A

  M.: 2I.995E+ 2A+A7M.: 2I.995E+ 2A+A7 > 1EA for 2A+A7> 1EA for 2A+A7

  M.: B<.995E+ 2A+AM.: B<.995E+ 2A+A > 1EA for 2A+A> 1EA for 2A+A

  M.: C<0hM.: C<0h

BACG M.: A<H5IBACG M.: A<H5I

  A2C A<H2IA2C A<H2I > add with carr to A<> add with carr to A<

  M.: HB<A<M.: HB<A<  A22 5I7hA22 5I7h

  A22 2I7hA22 2I7h

  A22 B<7hA22 B<7h

  1..P BAC 1..P BAC  > decre&ent C< auto&atica!! unti! ero> decre&ent C< auto&atica!! unti! ero

  M.: A/ChM.: A/Ch

  I+ 7h> ha!tI+ 7h> ha!t

  MAI E2PMAI E2P

  E2 MAIE2 MAI

Page 38: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 38/85

Ari&5e&i- Ins&ru-&ions S74; S44; ,EC; AAS; ,AS; .EGAri&5e&i- Ins&ru-&ions S74; S44; ,EC; AAS; ,AS; .EG

 AAS AAS

DAS

CF

(AL) difference

(AH) dec ?=

if ?orro>

Page 39: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 39/85

Ari&5e&i- Ins&ru-&ions S74; S44; ,EC; AAS;Ari&5e&i- Ins&ru-&ions S74; S44; ,EC; AAS;

,AS; .EG,AS; .EG

MnemonicMnemonic   MeaningMeaning   FormatFormat   OperationOperation FlagsFlagsaffectedaffected

S8BS8B   S@?tractS@?tract S8B D,SS8B D,S   (D)(S) (D)(D)(S) (D) Borro> (CF)Borro> (CF)

 All All

SBBSBB   S@?tractS@?tract>it>it

?orro>?orro>

SBB D,SSBB D,S   (D)(S)(CF) (D)(D)(S)(CF) (D) 

 All All

D"CD"C   DecrementDecrement?= one?= one

D"C DD"C D   (D) (D)(D) (D)  All ?@t CF All ?@t CF

N"&N"&   NegateNegate   N"& DN"& D   All All

DASDAS   DecimalDecimalad@st forad@st for

s@?tractions@?traction

DASDAS   Convert te res@lt in AL toConvert te res@lt in AL topac<ed decimal formatpac<ed decimal format

 All All

 AAS AAS   ASC ASCad@st forad@st for

s@?tractions@?traction

 AAS AAS   (AL) difference(AL) difference

(AH) dec ?= if ?orro>(AH) dec ?= if ?orro>

C1,ACC1,AC

Page 40: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 40/85

"'amples$ DAS"'amples$ DAS

Borro> from AH

Page 41: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 41/85

"'amples$ DAS"'amples$ DAS

M.: B1 78/M.: B1 78/

M.: A1 8/M.: A1 8/

5UB A1B1> A1KB/5UB A1B1> A1KB/

2A5 > adust as A1K/2A5 > adust as A1K/

M.: A< 8/M.: A< 8/

5UB A1O/> A<K00995UB A1O/> A<K0099

AA5 > A<K990O ten's co&p!e&ent of ?(Borrow one fro& A/ )AA5 > A<K990O ten's co&p!e&ent of ?(Borrow one fro& A/ )

.3 A10/ > A1KO.3 A10/ > A1KO

Page 42: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 42/85

Assu&e (B<)K00A/ what is the resu!t of executin" theAssu&e (B<)K00A/ what is the resu!t of executin" the

instructioninstruction

 E4 B< E4 B<

(B<)K000000000000(B<)K000000000000

7's co&p K 0000 K 99C6/7's co&p K 0000 K 99C6/

(C9)K(C9)K

Page 43: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 43/85

)*ample)*ample

II 7?#it su#traction of two 7 #it nu&#ers < and that are stored7?#it su#traction of two 7 #it nu&#ers < and that are storedin the &e&or asin the &e&or as

< K (25G70h)(25G707h)(25G70h)(25G700h)< K (25G70h)(25G707h)(25G70h)(25G700h)

K (25G0h)(25G07h)(25G0h)(25G00h) K (25G0h)(25G07h)(25G0h)(25G00h)

RR +he resu!t < ? to #e stored where < is saved in the &e&or+he resu!t < ? to #e stored where < is saved in the &e&or

M.: 5I 700hM.: 5I 700hM.: 2I 00hM.: 2I 00h

M.: A< H5IM.: A< H5I

5UB A< H2I5UB A< H2I

M.: H5I A< >save the 15 word of resu!tM.: H5I A< >save the 15 word of resu!t

M.: A< H5I L7M.: A< H5I L7

5BB A< H2IL75BB A< H2IL7

M.: H5I L7 A<M.: H5I L7 A<

Ex* 7 6 F8 = 7 6F 8O K E9 EE EE EEEx* 7 6 F8 = 7 6F 8O K E9 EE EE EE

M@ltiplication and DivisionM@ltiplication and Division

Page 44: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 44/85

M@ltiplication and DivisionM@ltiplication and Division

+ultipli(ation and Diision+ultipli(ation and Diision

Page 45: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 45/85

+ultipli(ation and Diision+ultipli(ation and Diision

+ultipli(ation and Diision

Page 46: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 46/85

Mu!tip!icationMu!tip!ication

(MU1 or IMU1)(MU1 or IMU1)Mu!tip!icantMu!tip!icant .perand.perand

(Mu!tip!ier)(Mu!tip!ier)3esu!t3esu!t

BteSBteBteSBte A1A1 3e"ister or3e"ister or&e&or&e&or

A<A<

,ordS,ord,ordS,ord A<A< 3e"ister or3e"ister or

&e&or&e&or2< GA<2< GA<

2wordS2word2wordS2word EA<EA< 3e"ister or3e"ister or

&e&or&e&or

EA< GE2<EA< GE2<

2ivision2ivision

(2I: or I2I:)(2I: or I2I:)2ividend2ividend .perand.perand

(2ivisor)(2ivisor)NuotientGNuotientG

3e&ainder 3e&ainder 

,ord-Bte,ord-Bte A<A< 3e"ister or3e"ister or

Me&orMe&or

A1 G A/A1 G A/

2word-,ord2word-,ord 2<GA<2<GA< 3e"ister or3e"ister or

Me&orMe&orA< G 2<A< G 2<

Nword-2wordNword-2word E2<G EA<E2<G EA< 3e"ister or3e"ister or

Me&orMe&orEA< G E2<EA< G E2<

+ultipli(ation and Diision

Page 47: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 47/85

+ultipli(ation and Diision )*amples+ultipli(ation and Diision )*amples

E'1>E'1> Assu&e that each instruction starts fro& these va!uesGAssu&e that each instruction starts fro& these va!uesG

A1 K 8/ B1 K / A/ K 0/A1 K 8/ B1 K / A/ K 0/

* MU1 B1* MU1 B1 TT  A1 * B1 K 8/ S / K B8O/A1 * B1 K 8/ S / K B8O/ TT A< K B8O/A< K B8O/

 

7* IMU1 B17* IMU1 B1 TT A1 * B1 K 7'5 A1 S B1 K 7'5 (8/) S /A1 * B1 K 7'5 A1 S B1 K 7'5 (8/) S /

K FB/ S / K OFF/K FB/ S / K OFF/TT 7's co&p7's co&p TT E68O/E68O/ TT A<*A<*

* 2I: B1* 2I: B1 TT  K K 07 (8?07SKB)K K 07 (8?07SKB) TT

** I2I: B1I2I: B1 TT  K KK K

BB BL

 AX 

 H 

 H 

00807

 AH AL

 BL

 AX 

 H 

 H 

M

008

BB 0707

 AH AL

Page 48: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 48/85

E'"> AL F=; 4L 1=; A= 00=

* MU1 B1 T A1 S B1 K 9/ S O/ K 8OA/ T A< K 8OA/

7* IMU1 B1 T A1 S B1 K 7'5 A1 S 7'5 B1 K 7'5 (9/) S 7'5(O/) K

  02/ S 69/ K 0A/ T A<*

 

*I2I: B1 T K K K 7T (009 = 7S69K/) BL

 AX 

)O(U7

M00

 H S 

 H  F 

 FH 

 H  F 

6

M00

A/ A1

07  R J

 NEG NEG

 POS = J Ks(0) F"HJ

A/ A1

  9EJ

 

* 2I: B1 T K K 0T(9?SOK67) T BL

 AX 

 H 

 H  F 

O

M00 A/ A1

67 0  !

Page 49: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 49/85

E'> A: F000=; 4: 01#=; ,: 0000= 

* MU1 B< K 9000/ S O0/  K 

2< A<

GE+ B000

7* IMU1 B< K 7'5(9000/) S 7'5(O0/) K 000 S 69EB K

2< A<

0*F"   B000

* 2I: B1 K K B62/ T More than 99/ T 2ivide Error *  H 

 H  F 

000

* I2I: B1 T K K C/ V F9 T 2ivide Error* H 

 H  F S 

)000(U7

 H 

 H 

000

E'3> A: 1"#0= 4L 0=

Page 50: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 50/85

E'3> A: 1"#0=; 4L 0= 

* I2I: B1 T K K K K K BL

 AX 

 H 

 H 

O0

70

 NEG

 POS 

 sNEG

 POS 

U7   )O0(U7

70

 H  s

 H 

 H 

 H 

F0

70

  H () J (20 E0) *0H (!"M) 

H ( POS ) J KS (H) DEH J!

*0H DEH

  3 D% BL J 0HJ2000 20H J

 BL

 AX 

 H 

 H 

O0

70   ! 20H 0H

 AH AL

Page 51: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 51/85

Logi(al Instru(tionsLogi(al Instru(tions

Page 52: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 52/85

Mne&onicMne&onic Meanin"Meanin" 9or&at9or&at .peration.peration 9!a"s Affected9!a"s Affected

A2A2

.3 .3 

<.3 <.3 

 .+ .+

1o"ica! A21o"ica! A2

1o"ica! Inc!usive .3 1o"ica! Inc!usive .3 

1o"ica! Exc!usive .3 1o"ica! Exc!usive .3 

1.4ICA1 .+1.4ICA1 .+

A2 25A2 25

.3 25.3 25

<.3 25<.3 25

 .+ 2 .+ 2

(5) W (2)(5) W (2) JJ (2)(2) 

(5)L(2)(5)L(2) JJ  (2) (2)

(5) (2)(5) (2)JJ(2)(2)

 J J

(2)(2)

JJ

 (2)(2)

.9 59 ;9 P9 C9.9 59 ;9 P9 C9A9 undefinedA9 undefined

.9 59 ;9 P9 C9.9 59 ;9 P9 C9

A9 undefinedA9 undefined

.9 59 ;9 P9 C9.9 59 ;9 P9 C9

A9 undefinedA9 undefined

 one one

-

Logi(al Instru(tions

2estination2estination 5ource5ource

3e"ister 3e"ister 

3e"ister 3e"ister Me&orMe&or

3e"ister 3e"ister 

Me&orMe&or

Accu&u!ator Accu&u!ator 

3e"ister 3e"ister 

Me&orMe&or3e"ister 3e"ister 

I&&ediateI&&ediate

I&&ediateI&&ediate

I&&ediateI&&ediate

2estination2estination

3e"ister3e"isterMe&orMe&or

Page 53: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 53/85

Logi(al Instru(tionsLogi(al Instru(tions

RR A2A2 = = Uses an addressin" &ode except &e&or?to?&e&or andUses an addressin" &ode except &e&or?to?&e&or and

se"&ent re"istersse"&ent re"isters

 = = Especia!! used in c!earin" certain #its (&as%in")Especia!! used in c!earin" certain #its (&as%in")

  xxxx xxxxxxxx xxxx A.,A., 0000 K 0000 xxxx0000 K 0000 xxxx

(c!ear the first four #its)(c!ear the first four #its) = = Exa&p!esGExa&p!esG A2 B1 09/A2 B1 09/

A2 A1 H/A2 A1 H/

RR.3 .3 

 = = Used in settin" certain #itsUsed in settin" certain #its

xxxx xxxxxxxx xxxx OROR 0000 K xxxx 0000 K xxxx

(5et the upper four #its)(5et the upper four #its)

Page 54: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 54/85

<.3 <.3 

 = = Used in invertin" #itsUsed in invertin" #its xxxx xxxx <.3 0000 K xxxxx'x'x'x'xxxx xxxx <.3 0000 K xxxxx'x'x'x'

DE'a*le>DE'a*le> C!ear #its 0 and set #its 6 and F invert #it ofC!ear #its 0 and set #its 6 and F invert #it of

re"ister C1Gre"ister C1G

A2 C1 .9C/A2 C1 .9C/ >> 00B 00B.3 C1 0C0/.3 C1 0C0/ >> 00 0000B00 0000B

<.3 C1 070/<.3 C1 070/ >>  000 0000B000 0000B

Page 55: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 55/85

S5i& Ins&ru-&ionsS5i& Ins&ru-&ions

S$ift Instru(tions

Page 56: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 56/85

Mne&onicMne&onic Meanin"Meanin" 9or&at9or&at .peration.peration 9!a"s Affected9!a"s Affected

5A1-5/15A1-5/1

5/3 5/3 

5A3 5A3 

5hift arith&etic5hift arith&etic

1eft-shift1eft-shift

1o"ica! !eft1o"ica! !eft

5hift !o"ica!5hift !o"ica!

ri"htri"ht

5hift arith&etic5hift arith&etic

ri"htri"ht

5A1-5/1 2Count5A1-5/1 2Count

5/3 2Count5/3 2Count

5A3 2Count5A3 2Count

5hift the (2) !eft # the5hift the (2) !eft # the

nu&#er of #it positionsnu&#er of #it positions

e$ua! to count and fi!!e$ua! to count and fi!!

the vacated #itsthe vacated #its

 positions on the ri"ht positions on the ri"ht

with eroswith eros

5hift the (2) ri"ht # the5hift the (2) ri"ht # the

nu&#er of #it positionsnu&#er of #it positions

e$ua! to count and fi!!e$ua! to count and fi!!

the vacated #itsthe vacated #its

 positions on the !eft positions on the !eft

with eroswith eros

5hift the (2) ri"ht # the5hift the (2) ri"ht # the

nu&#er of #it positionsnu&#er of #it positions

e$ua! to count and fi!!e$ua! to count and fi!!

the vacated #itsthe vacated #its positions on the !eft positions on the !eft

with the ori"ina! &ostwith the ori"ina! &ost

si"nificant #itsi"nificant #it

C9P959;9C9P959;9

A9 undefinedA9 undefined

.9 undefined if count X

.9 undefined if count X

C9P959;9C9P959;9

A9 undefinedA9 undefined

.9 undefined if count X.9 undefined if count X

C9P959;9C9P959;9

A9 undefinedA9 undefined

.9 undefined if count X.9 undefined if count X

S$ift Instru(tions

S$ift Instr (tions

Page 57: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 57/85

S$ift Instru(tions

,es&ina&ion,es&ina&ion Coun&Coun&

3e"ister3e"ister

3e"ister 3e"ister 

 Me&orMe&or

 Me&orMe&or

C1C1

C1C1

Page 58: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 58/85

 

Page 59: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 59/85

Ex*Ex*> Mu!tip!> Mu!tip! A< # 0A< # 0

5/1 A< 5/1 A< M.: B< A<M.: B< A<

M.: C17M.: C17

5/1 A<C15/1 A<C1

A22 A< B<A22 A< B< Ex*Ex* ,hat are the resu!ts of,hat are the resu!ts of 5A3 C1 5A3 C1

if C1 initia!! contains B6/ 2B/if C1 initia!! contains B6/ 2B/

Ex*Ex* ,hat are the resu!ts of,hat are the resu!ts of

5/1 A1 C15/1 A1 C1

if A1 contains F/ and C1 contains A8/if A1 contains F/ and C1 contains A8/

R I i

Page 60: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 60/85

Ro&a&e Ins&ru-&ionsRo&a&e Ins&ru-&ions

Page 61: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 61/85

Mne&onicMne&onic Meanin"Meanin" 9or&at9or&at .peration.peration 9!a"s Affected9!a"s Affected

3.13.1 3otate !eft3otate !eft 3.1 2Count3.1 2Count 3otate the (2) !eft # the3otate the (2) !eft # the

nu&#er of #it positionsnu&#er of #it positions

e$ua! to Count* Each #ite$ua! to Count* Each #it

shifted out fro& the !eftshifted out fro& the !eft

&ost #it "oes #ac% into the&ost #it "oes #ac% into the

ri"ht&ost #it position*ri"ht&ost #it position*

C9C9

.9 undefined if count X .9 undefined if count X

3.3 3.3  3otate ri"ht3otate ri"ht 3.3 2Count3.3 2Count 3otate the (2) ri"ht # the3otate the (2) ri"ht # thenu&#er of #it positionsnu&#er of #it positions

e$ua! to Count* Each #ite$ua! to Count* Each #it

shifted out fro& theshifted out fro& the

ri"ht&ost #it "oes #ac% intori"ht&ost #it "oes #ac% into

the !eft&ost #it position*the !eft&ost #it position*

C9C9.9 undefined if count X .9 undefined if count X

3C13C1 3otate !eft3otate !eftthrou"hthrou"h

carrcarr

3C1 2Count3C1 2Count 5a&e as 3.1 except carr5a&e as 3.1 except carris attached to (2) foris attached to (2) for

rotation*rotation*

C9C9.9 undefined if count X .9 undefined if count X

3C3 3C3  3otate ri"ht3otate ri"ht

throu"hthrou"h

carrcarr

3C3 2Count3C3 2Count 5a&e as 3.3 except carr5a&e as 3.3 except carr

is attached to (2) foris attached to (2) for

rotation*rotation*

C9C9

.9 undefined if count X .9 undefined if count X

-otate Instru(tions

- t t I t ti

Page 62: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 62/85

,es&ina&ion,es&ina&ion Coun&Coun&

3e"ister3e"ister

3e"ister 3e"ister  Me&orMe&or

 Me&orMe&or

C1C1

C1C1

-otate Instru(tions

Page 63: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 63/85

Ex* ,hat is the resu!t of 3.1 B+3E P+3 H5I

if 5I is pointin" to a &e&or !ocation that contains / (87/)

E lE l

Page 64: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 64/85

E'a*leE'a*le

,rite a pro"ra& that counts the nu&#er of 's in a,rite a pro"ra& that counts the nu&#er of 's in a

 #te and writes it into B1 #te and writes it into B12A+A 2B OF > 6h2A+A 2B OF > 6h

5UB B1 B1 > c!ear B1 to %eep the nu&#er of s5UB B1 B1 > c!ear B1 to %eep the nu&#er of s

M.: 21 8 > Counter M.: 21 8 > Counter 

M.: A1 2A+AM.: A1 2A+A

A4AIG 3.1 A1 > rotate !eft onceA4AIG 3.1 A1 > rotate !eft once

DC E<+ > chec% for DC E<+ > chec% for

IC B1 > if C9K then add one to countIC B1 > if C9K then add one to count E<+G 2EC 21 > "o throu"h this 8 ti&es E<+G 2EC 21 > "o throu"h this 8 ti&es

D; A4AI > if not finished "o #ac% D; A4AI > if not finished "o #ac% 

 .P .P

Flag Con&rol Ins&ru-&ionsFlag Con&rol Ins&ru-&ions 

Page 65: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 65/85

gg +he 8086 &icroprocessor has a set of !a"s to either &onitor the+he 8086 &icroprocessor has a set of !a"s to either &onitor the

status of executin" instructions or contro! options avai!a#!e instatus of executin" instructions or contro! options avai!a#!e in

its operation*its operation* +he instruction set inc!udes a "roup of instructions that when+he instruction set inc!udes a "roup of instructions that when

executed direct! affect the state of the f!a"s* +he instructionsexecuted direct! affect the state of the f!a"s* +he instructions

areGareG

1oad A/ fro& f!a"s (1A/9)1oad A/ fro& f!a"s (1A/9) 5tore A/ into f!a"s (5A/9)5tore A/ into f!a"s (5A/9)

C!ear carr (C1C)C!ear carr (C1C)

5et carr (5+C)5et carr (5+C)

Co&p!e&ent carr (CMC)Co&p!e&ent carr (CMC) C!ear interrupt (C1I)C!ear interrupt (C1I)

5et interrupt (5+I)5et interrupt (5+I)

Page 66: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 66/85

Contro! +ransfer or Branchin" InstructionsContro! +ransfer or Branchin" Instructions

+ransfer the f!ow of execution of the pro"ra& to a new address+ransfer the f!ow of execution of the pro"ra& to a new address

specified in the instruction direct! or indirect!specified in the instruction direct! or indirect!

C!assified as two tpesC!assified as two tpes

Unconditiona! Contro! +ransfer (Branch) InstructionsUnconditiona! Contro! +ransfer (Branch) Instructions

o Execution contro! is transferred to the specific !ocationExecution contro! is transferred to the specific !ocation

independent of an statusindependent of an status

Conditiona! Contro! +ransfer (Branch) InstructionsConditiona! Contro! +ransfer (Branch) Instructions

o Contro! is transferred to the specified !ocation providedContro! is transferred to the specified !ocation providedthe resu!t of the previous operation satisfies a particu!arthe resu!t of the previous operation satisfies a particu!ar

condition otherwise execution continues in nor&a! f!owcondition otherwise execution continues in nor&a! f!ow

se$uencese$uence

Page 67: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 67/85

Unconditiona! Branch InstructionsUnconditiona! Branch Instructions

CA11G Unconditiona! Ca!! G Procedure in A1PCA11G Unconditiona! Ca!! G Procedure in A1P

 Used to ca!! a su#routine fro& &ain pro"ra&Used to ca!! a su#routine fro& &ain pro"ra&

 Address is specified direct! or indirect! #ased on tpe ofAddress is specified direct! or indirect! #ased on tpe of

addressin" &odeaddressin" &ode  C!assified as ear Ca!! (L-? 7 disp!ace&ent) and 9arC!assified as ear Ca!! (L-? 7 disp!ace&ent) and 9ar

Ca!! (Anwhere outside the se"&ent)Ca!! (Anwhere outside the se"&ent)

 .n execution this instruction stores the incre&ented IP.n execution this instruction stores the incre&ented IP

and C5 onto the stac% and !oads the C5 and IP re"istersand C5 onto the stac% and !oads the C5 and IP re"isters  9or ear ca!! it pushes on! IP and for 9ar ca!! it pushes9or ear ca!! it pushes on! IP and for 9ar ca!! it pushes

 #oth C5 and IP on to the stac%  #oth C5 and IP on to the stac% 

Page 68: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 68/85

Unconditiona! Branch InstructionsUnconditiona! Branch Instructions

3E+G 3eturn fro& Procedure3E+G 3eturn fro& Procedure Executed at the end of each ProcedureExecuted at the end of each Procedure ,hen executed the previous! stored content of IP and C5,hen executed the previous! stored content of IP and C5

a!on" with f!a"s are retrieved into the C5 IP and 9!a"a!on" with f!a"s are retrieved into the C5 IP and 9!a"

re"isters fro& stac% and execution of the &ain pro"ra&re"isters fro& stac% and execution of the &ain pro"ra&continuescontinues

C!assified into tpes #ased on the tpe of procedureC!assified into tpes #ased on the tpe of procedure

o  3eturn within the se"&ent3eturn within the se"&ent

o  3eturn within the se"&ent addin" 6 #it i&&ediate3eturn within the se"&ent addin" 6 #it i&&ediate

disp!ace&ent to the 5P contentsdisp!ace&ent to the 5P contentso  3eturn Interse"&ent3eturn Interse"&ent

o  3eturn Interse"&ent addin" 6 #it i&&ediate3eturn Interse"&ent addin" 6 #it i&&ediatedisp!ace&ent to the 5Pdisp!ace&ent to the 5P

contentscontents

Page 69: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 69/85

Unconditiona! Branch InstructionsUnconditiona! Branch Instructions

I+ G Interrupt +pe I+ G Interrupt +pe 76 interrupts in 808676 interrupts in 8086 ,hen I+ is executed the +PE #te is &u!tip!ied # ,hen I+ is executed the +PE #te is &u!tip!ied #

and the contents of IP and C5 of I53 wi!! #e ta%en fro&and the contents of IP and C5 of I53 wi!! #e ta%en fro&

hexadeci&a! &u!tip!ication (Y) as offset address andhexadeci&a! &u!tip!ication (Y) as offset address and0000 as se"&ent address0000 as se"&ent address

9or Execution of this instruction I9 has to #e ena#!ed9or Execution of this instruction I9 has to #e ena#!ed

 I+.G Interrupt on .verf!owI+.G Interrupt on .verf!ow

Executed when the overf!ow f!a" .9 is setExecuted when the overf!ow f!a" .9 is set  ew contents of IP and C5 are ta%en fro& the address ew contents of IP and C5 are ta%en fro& the address

0000G0000000G000

Unconditiona! Branch InstructionsUnconditiona! Branch Instructions

Page 70: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 70/85

DMPG Unconditiona! Du&pDMPG Unconditiona! Du&p Unconditiona!! transfers the contro! of execution to theUnconditiona!! transfers the contro! of execution to the

specified address usin" an 8?#it or 6?#it disp!ace&entspecified address usin" an 8?#it or 6?#it disp!ace&ent  o f!a"s are affected o f!a"s are affected C!assified as tpesC!assified as tpes

I3E+G 3eturn fro& I53 I3E+G 3eturn fro& I53  Before transferrin" ca!! to I3E+ the IP C5 and f!a"Before transferrin" ca!! to I3E+ the IP C5 and f!a"

re"ister are stored on to stac% to indicate the !ocation fro&re"ister are stored on to stac% to indicate the !ocation fro&where the execution is to #e continued after the I53where the execution is to #e continued after the I53

executedexecuted 1oopG 1oop Unconditiona!!1oopG 1oop Unconditiona!!

Execute the part of pro"ra& fro& the !a#e! or addressExecute the part of pro"ra& fro& the !a#e! or addressspecified in the instruction upto the !oop instruction C<specified in the instruction upto the !oop instruction C<

nu&#er of ti&esnu&#er of ti&es

Conditiona! Branch Instructions = Du&p InstructionsConditiona! Branch Instructions = Du&p Instructions

Page 71: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 71/85

Conditiona! Branch Instructions = 1oop InstructionConditiona! Branch Instructions = 1oop Instruction

Page 72: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 72/85

Page 73: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 73/85

Asse&#!er 2irectivesAsse&#!er 2irectives

2BG 2efine Bte2BG 2efine Bte

Used to reserve #te or #tes of &e&or !ocations in theUsed to reserve #te or #tes of &e&or !ocations in the

avai!a#!e &e&oravai!a#!e &e&or

2irects the asse&#!er to a!!ocate the specified nu&#er of2irects the asse&#!er to a!!ocate the specified nu&#er of

&e&or #tes to the said data tpe that &a #e a constant&e&or #tes to the said data tpe that &a #e a constant

E<GE<G 3A53A5 2B 0/ 07/ 0/ 0/2B 0/ 07/ 0/ 0/

2,G 2efine ,ord2,G 2efine ,ord

9unctions si&i!ar to 2B #ut &a%es the asse&#!er reserve9unctions si&i!ar to 2B #ut &a%es the asse&#!er reservethe nu&#er of &e&or words instead of #testhe nu&#er of &e&or words instead of #tes

E<GE<G ,.325 2, 7/ 6F/ F8AB/ 0C/,.325 2, 7/ 6F/ F8AB/ 0C/

Asse&#!er 2irectivesAsse&#!er 2irectives

Page 74: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 74/85

2NG 2efine Nuad ,ord2NG 2efine Nuad ,ord

Used to direct the asse&#!er to reserve wordsUsed to direct the asse&#!er to reserve words

Ma initia!ie with the specific va!uesMa initia!ie with the specific va!ues 2+G 2efine +en Btes2+G 2efine +en Btes

2irects the asse&#!er to define the specified varia#!e2irects the asse&#!er to define the specified varia#!e

re$uirin" 0 #tes for its stora"e and initia!ie the 0 #tesre$uirin" 0 #tes for its stora"e and initia!ie the 0 #tes

with the specified va!ueswith the specified va!ues Assu&eG Assu&e 1o"ica! se"&ent a&eAssu&eG Assu&e 1o"ica! se"&ent a&e

 Used to infor& the asse&#!er the na&es of the !o"ica!Used to infor& the asse&#!er the na&es of the !o"ica!

se"&ents to #e assu&ed for different se"&ents used inse"&ents to #e assu&ed for different se"&ents used in

 pro"ra& pro"ra& Must at the start of each pro"ra&Must at the start of each pro"ra&

Page 75: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 75/85

Asse&#!er 2irectivesAsse&#!er 2irectives

E2G End of Pro"ra&E2G End of Pro"ra& Mar%s the end of A1PMar%s the end of A1P

,hen encountered it i"nores the source !ines avai!a#!e !ater ,hen encountered it i"nores the source !ines avai!a#!e !ater 

E2PG End of ProcedureE2PG End of Procedure

A!! the state&ents appearin" in the sa&e &odu!e after thisA!! the state&ents appearin" in the sa&e &odu!e after thisinstruction wi!! #e stopped a#rupt!instruction wi!! #e stopped a#rupt!

E25G End of 5e"&entE25G End of 5e"&ent

Mar%s the end of a !o"ica! se"&entMar%s the end of a !o"ica! se"&ent

1o"ica! se"&ents are assi"ned with na&es usin" A55UME1o"ica! se"&ents are assi"ned with na&es usin" A55UMEdirectivedirective

 a&es appearin" with E25 as prefixes to &ar% the end of those a&es appearin" with E25 as prefixes to &ar% the end of those

 particu!ar se"&ent particu!ar se"&ent

Asse&#!er 2irectivesAsse&#!er 2irectives A!i AddE:E A!i E M Add

Page 76: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 76/85

E:EG A!i"n on Even Me&or AddressE:EG A!i"n on Even Me&or Address

Ever Asse&#!er first initia!ies a !ocation counter Ever Asse&#!er first initia!ies a !ocation counter 

Updates the !ocation counter to the next even address if theUpdates the !ocation counter to the next even address if thecurrent !ocation counter contents are not even and assi"nscurrent !ocation counter contents are not even and assi"ns

the fo!!owin" routine or varia#!e or constant to that addressthe fo!!owin" routine or varia#!e or constant to that address

ENUG E$uateENUG E$uate

Used to assi"n a !a#e! with a va!ue or a s&#o!Used to assi"n a !a#e! with a va!ue or a s&#o! 3educes the recurrence of the nu&erica! va!ues or3educes the recurrence of the nu&erica! va!ues or

constants in a pro"ra& codeconstants in a pro"ra& code

Each recurrin" va!ue is assi"ned a !a#e! and that !a#e! isEach recurrin" va!ue is assi"ned a !a#e! and that !a#e! is

used throu"hout the pro"ra&used throu"hout the pro"ra& E<+3G Externa! and Pu#!icG Pu#!icE<+3G Externa! and Pu#!icG Pu#!ic

Infor&s the asse&#!er that the na&es procedures andInfor&s the asse&#!er that the na&es procedures and

!a#e!s dec!ared after this directive have a!read #een!a#e!s dec!ared after this directive have a!read #een

defined in so&e of the A1P &odu!esdefined in so&e of the A1P &odu!es

Asse&#!er 2irectivesAsse&#!er 2irectives

Page 77: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 77/85

43.UPG 4roup the re!ated se"&ents43.UPG 4roup the re!ated se"&ents

Used to for& !o"ica! "roups of se"&ents with si&i!arUsed to for& !o"ica! "roups of se"&ents with si&i!ar purpose or tpe purpose or tpe

Infor&s the asse&#!er to for& a !o"ica! "roup of fo!!owin"Infor&s the asse&#!er to for& a !o"ica! "roup of fo!!owin"

se"&ent na&esse"&ent na&es

P3.43AM 43.UPP3.43AM 43.UP C.2E 2A+A 5+AC C.2E 2A+A 5+AC 

1ABE1G 1a#e!1ABE1G 1a#e!

Used to assi"n a na&e to the current content of the !ocationUsed to assi"n a na&e to the current content of the !ocation

counter counter 

1en"thG Bte !en"th of a 1a#e!1en"thG Bte !en"th of a 1a#e!

 ot avai!a#!e for MA5M ot avai!a#!e for MA5M

3efers to the !en"th of data arra or strin"3efers to the !en"th of data arra or strin"

M.: C< 1E4+/M.: C< 1E4+/ A33AA33A

Asse&#!er 2irectivesAsse&#!er 2irectives

Page 78: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 78/85

Asse&#!er 2irectivesAsse&#!er 2irectives

1.CA11.CA1

+he 1a#e!s :aria#!es constants or procedures dec!ared+he 1a#e!s :aria#!es constants or procedures dec!ared

1.CA1 are to #e used on! # that particu!ar &odu!e1.CA1 are to #e used on! # that particu!ar &odu!e

5a&e !a#e! can serve different purposes for different5a&e !a#e! can serve different purposes for different

&odu!es of a pro"ra&&odu!es of a pro"ra&

 AMEG 1o"ica! a&e of a Modu!e AMEG 1o"ica! a&e of a Modu!e

Used to assi"n the na&e to an A1P &odu!eUsed to assi"n the na&e to an A1P &odu!e

Modu!e can now #e referred as the dec!ared na&eModu!e can now #e referred as the dec!ared na&e

.995E+G .ffset of a 1a#e!.995E+G .ffset of a 1a#e! Used with arras strin"s !a#e!s and procedures to decideUsed with arras strin"s !a#e!s and procedures to decide

their offsets in their defau!t se"&entstheir offsets in their defau!t se"&ents

Page 79: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 79/85

Asse&#!er 2irectivesAsse&#!er 2irectives

.34G .ri"in.34G .ri"in

2irects the asse&#!er to start the &e&or a!!ot&ent for the particu!ar2irects the asse&#!er to start the &e&or a!!ot&ent for the particu!ar

se"&ent #!oc% or code fro& the dec!ared address in the .34se"&ent #!oc% or code fro& the dec!ared address in the .34

state&entstate&ent

.34 700/.34 700/

P3.CG ProcedureP3.CG Procedure Mar%s the start of a na&ed procedure in the state&entMar%s the start of a na&ed procedure in the state&ent

 ear and 9ar specif the tpes of a procedure ear and 9ar specif the tpes of a procedure

PUB1ICPUB1IC

Used a!on" with E<+3Used a!on" with E<+3

Infor&s the asse&#!er that the !a#e!s constants or procedures dec!aredInfor&s the asse&#!er that the !a#e!s constants or procedures dec!ared

 pu#!ic can #e accessed # other asse&#! &odu!es to for& their codes pu#!ic can #e accessed # other asse&#! &odu!es to for& their codes

Asse&#!er 2irectivesAsse&#!er 2irectives

Page 80: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 80/85

5E4ME+G 1o"ica! 5e"&ent5E4ME+G 1o"ica! 5e"&ent Mar%s the startin" of a !o"ica! se"&entMar%s the startin" of a !o"ica! se"&ent

5tarted se"&ent is a!so assi"ned a na&e i*e* 1a#e!5tarted se"&ent is a!so assi"ned a na&e i*e* 1a#e! 5E4ME+ and E25 &ust #rac%et each !o"ica! state&ent5E4ME+ and E25 &ust #rac%et each !o"ica! state&ent E<E*C.2EE<E*C.2E 5E4ME+5E4ME+ C.2EC.2E

E<E*C.2EE<E*C.2E E25E25

5/.3+5/.3+ Indicates to the asse&#!er that on! one #te is re$uired toIndicates to the asse&#!er that on! one #te is re$uired to

code the disp!ace&ent for a u&pcode the disp!ace&ent for a u&p +his &ethod of u&pin" save &e&or+his &ethod of u&pin" save &e&or DMPDMP 5/.3+5/.3+ 1ABE11ABE1

+PE+PE 2irects the asse&#!er to decide the data tpe of the2irects the asse&#!er to decide the data tpe of the

specified !a#e! and rep!aces the +PE !a#e! # the decidedspecified !a#e! and rep!aces the +PE !a#e! # the decideddata tpedata tpe

M.: A< +PE 5+3I4M.: A< +PE 5+3I4

Asse&#!er 2irectivesAsse&#!er 2irectives

Page 81: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 81/85

41.BA141.BA1

1a#e!s :aria#!es Constants or procedures dec!ared1a#e!s :aria#!es Constants or procedures dec!ared

41.BA1 can #e used # other &odu!es of the pro"ra&41.BA1 can #e used # other &odu!es of the pro"ra& 3.U+IE3.U+IE P3.CP3.C 41.BA141.BA1

9A3 P+3 9A3 P+3 

Indicates that the !a#e! fo!!owin" this directive is notIndicates that the !a#e! fo!!owin" this directive is not

avai!a#!e within the sa&e se"&ent and the address of theavai!a#!e within the sa&e se"&ent and the address of the!a#e! is of 7 #its!a#e! is of 7 #its

DMPDMP 9A3 P+3 9A3 P+3  1a#e!1a#e!

 EA3 P+3  EA3 P+3 

Indicates that the !a#e! fo!!owin" this directive is in theIndicates that the !a#e! fo!!owin" this directive is in the

sa&e se"&ent and needs on! 6 #it to address itsa&e se"&ent and needs on! 6 #it to address it

DMPDMP  EA3 P+3  EA3 P+3  1a#e!1a#e!

Page 82: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 82/85

ProcedureProcedure

5u#routines in a A1P5u#routines in a A1P

Ma re$uire input data or constants for their executionMa re$uire input data or constants for their execution

If interactive it &a direct! accept inputs fro& input devicesIf interactive it &a direct! accept inputs fro& input devices

+echni$ues to pass data to procedures in A1P+echni$ues to pass data to procedures in A1P

Usin" 4!o#a! dec!ared varia#!eUsin" 4!o#a! dec!ared varia#!e

Usin" re"isters of CPU architectureUsin" re"isters of CPU architecture

Usin" &e&or !ocations (3eserved)Usin" &e&or !ocations (3eserved)

Usin" 5tac% Usin" 5tac%  Usin" PUB1IC @ E<+3Usin" PUB1IC @ E<+3

ProcedureProcedure

Page 83: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 83/85

+he sntax for procedure dec!arationG+he sntax for procedure dec!arationG

na&e P3.Cna&e P3.C

  > here "oes the code  > here "oes the code  > of the procedure ***  > of the procedure ***

3E+3E+na&ena&e E2PE2P

na&ena&e ? is the procedure na&e the sa&e na&e shou!d #e in the? is the procedure na&e the sa&e na&e shou!d #e in thetop and the #otto& this is used to chec% correct c!osin" oftop and the #otto& this is used to chec% correct c!osin" of procedures* procedures*Pro#a#! ou a!read %now thatPro#a#! ou a!read %now that RETRET instruction is used toinstruction is used toreturn to operatin" sste&* +he sa&e instruction is used toreturn to operatin" sste&* +he sa&e instruction is used toreturn fro& procedure (actua!! operatin" sste& sees ourreturn fro& procedure (actua!! operatin" sste& sees our

 pro"ra& as a specia! procedure)* pro"ra& as a specia! procedure)*

%ROC%ROC andand E.,%E.,% are co&pi!er directives so the are notare co&pi!er directives so the are notasse&#!ed into an rea! &achine code* Co&pi!er ust re&e&#ersasse&#!ed into an rea! &achine code* Co&pi!er ust re&e&#ersthe address of procedure*the address of procedure*CALLCALL instruction is used to ca!! a procedure*instruction is used to ca!! a procedure*

MAC3.5MAC3.5 Process of assi"nin" a !a#e! or &acro na&e to a strin"Process of assi"nin" a !a#e! or &acro na&e to a strin"

Page 84: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 84/85

5i&i!ar to 5u#routines5i&i!ar to 5u#routines

+he co&p!ete code of instructions strin" is inserted at each p!ace+he co&p!ete code of instructions strin" is inserted at each p!acewhere the &acro na&e appearswhere the &acro na&e appears

2oes not uti!ie the service of stac% 2oes not uti!ie the service of stac% 

Can #e defined anwhere in the pro"ra&Can #e defined anwhere in the pro"ra&

Uses the directives MAC3. and E2MUses the directives MAC3. and E2M

+he !a#e! prior to MAC3. directive is ca!!ed Macro na&e which+he !a#e! prior to MAC3. directive is ca!!ed Macro na&e which

shou!d #e used in actua! pro"ra&shou!d #e used in actua! pro"ra& E2M &ar%s the ends the instructions se$uence assi"ned withE2M &ar%s the ends the instructions se$uence assi"ned with

&acro na&e&acro na&e

E<GE<G 2I5P1A MAC3.2I5P1A MAC3.

M.: A< 5E4 M54M.: A< 5E4 M54

M.: 25 A<M.: 25 A<

M.: 2< .995E+ M54M.: 2< .995E+ M54

M.: A/ 0O/M.: A/ 0O/

I+ 7/I+ 7/

E2ME2M

Page 85: 8086 UNIT-2

7/23/2019 8086 UNIT-2

http://slidepdf.com/reader/full/8086-unit-2 85/85

MAC3.5MAC3.5

Can #e used in 2ata se"&entCan #e used in 2ata se"&ent Can #e used to represent state&ents and directivesCan #e used to represent state&ents and directives Can #e ca!!ed # $uotin" its na&e a!on" with an va!ues to #eCan #e ca!!ed # $uotin" its na&e a!on" with an va!ues to #e

 passed to the &acro passed to the &acro

Pro"ra&&er specifies the para&eters of the &acro those are toPro"ra&&er specifies the para&eters of the &acro those are to #e chan"ed each ti&e the &acro is ca!!ed #e chan"ed each ti&e the &acro is ca!!ed +here &a #e &ore than one para&eter in a &acro definition+here &a #e &ore than one para&eter in a &acro definition A!! Para&eters are defined se$uentia!!A!! Para&eters are defined se$uentia!! A &acro &a #e defined in another &acro and &a #e ca!!edA &acro &a #e defined in another &acro and &a #e ca!!ed

fro& inside a &acrofro& inside a &acro