Unit 2
Unit 2
TII
Def
ini
ti
onofMi
cropr
ocessor
: Mi
cropr
ocessori
samul
ti
pur
pose,pr
ogr
ammabl
e
dev
icet
hataccept
sdi
git
aldat
aasi
nput
,pr
ocessesi
taccor
dingt
oinst
ruct
ions
st
oredi
nit
smemor
y,andpr
ovi
desr
esul
tsasout
put
.or Ami
cropr
ocessori
sa
mul
ti
pur
pose,pr
ogr
ammabl
e,cl
ock-
dri
ven,r
egi
ster
-based el
ect
roni
c dev
ice t
hat
r
eadsbi
nar
yinst
ruct
ionsf
rom ast
oragedev
icecal
l
edmemor
yaccept
sbi
nar
ydat
a
asi
nputandpr
ocessesdat
aaccor
dingt
oinst
ruct
ions,
andpr
ovi
desr
esul
tasout
put
.
OVERVI
EW OFASI
MPLEMI
CROCOMPUTER:
Themaj
orpar
tsar
ethecent
ralpr
ocessi
nguni
torCPU,memor
y,andt
hei
nputand
out
putci
rcui
tr
yorI
/O.Connect
ingt
hesepar
tst
oget
herar
ethr
eeset
sofpar
all
ell
i
nes
cal
l
edbuses.Thet
hreebusesar
etheaddr
essbus,
thedat
abus,
andt
hecont
rol
bus.
Bl
ockdi
agr
am ofsi
mpl
ecomput
erormi
crocomput
er.
i
) MEMORY:Thememor
ysect
ionusual
l
yconsi
stsofami
xtur
eofRAM and
ROM.I
tmayal
sohav
emagnet
icf
loppydi
sks,magnet
ichar
ddi
sks,orl
aser
opt
icaldi
sks.Memor
yhast
wopur
poses.Thef
ir
stpur
posei
stost
oret
he
bi
nar
ycodesf
ort
hesequenceofi
nst
ruct
ionsy
ouwantt
hecomput
ert
ocar
ry
out
.Wheny
ouwr
it
eacomput
erpr
ogr
am,whaty
ouar
ereal
l
ydoi
ngi
sjust
wr
it
ingasequent
iall
i
stofi
nst
ruct
ionsf
ort
hecomput
er.Thesecondpur
pose
oft
hememor
yist
ost
oret
hebi
nar
y-codeddat
awi
thwhi
cht
hecomput
eri
s
goi
ngt
obewor
king.
i
i
) I
NPUT/
OUTPUT:Thei
nput
/out
putorI
/Osect
ional
l
owst
hecomput
ert
otake
i
ndat
afr
om t
heout
sidewor
ldorsenddat
atot
heout
sidewor
ld.Theseal
l
ow
t
heuserandt
hecomput
ert
ocommuni
cat
ewi
theachot
her
.Theact
ual
phy
sicaldev
icesusedt
oint
erf
acet
hecomput
erbusest
oext
ernalsy
stems
ar
eof
tencal
l
edpor
ts.
i
i
i) CPU:The cent
ralpr
ocessi
ng uni
torCPU cont
rol
sthe oper
ati
on oft
he
comput
er.I
tfet
chesbi
nar
y-codedi
nst
ruct
ionoft
hecomput
er.I
tfet
ches
bi
nar
y-coded i
nst
ruct
ions f
rom memor
y,decodes t
he i
nst
ruct
ions i
ntoa
ser
iesofsi
mpl
eact
ions,andcar
ri
esoutt
heseact
ions.TheCPUcont
ainsan
ar
it
hmet
icl
ogi
cuni
t,orALU.Whi
chcanper
for
m add,
subt
ract
,OR,
AND,
inv
ert
,
orexcl
usi
ve-
ORoper
ati
onsonbi
nar
ywor
dswheni
nst
ruct
edt
odoso.The
CPUal
socont
ainsanaddr
esscount
erwhi
chi
susedt
ohol
dtheaddr
essof
t
henexti
nst
ruct
ionordat
atobef
etchedf
rom memor
y,gener
al-
pur
pose
r
egi
ster
swhi
char
eusedf
ort
empor
aryst
orageofbi
nar
ydat
a,andci
rcui
tr
y
whi
chgener
atest
hecont
rol
bussi
gnal
s.
i
v) ADDRESSBUS:
Theaddr
essbusconsi
stsof16,
20,
24,
ormor
epar
all
elsi
gnal
l
i
nes.Ont
hesel
i
nest
heCPUsendsoutt
headdr
essoft
hememor
ylocat
ion
t
hati
stobewr
it
tent
oorr
eadf
rom.Thenumberofaddr
essl
i
nesdet
ermi
nes
t
henumberofmemor
ylocat
ionst
hatt
heCPUcanaddr
ess.I
ftheCPUhasN
addr
essl
i
nest
heni
tcandi
rect
lyaddr
ess2Nmemor
ylocat
ions.
v
) DATABUS:Thedat
abusconsi
stsof8,
16,
32ormor
epar
all
elsi
gnall
i
nes.As
i
ndi
cat
edbyt
hedoubl
e-endedar
rowsont
hedat
abusl
i
ne,
thedat
abusl
i
nes
ar
ebi
-di
rect
ional
.Thi
smeanst
hatt
heCPUcanr
eaddat
ainont
hesel
i
nes
f
rom memor
yorf
rom apor
taswel
lassenddat
aoutont
hesel
i
nest
o
memor
ylocat
ionort
oapor
t.Manydev
icesi
nasy
stem wi
l
lhav
ethei
r
out
put
sconnect
edt
othedat
abus,butt
heout
put
sofonl
yonedev
iceata
t
imewi
l
lbeenabl
ed.
v
i) CONTROLBUS:Thecont
rolbusconsi
stsof4-
10par
all
elsi
gnall
i
nes.The
CPUsendsoutsi
gnal
sont
hecont
rolbust
oenabl
etheout
put
sofaddr
essed
memor
ydev
icesorpor
tdev
ices.Ty
pical
cont
rol
bussi
gnal
sar
ememor
yread,
memor
ywr
it
e,I
/Or
ead,
andI
/Owr
it
er.Tor
eadaby
teofdat
afr
om amemor
y
l
ocat
ion,f
orexampl
e,t
heCPUsendsoutt
headdr
essoft
hedesi
redby
teon
t
headdr
essbusandt
hensendsoutamemor
yreadsi
gnal
ont
hecont
rol
bus.
Machi
neCy
cle(
BusCy
cle)
Thebuscy
clei
sal
sonamedasmachi
necy
cle.Buscy
cleof8086i
susedt
oaccess
memor
y,per
ipher
aldev
ices(
Input
/out
putdev
ices)
,andI
nter
ruptcont
rol
l
er.Bus
cy
clecor
respondst
oasequenceofev
ent
sthatst
art
swi
thanaddr
essbei
ngout
put
onsy
stem addr
essbusf
oll
owedbyawr
it
eorr
eaddat
atr
ansf
er.Dur
ingt
hese
oper
ati
ons,aser
iesofcont
rolsi
gnal
sar
eal
sopr
oducedbymi
cropr
ocessort
o
cont
rol
dir
ect
ionandt
imi
ngofbus.
Ther
ear
eatl
eastf
ourcl
ockper
iodsi
nabuscy
cleof8086mi
cropr
ocessor
.These
f
ourcl
ockper
iodsar
ecal
l
edT1,
T2,
T3andT4st
ates.
Thesef
ourcl
ockst
atesgi
vesbuscy
cledur
ati
onTof200ns*
4=800nsi
n5-
MHz
8086sy
stem.
1.ReadCy
cle:
Whenar
eadcy
clei
stobeper
for
med,
dur
ingT1mi
cropr
ocessorput
san
addr
essonaddr
essbus,
andt
henbusi
sputi
nhi
ghi
mpedancest
atedur
ing
T2st
ate.Dat
atober
eadmustbeoutonbusdur
ingT3andT4.Dur
ingT3busi
s
made“
reser
vedf
ordat
ain”andf
inal
l
ydat
aisr
eaddur
ingT4.
2.Wr
it
eCy
cle:
I
ncaseofwr
it
ememor
ycy
cle,
dur
ingT1st
atemi
cropr
ocessorput
san
addr
essonaddr
essbus.Dat
aisputondat
abusbyCPUdur
ingT2st
ateand
mai
ntai
neddur
ingT3andT4st
atest
hati
swr
it
tenoutt
omemor
yorI
/O
dev
ices.
Ar
chi
tect
ureof8086mi
cropr
ocessor
:
Asshowni
nthebel
owf
igur
e,t
he8086CPUi
sdi
vi
dedi
ntot
woi
ndependent
f
unct
ional
par
ts
BusI
nter
faceUni
t(
BIU)
Execut
ionUni
t(
EU)
Di
vi
dingt
hewor
kbet
weent
heset
wouni
ts’
speedsuppr
ocessi
ng.
TheExecut
ionUni
t(EU)
:
Theexecut
ionuni
toft
he8086t
ell
stheBI
Uwher
etof
etchi
nst
ruct
ionsordat
a
f
rom,
decodesi
nst
ruct
ions,
andexecut
esi
nst
ruct
ions.
TheEUcont
ainscont
rol
cir
cui
tr
y,whi
chdi
rect
sint
ernal
oper
ati
ons.
Adecoderi
ntheEUt
ransl
atesi
nst
ruct
ionsf
etchedf
rom memor
yint
oaser
ies
ofact
ions,
whi
cht
heEUcar
ri
esout
.
TheEUhasa16-
bitar
it
hmet
icl
ogi
cuni
t(ALU)whi
chcanadd,subt
ract
,AND,
OR,
XOR,
incr
ement
,decr
ement
,compl
ementorshi
ftbi
nar
ynumber
s.
Themai
nfunct
ionsofEUar
e:
Decodi
ngofI
nst
ruct
ions
Execut
ionofi
nst
ruct
ions
St
eps
EUext
ract
sinst
ruct
ionsf
rom t
opofqueuei
nBI
U
Decodet
hei
nst
ruct
ions
Gener
atesoper
andsi
fnecessar
y
Passesoper
andst
oBI
U&r
equest
sitt
oper
for
mreadorwr
it
ebuscy
clest
o
memor
yorI
/O
Per
for
mtheoper
ati
onspeci
fi
edbyt
hei
nst
ruct
iononoper
ands
Letusnowdi
scusst
hef
unct
ional
par
tsof8086mi
cropr
ocessor
s.
ALU
I
thandl
esal
lar
it
hmet
icand l
ogi
caloper
ati
ons,l
i
ke+,−,×,/
,OR,AND,NOT
oper
ati
ons.
Fl
agRegi
ster
I
tisa16-
bitr
egi
stert
hatbehav
esl
i
keaf
li
p-f
lop,
i.
e.i
tchangesi
tsst
atusaccor
ding
t
other
esul
tst
oredi
ntheaccumul
ator
.Ithas9f
lagsandt
heyar
edi
vi
dedi
nto2
gr
oups−Condi
ti
onal
FlagsandCont
rol
Flags.
Condi
ti
onalFl
ags
I
trepr
esent
sthe r
esul
toft
he l
astar
it
hmet
ic orl
ogi
cali
nst
ruct
ion execut
ed.
Fol
l
owi
ngi
sthel
i
stofcondi
ti
onal
flags−
Car
ryf
lag− Thi
sfl
ag i
ndi
cat
es an ov
erf
low condi
ti
on f
or ar
it
hmet
ic
oper
ati
ons.
Auxi
li
aryf
lag− When an oper
ati
on i
sper
for
med atALU,i
tresul
tsi
na
car
ry/
bar
rowf
rom l
owerni
bbl
e(i
.
e.D0–D3)t
oupperni
bbl
e(i
.e.D4–D7)
,
t
hent
hisf
lagi
sset
,i.
e.car
rygi
venbyD3bi
ttoD4i
sAFf
lag.Thepr
ocessor
usest
hisf
lagt
oper
for
m bi
nar
ytoBCDconv
ersi
on.
Par
it
yfl
ag−Thi
sfl
agi
susedt
oindi
cat
ethepar
it
yoft
her
esul
t,i
.e.whent
he
l
oweror
der8-
bit
soft
her
esul
tcont
ainsev
ennumberof1’
s,t
hent
hePar
it
y
Fl
agi
sset
.Foroddnumberof1’
s,t
hePar
it
yFl
agi
sreset
.
Zer
ofl
ag−Thi
sfl
agi
ssett
o1whent
her
esul
tofar
it
hmet
icorl
ogi
cal
oper
ati
oni
szer
oel
sei
tissett
o0.
Si
gnf
lag−Thi
sfl
aghol
dst
hesi
gnoft
her
esul
t,i
.e.whent
her
esul
toft
he
oper
ati
oni
snegat
ive,
thent
hesi
gnf
lagi
ssett
o1el
sesett
o0.
Ov
erf
low f
lag−Thi
sfl
agr
epr
esent
sther
esul
twhent
hesy
stem capaci
tyi
s
exceeded.
Cont
rolFl
ags
Cont
rolf
lagscont
rol
stheoper
ati
onsoft
heex
ecut
ionuni
t.Fol
l
owi
ngi
sthel
i
stof
cont
rol
flags−
Tr
apf
lag−I
tisusedf
orsi
ngl
est
epcont
rolandal
l
owst
heusert
oexecut
e
onei
nst
ruct
ionatat
imef
ordebuggi
ng.I
fiti
sset
,thent
hepr
ogr
am canbe
r
uni
nasi
ngl
est
epmode.
I
nter
ruptf
lag−I
tisani
nter
ruptenabl
e/di
sabl
efl
ag,
i.
e.usedt
oal
l
ow/
prohi
bit
t
hei
nter
rupt
ionofapr
ogr
am.I
tissett
o1f
ori
nter
ruptenabl
edcondi
ti
onand
sett
o0f
ori
nter
ruptdi
sabl
edcondi
ti
on.
Di
rect
ionf
lag−I
tisusedi
nst
ri
ngoper
ati
on.Ast
henamesuggest
swheni
tis
sett
henst
ri
ngby
tesar
eaccessedf
rom t
hehi
ghermemor
yaddr
esst
othe
l
owermemor
yaddr
essandv
ice-
a-v
ersa.
Gener
alpur
poser
egi
ster
Ther
ear
e8gener
alpur
poser
egi
ster
s,i
.e.
,AH,AL,BH,BL,CH,CL,DH,andDL.
Theser
egi
ster
scanbeusedi
ndi
vi
dual
l
ytost
ore8-
bitdat
aandcanbeusedi
npai
rs
t
ost
ore16bi
tdat
a.Thev
ali
dregi
sterpai
rsar
eAHandAL,BHandBL,CHandCL,
andDHandDL.I
tisr
efer
redt
otheAX,
BX,
CX,
andDXr
espect
ivel
y.
AXr
egi
ster−I
tisal
soknownasaccumul
atorr
egi
ster
.Iti
susedt
ost
ore
oper
andsf
orar
it
hmet
icoper
ati
ons.
BXr
egi
ster−I
tisusedasabaser
egi
ster
.Iti
susedt
ost
oret
hest
art
ingbase
addr
essoft
hememor
yar
eawi
thi
nthedat
asegment
.
CXr
egi
ster−I
tisr
efer
redt
oascount
er.I
tisusedi
nloopi
nst
ruct
iont
ost
ore
t
hel
oopcount
er.
DXr
egi
ster−Thi
sregi
steri
susedt
ohol
dI/
Opor
taddr
essf
orI
/Oi
nst
ruct
ion.
St
ackpoi
nterr
egi
ster
I
tisa16-
bitr
egi
ster
,whi
chhol
dst
headdr
essf
rom t
hest
artoft
hesegmentt
othe
memor
ylocat
ion,
wher
eawor
dwasmostr
ecent
lyst
oredont
hest
ack.
BusI
nter
faceUni
t(BI
U):
TheBI
Usendsoutaddr
esses,f
etchesi
nst
ruct
ionsf
rom memor
y,r
eadsdat
afr
om
por
tsandmemor
y,andwr
it
esdat
atopor
tsandmemor
y.I
nsi
mpl
ewor
ds,t
heBI
U
handl
esal
ltr
ansf
ersofdat
aandaddr
essesont
hebusesf
ort
heexecut
ionuni
t
Regi
steror
gani
zat
ion:
8086hasapower
fulsetofr
egi
ster
sknownasgener
alpur
poser
egi
ster
sand
speci
alpur
poser
egi
ster
s.
Al
loft
hem ar
e16-
bitr
egi
ster
s.
Gener
alpur
poser
egi
ster
s:
Theser
egi
ster
scanbeusedasei
ther8-
bitr
egi
ster
sor16-
bitr
egi
ster
s.
Theymaybeei
therusedf
orhol
dingdat
a,v
ari
abl
esandi
nter
medi
ater
esul
ts
t
empor
ari
l
yorf
orot
herpur
posesl
i
keacount
erorf
orst
ori
ngof
fsetaddr
ess
f
orsomepar
ti
cul
araddr
essi
ngmodeset
c.
Speci
alpur
poser
egi
ster
s:
Theser
egi
ster
sar
eusedassegmentr
egi
ster
s,poi
nter
s,i
ndexr
egi
ster
soras
of
fsetst
orager
egi
ster
sforpar
ti
cul
araddr
essi
ngmodes.
The8086r
egi
ster
sar
ecl
assi
fi
edi
ntot
hef
oll
owi
ngt
ypes:
Gener
alDat
aRegi
ster
s
SegmentRegi
ster
s
Poi
nter
sandI
ndexRegi
ster
s
Fl
agRegi
ster
Gener
alDat
aRegi
ster
s:
Ther
egi
ster
sAX,
BX,
CXandDXar
ethegener
alpur
pose16-
bitr
egi
ster
s.
AXi
susedas16-
bitaccumul
ator
.Thel
ower8-
biti
sdesi
gnat
edasALand
hi
gher8-
biti
sdesi
gnat
edasAH.ALcanbeusedasan8-
bitaccumul
atorf
or8
-
bitoper
ati
on.
Al
ldat
aregi
stercanbeusedasei
ther16bi
tor8bi
t.BXi
sa16bi
tregi
ster
,
butBLi
ndi
cat
est
hel
ower8-
bitofBXandBHi
ndi
cat
est
hehi
gher8-
bitofBX.
Ther
egi
sterBXi
susedasof
fsetst
oragef
orf
ormi
ngphy
sicaladdr
essi
ncase
ofcer
tai
naddr
essi
ngmodes.
Ther
egi
sterCXi
suseddef
aul
tcount
eri
ncaseofst
ri
ngandl
oopi
nst
ruct
ions.
DXr
egi
steri
sagener
alpur
poser
egi
sterwhi
chmaybeusedasani
mpl
i
cit
oper
andorSegmentRegi
ster
s:
Ther
ear
e4segmentr
egi
ster
s.Theyar
e:
CodeSegmentRegi
ster
(CS)
Dat
aSegmentRegi
ster
(DS)
Ext
raSegmentRegi
ster
(ES)
St
ackSegmentRegi
ster
(SS)
The 8086 ar
chi
tect
ure usest
he conceptofsegment
ed memor
y.8086 abl
eto
addr
essamemor
ycapaci
tyof1megaby
teandi
tisby
teor
gani
zed.Thi
s1megaby
te
memor
yisdi
vi
dedi
nto16l
ogi
calsegment
s.Eachsegmentcont
ains64kby
tesof
memor
y.
Codesegmentr
egi
ster(
CS)
:isusedf
oraddr
essi
ngmemor
ylocat
ioni
nthe
codesegmentoft
hememor
y,wher
etheexecut
abl
epr
ogr
am i
sst
ored.
Dat
asegmentr
egi
ster(
DS)
:poi
ntst
othedat
asegmentoft
hememor
ywher
e
t
hedat
aisst
ored.
Ext
raSegmentRegi
ster(
ES):
alsor
efer
stoasegmenti
nthememor
ywhi
chi
s
anot
herdat
asegmenti
nthememor
y.
St
ackSegmentRegi
ster(
SS)
:isusedf
oraddr
essi
ngst
acksegmentoft
he
memor
y.Thest
acksegmenti
sthatsegmentofmemor
ywhi
chi
susedt
o
st
orest
ackdat
a.
Whi
l
eaddr
essi
nganyl
ocat
ioni
nthememor
ybank,t
hephy
sicaladdr
essi
s
cal
cul
atedf
rom t
wopar
ts:
Phy
sical
addr
ess=segmentaddr
ess+of
fsetaddr
ess
Thef
ir
sti
ssegmentaddr
ess,t
hesegmentr
egi
ster
scont
ain16-
bitsegment
baseaddr
esses,
rel
atedt
odi
ff
erentsegment
.
Thesecondpar
tist
heof
fsetv
aluei
nthatsegment
.
Poi
nter
sandI
ndexRegi
ster
s:
Thei
ndexandpoi
nterr
egi
ster
sar
egi
venbel
ow:
I
P—I
nst
ruct
ionpoi
nter
-st
orememor
ylocat
ionofnexti
nst
ruct
iont
obe
execut
ed
BP—Basepoi
nter
SP—St
ackpoi
nter
SI
—Sour
cei
ndex
DI
—Dest
inat
ioni
ndex
Thepoi
nter
sregi
ster
scont
ainof
fsetwi
thi
nthepar
ti
cul
arsegment
s.
Thepoi
nterr
egi
sterI
Pcont
ainsof
fsetwi
thi
nthecodesegment
.
Thepoi
nterr
egi
sterBPcont
ainsof
fsetwi
thi
nthedat
asegment
.
Theepoi
nterr
egi
sterSPcont
ainsof
fsetwi
thi
nthest
acksegment
.
Thei
ndexr
egi
ster
sar
eusedasgener
alpur
poser
egi
ster
saswel
las
f
orof
fsetst
oragei
ncaseofi
ndexed,basei
ndexedandr
elat
ivebase
i
ndexedaddr
essi
ngmodes.
Ther
egi
sterSIi
susedt
ost
oret
heof
fsetofsour
cedat
aindat
a
segment
.
Ther
egi
sterDIi
susedt
ost
oret
heof
fsetofdest
inat
ioni
ndat
aorext
ra
segment
.
Thei
ndexr
egi
ster
sar
epar
ti
cul
arl
yusef
ulf
orst
ri
ngmani
pul
ati
on.
The8086mi
cropr
ocessorsuppor
ts8t
ypesofi
nst
ruct
ions−
Dat
aTr
ansf
erI
nst
ruct
ions
Ar
it
hmet
icI
nst
ruct
ions
Bi
tMani
pul
ati
onI
nst
ruct
ions
St
ri
ngI
nst
ruct
ions
Pr
ogr
am Execut
ionTr
ansf
erI
nst
ruct
ions(
Branch&LoopI
nst
ruct
ions)
Pr
ocessorCont
rol
Inst
ruct
ions
I
ter
ati
onCont
rol
Inst
ruct
ions
I
nter
ruptI
nst
ruct
ions
Letusnowdi
scusst
hesei
nst
ruct
ionset
sindet
ail
.
Dat
aTr
ansf
erI
nst
ruct
ions
Thesei
nst
ruct
ionsar
eusedt
otr
ansf
ert
hedat
afr
om t
hesour
ceoper
andt
othe
dest
inat
ionoper
and.Fol
l
owi
ngar
ethel
i
stofi
nst
ruct
ionsundert
hisgr
oup−
I
nst
ruct
iont
otr
ansf
erawor
d
MOV− Usedt
ocopyt
heby
teorwor
dfr
om t
hepr
ovi
dedsour
cet
othe
pr
ovi
deddest
inat
ion.
PUSH−Usedt
oputawor
datt
het
opoft
hest
ack.
POP−Usedt
ogetawor
dfr
om t
het
opoft
hest
ackt
othepr
ovi
dedl
ocat
ion.
PUSHA−Usedt
oputal
lther
egi
ster
sint
othest
ack.
POPA−Usedt
ogetwor
dsf
rom t
hest
ackt
oal
lregi
ster
s.
XCHG−Usedt
oexchanget
hedat
afr
om t
wol
ocat
ions.
XLAT−Usedt
otr
ansl
ateaby
tei
nALusi
ngat
abl
eint
hememor
y.
I
nst
ruct
ionsf
ori
nputandout
putpor
ttr
ansf
er
I
N−Usedt
oreadaby
teorwor
dfr
om t
hepr
ovi
dedpor
ttot
heaccumul
ator
.
OUT−Usedt
osendoutaby
teorwor
dfr
om t
heaccumul
atort
othepr
ovi
ded
por
t.
I
nst
ruct
ionst
otr
ansf
ert
headdr
ess(
Speci
aladdr
esst
ransf
eri
nst
ruct
ions)
LEA−Usedt
oloadt
headdr
essofoper
andi
ntot
hepr
ovi
dedr
egi
ster
.
LDS−Usedt
oloadDSr
egi
sterandot
herpr
ovi
dedr
egi
sterf
rom t
hememor
y
LES−Usedt
oloadESr
egi
sterandot
herpr
ovi
dedr
egi
sterf
rom t
hememor
y.
I
nst
ruct
ionst
otr
ansf
erf
lagr
egi
ster
s(f
lagt
ransf
err
egi
ster
s)
LAHF−Usedt
oloadAHwi
tht
hel
owby
teoft
hef
lagr
egi
ster
.
SAHF−Usedt
ost
oreAHr
egi
stert
olowby
teoft
hef
lagr
egi
ster
.
PUSHF−Usedt
ocopyt
hef
lagr
egi
steratt
het
opoft
hest
ack.
POPF−Usedt
ocopyawor
datt
het
opoft
hest
ackt
othef
lagr
egi
ster
.
Ar
it
hmet
icI
nst
ruct
ions
These i
nst
ruct
ions ar
e used t
o per
for
m ar
it
hmet
ic oper
ati
ons l
i
ke addi
ti
on,
subt
ract
ion,
mul
ti
pli
cat
ion,
div
isi
on,
etc.
Fol
l
owi
ngi
sthel
i
stofi
nst
ruct
ionsundert
hisgr
oup−
I
nst
ruct
ionst
oper
for
m addi
ti
on
ADD−Usedt
oaddt
hepr
ovi
dedby
tet
oby
te/
wor
dtowor
d.
ADC−Usedt
oaddwi
thcar
ry.
I
NC−Usedt
oincr
ementt
hepr
ovi
dedby
te/
wor
dby1.
AAA−Usedt
oadj
ustASCI
Iaf
teraddi
ti
on.
DAA−Usedt
oadj
ustt
hedeci
mal
aft
ert
headdi
ti
on/
subt
ract
ionoper
ati
on.
I
nst
ruct
ionst
oper
for
m subt
ract
ion
SUB−Usedt
osubt
ractt
heby
tef
rom by
te/
wor
dfr
om wor
d.
SBB−Usedt
oper
for
m subt
ract
ionwi
thbor
row.
DEC−Usedt
odecr
ementt
hepr
ovi
dedby
te/
wor
dby1.
NPG−Usedt
onegat
eeachbi
toft
hepr
ovi
dedby
te/
wor
dandadd1/
2’s
compl
ement
.
CMP−Usedt
ocompar
e2pr
ovi
dedby
te/
wor
d.
AAS−Usedt
oadj
ustASCI
Icodesaf
tersubt
ract
ion.
DAS−Usedt
oadj
ustdeci
mal
aft
ersubt
ract
ion.
I
nst
ruct
iont
oper
for
m mul
ti
pli
cat
ion
MUL−Usedt
omul
ti
plyunsi
gnedby
tebyby
te/
wor
dbywor
d.
I
MUL−Usedt
omul
ti
plysi
gnedby
tebyby
te/
wor
dbywor
d.
AAM −Usedt
oadj
ustASCI
Icodesaf
termul
ti
pli
cat
ion.
I
nst
ruct
ionst
oper
for
m di
vi
sion
DI
V−Usedt
odi
vi
det
heunsi
gnedwor
dbyby
teorunsi
gneddoubl
ewor
dby
wor
d.
I
DIV−Usedt
odi
vi
det
hesi
gnedwor
dbyby
teorsi
gneddoubl
ewor
dbywor
d.
AAD−Usedt
oadj
ustASCI
Icodesaf
terdi
vi
sion.
CBW −Usedt
ofi
l
ltheupperby
teoft
hewor
dwi
tht
hecopi
esofsi
gnbi
toft
he
l
owerby
te.
CWD−Usedt
ofi
l
ltheupperwor
doft
hedoubl
ewor
dwi
tht
hesi
gnbi
toft
he
l
owerwor
d.
Bi
tMani
pul
ati
onI
nst
ruct
ions
Thesei
nst
ruct
ionsar
eusedt
oper
for
m oper
ati
onswher
edat
abi
tsar
einv
olv
ed,
i.
e.
oper
ati
onsl
i
kel
ogi
cal
,shi
ft
,et
c.
Fol
l
owi
ngi
sthel
i
stofi
nst
ruct
ionsundert
hisgr
oup−
I
nst
ruct
ionst
oper
for
mlogi
cal
oper
ati
on
NOT−Usedt
oinv
erteachbi
tofaby
teorwor
d.
AND−Usedf
oraddi
ngeachbi
tinaby
te/
wor
dwi
tht
hecor
respondi
ngbi
tin
anot
herby
te/
wor
d.
OR−Usedt
omul
ti
plyeachbi
tinaby
te/
wor
dwi
tht
hecor
respondi
ngbi
tin
anot
herby
te/
wor
d.
XOR−Usedt
oper
for
m Excl
usi
ve-
ORoper
ati
onov
ereachbi
tinaby
te/
wor
d
wi
tht
hecor
respondi
ngbi
tinanot
herby
te/
wor
d.
TEST−Usedt
oaddoper
andst
oupdat
efl
ags,
wit
houtaf
fect
ingoper
ands.
I
nst
ruct
ionst
oper
for
m shi
ftoper
ati
ons
SHL/
SAL−Usedt
oshi
ftbi
tsofaby
te/
wor
dtowar
dsl
eftandputzer
o(S)i
n
LSBs.
SHR−Usedt
oshi
ftbi
tsofaby
te/
wor
dtowar
dst
her
ightandputzer
o(S)i
n
MSBs.
SAR−Usedt
oshi
ftbi
tsofaby
te/
wor
dtowar
dst
her
ightandcopyt
heol
d
MSBi
ntot
henewMSB.
I
nst
ruct
ionst
oper
for
mrot
ateoper
ati
ons
ROL−Usedt
orot
atebi
tsofby
te/
wor
dtowar
dst
hel
eft
,i.
e.MSBt
oLSBand
t
oCar
ryFl
ag[
CF]
.
ROR−Usedt
orot
atebi
tsofby
te/
wor
dtowar
dst
her
ight
,i.
e.LSBt
oMSBand
t
oCar
ryFl
ag[
CF]
.
RCR−Usedt
orot
atebi
tsofby
te/
wor
dtowar
dst
her
ight
,i.
e.LSBt
oCFand
CFt
oMSB.
RCL−Usedt
orot
atebi
tsofby
te/
wor
dtowar
dst
hel
eft
,i.
e.MSBt
oCFandCF
t
oLSB.
St
ri
ngI
nst
ruct
ions
St
ri
ng i
s a gr
oup ofby
tes/
wor
ds and t
hei
rmemor
yis al
way
s al
l
ocat
ed i
na
sequent
ial
order
.
Fol
l
owi
ngi
sthel
i
stofi
nst
ruct
ionsundert
hisgr
oup−
REP−Usedt
orepeatt
hegi
veni
nst
ruct
iont
il
lCX≠0.
REPE/
REPZ−Usedt
orepeatt
hegi
veni
nst
ruct
ionunt
ilCX=0orzer
ofl
agZF
=1.
REPNE/
REPNZ−Usedt
orepeatt
hegi
veni
nst
ruct
ionunt
ilCX=0orzer
ofl
ag
ZF=1.
MOVS/
MOVSB/
MOVSW −Usedt
omov
etheby
te/
wor
dfr
om onest
ri
ngt
o
anot
her
.
COMS/
COMPSB/
COMPSW −Usedt
ocompar
etwost
ri
ngby
tes/
wor
ds.
I
NS/
INSB/
INSW −Usedasani
nputst
ri
ng/
byt
e/wor
dfr
om t
heI
/Opor
ttot
he
pr
ovi
dedmemor
ylocat
ion.
OUTS/
OUTSB/
OUTSW − Used as an out
putst
ri
ng/
byt
e/wor
dfr
om t
he
pr
ovi
dedmemor
ylocat
iont
otheI
/Opor
t.
SCAS/
SCASB/
SCASW −Usedt
oscanast
ri
ngandcompar
eit
sby
tewi
tha
by
tei
nALorst
ri
ngwor
dwi
thawor
dinAX.
LODS/
LODSB/
LODSW −Usedt
ost
oret
hest
ri
ngby
tei
ntoALorst
ri
ngwor
d
i
ntoAX.
Pr
ogr
am Execut
ionTr
ansf
erI
nst
ruct
ions(
BranchandLoopI
nst
ruct
ions)
Theseinst
ruct
ionsar
eusedtotransf
er/
brancht
hei
nst
ruct
ionsdur
inganexecut
ion.
I
tincl
udesthefoll
owi
nginst
ruct
ions−
I
nst
ruct
ionst
otr
ansf
ert
hei
nst
ruct
iondur
inganexecut
ionwi
thoutanycondi
ti
on−
CALL−Usedt
ocal
lapr
ocedur
eandsav
ethei
rret
urnaddr
esst
othest
ack.
RET−Usedt
oret
urnf
rom t
hepr
ocedur
etot
hemai
npr
ogr
am.
JMP− Used t
ojump t
othe pr
ovi
ded addr
ess t
o pr
oceed t
othe next
i
nst
ruct
ion.
I
nst
ruct
ionst
otr
ansf
ert
hei
nst
ruct
iondur
inganexecut
ionwi
thsomecondi
ti
ons−
JA/
JNBE−Usedt
ojumpi
fabov
e/notbel
ow/
equal
inst
ruct
ionsat
isf
ies.
JAE/
JNB−Usedt
ojumpi
fabov
e/notbel
owi
nst
ruct
ionsat
isf
ies.
JBE/
JNA−Usedt
ojumpi
fbel
ow/
equal
/notabov
einst
ruct
ionsat
isf
ies.
JC−Usedt
ojumpi
fcar
ryf
lagCF=1
JE/
JZ−Usedt
ojumpi
fequal
/zer
ofl
agZF=1
JG/
JNLE−Usedt
ojumpi
fgr
eat
er/
notl
esst
han/
equal
inst
ruct
ionsat
isf
ies.
JGE/
JNL− Used t
ojump i
fgr
eat
ert
han/
equal
/notl
esst
han i
nst
ruct
ion
sat
isf
ies.
JL/
JNGE− Used t
ojump i
fless t
han/
notgr
eat
ert
han/
equali
nst
ruct
ion
sat
isf
ies.
JLE/
JNG−Usedt
ojumpi
flesst
han/
equal
/i
fnotgr
eat
ert
hani
nst
ruct
ion
sat
isf
ies.
JNC−Usedt
ojumpi
fnocar
ryf
lag(
CF=0)
JNE/
JNZ−Usedt
ojumpi
fnotequal
/zer
ofl
agZF=0
JNO−Usedt
ojumpi
fnoov
erf
lowf
lagOF=0
JNP/
JPO−Usedt
ojumpi
fnotpar
it
y/par
it
yoddPF=0
JNS−Usedt
ojumpi
fnotsi
gnSF=0
JO−Usedt
ojumpi
fov
erf
lowf
lagOF=1
JP/
JPE−Usedt
ojumpi
fpar
it
y/par
it
yev
enPF=1
JS−Usedt
ojumpi
fsi
gnf
lagSF=1
Pr
ocessorCont
rol
Inst
ruct
ions
Thesei
nstr
uct
ionsar
eusedt
ocont
rolt
hepr
ocessoract
ionbyset
ti
ng/
reset
ti
ngt
he
fl
agval
ues.
Fol
l
owi
ngar
ethei
nst
ruct
ionsundert
hisgr
oup−
STC−Usedt
osetcar
ryf
lagCFt
o1
CLC−Usedt
ocl
ear
/resetcar
ryf
lagCFt
o0
CMC−Usedt
oputcompl
ementatt
hest
ateofcar
ryf
lagCF.
STD−Usedt
osett
hedi
rect
ionf
lagDFt
o1
CLD−Usedt
ocl
ear
/resett
hedi
rect
ionf
lagDFt
o0
STI−Usedt
osett
hei
nter
ruptenabl
efl
agt
o1,
i.
e.,
enabl
eINTRi
nput
.
CLI−Usedt
ocl
eart
hei
nter
ruptenabl
efl
agt
o0,
i.
e.,
disabl
eINTRi
nput
.
I
ter
ati
onCont
rolI
nst
ruct
ions
Thesei
nst
ructi
onsareusedtoexecutethegiv
eni nst
ruct
ionsf
ornumberoft
imes.
Fol
lowi
ngi
st hel
istofi
nst
ruct
ionsunderthi
sgroup−
LOOP−Usedt
oloopagr
oupofi
nst
ruct
ionsunt
ilt
hecondi
ti
onsat
isf
ies,i
.e.
,
CX=0
LOOPE/
LOOPZ−Usedt
oloopagr
oupofi
nst
ruct
ionst
il
litsat
isf
iesZF=1&
CX=0
LOOPNE/
LOOPNZ−Usedt
oloopagr
oupofi
nst
ruct
ionst
il
li
tsat
isf
iesZF=0
&CX=0
JCXZ−Usedt
ojumpt
othepr
ovi
dedaddr
essi
fCX=0
I
nter
ruptI
nst
ruct
ions
Thesei
nst
ruct
ionsar
eusedt
ocal
lthei
nter
ruptdur
ingpr
ogr
am execut
ion.
I
NT−Usedt
oint
err
uptt
hepr
ogr
am dur
ingexecut
ionandcal
l
ingser
vice
speci
fi
ed.
I
NTO−Usedt
oint
err
uptt
hepr
ogr
am dur
ingexecut
ioni
fOF=1
I
RET−Usedt
oret
urnf
rom i
nter
ruptser
vicet
othemai
npr
ogr
am
Addr
essi
ngmodesof8086:
Addr
essi
ngmodei
ndi
cat
esawayofl
ocat
ingdat
aoroper
ands.
Theaddr
essi
ngmodesdescr
ibet
het
ypesofoper
andsandt
hewayt
heyar
e
accessedf
orexecut
ingani
nst
ruct
ion.
Accor
dingt
othef
lowofi
nst
ruct
ionexecut
ion,
thei
nst
ruct
ionsmaybecat
egor
ized
as
i
)Sequent
ial
cont
rol
flowi
nst
ruct
ionsand
i
i
)Cont
rol
transf
eri
nst
ruct
ions
Sequenti
alcontr
olf
lowi nst
ructi
onsaret heinst
ructi
ons,whichafterexecut
ion,t
ransfer
contr
oltothenexti
nstructi
onappearingi mmediatel
yaf t
erit(
inthesequence)inthe
progr
am.Forex ample,
thear i
thmeti
c,logic,
datatransferandprocessorcontrol
instr
ucti
ons
aresequenti
alcont
rolf
lowi nstr
uct
ions.
Thecont
roltr
ansferi
nst
ruct
ions,
ontheotherhand,transfercontr
ol t
osomepr edefined
addr
essortheaddresssomehowspecif
iedintheinstruct
ion,aft
ertheirexecut
ion.For
exampl
e,I
NT, CALL,RETandJUMPinstruct
ionsfall
undert hi
scat egory.
Theaddr
essi
ngmodesf
orsequent
ial
cont
rol
transf
eri
nst
ruct
ionsar
e:
1.I
mmedi
ate:Inthi
stypeofaddr
essing,
immedi
atedat
aisapar
tofi
nst
ruct
ionandappear
s
i
nthef
orm ofsuccessi
vebyt
eorbytes.
Ex:
MOVAX,
0005H
I
ntheaboveexampl
e,0005Hi
sthei
mmedi
atedat
a.Thei
mmedi
atedat
amaybe8-
bitor16-
bi
tinsi
ze.
2.Dir
ect
:Int
hedirectaddressi
ngmodea16-
bitmemor
yaddr
ess(
off
set
)isdi
rect
ly
speci
fi
edint
heinstruct
ionasapartofi
t.
Ex:
MOVAX,
[5000H]
Here,
dat aresi
desinamemor ylocat
ioninthedat
asegment,
whoseeff
ecti
veaddressmay
becompl et
edusing5000Hast heoffsetaddr
essandcont
entofDSassegmentaddress.
Theeffecti
veaddressher
e,i
s10H*DS+5000H.
3.Regi
ster
:Inregi
steraddressi
ngmode,t hedat
aisst
oredi
naregi
sterandi
sref
err
edusi
ng
thepar
ti
cularr
egist
er.Allheregi
ster
s,exceptI
P,maybeusedi
nthi
smode.
Ex:
MOVBX,
AX
4.Regist
erIndi
rect:Somet i
mes, t
headdr essofthememor yl
ocati
on,whichcont
ainsdataor
operand,i
sdeterminedinani ndir
ectway ,usi
ngt heoff
setregi
ster
.Thismodeofaddr essi
ng
i
sknownasr egi
sterindi
rectmode.Int hisaddressingmode,theoffsetaddr
essofdataisin
ei
therBXorSIorDIr egi
ster.ThedefaultsegmentiseitherDSorES.
Thedat
aissupposedtobeavail
ableatt
headdr
esspoi
ntedt
obyt
hecont
entofanyoft
he
abov
eregi
ster
sinthedefaul
tdatasegment
.
Ex:
MOVAX,
[BX]
Here,dat
aispr
esentinamemoryl
ocat
ioninDSwhoseof
fsetaddr
essi
sinBX.Theef
fect
ive
addressoft
hedataisgi
venas10H*DS+[BX]
.
5.I
ndexed:
Int
hisaddr
essi
ngmode,
off
setoft
heoper
andi
sst
oredi
noneoft
hei
ndex
r
egi
ster
s.DSandESarethedef
aultsegment
sfori
ndexr
egi
ster
s,SIandDIr
espect
ivel
y.Thi
s
i
saspecial
caseofr
egi
steri
ndi
rectaddr
essi
ngmode.
Ex:
MOVAX,
[SI
]
Here,
datai
savai
labl
eatanof
fsetaddr
essst
oredi
nSIi
nDS.Theef
fect
iveaddr
ess,
int
his
case,
iscomput
edas10*DS+[
SI]
.
6.Regi
sterRel
ati
ve:Int
hisaddressingmode,thedat
aisavai
lableataneff
ect
iveaddress
for
medbyaddi ngan8-bi
tor16-bitdispl
acementwit
hthecontentofanyoneoftheregist
ers
BX,BP,SIandDIinthedefaul
t(eit
herDSorES)segment.
Ex:
MOVAX,
50H[
BX]
Her
e,t
heef
fect
iveaddr
essi
sgi
venas10H*
DS+50H+[
BX]
7.BasedIndexed:Theeff
ecti
v eaddressofdat
ai sf
ormed,
inthi
saddressi
ngmode,by
addingcontentofabaseregister(
anyoneofBXorBP)t othecont
entofanindexr
egi
ster
(anyoneofSIorDI )
.Thedefaultsegmentregi
stermaybeESorDS.
Ex:
MOVAX,
[BX]
[SI
]
Here,BXist
hebaser egi
sterandSIistheindexregist
ert
heeff
ecti
veaddr
essiscomput
ed
as10H*DS+Rel at
iveBasedIndexed:Theeffecti
veaddr
essisfor
medbyaddingan8or16-
bi
tdispl
acementwiththesum ofthecontentsofanyoneofthebaseregi
ster(
BXorBP)and
anyoneoftheindexregi
ster,
inadefaultsegment.
Ex:
MOVAX,
50H[
BX][
SI]
Here,
50Hisanimmediat
edispl
acement
,BXi
sbaser
egi
sterandSIi
sani
ndexr
egi
stert
he
ef
fect
iveaddr
essofdat
aiscomputedas
10H*DS+[
BX]+[
SI]+50H
Forcont
rolt
ransferi
nstr
uct
ions,
theaddr
essi
ngmodesdependuponwhet hert
he
desti
nat
ioni
swi t
hinthesamesegmentordif
ferentone.I
tal
sodependsupont
hemet
hodof
passi
ngthedesti
nati
onaddresstothepr
ocessor.
Basi
cal
ly
,ther
earetwoaddressi
ngmodesforthecont
rol
transf
eri
nst
ruct
ions,
int
ersegment
addr
essi
ngandintr
asegmentaddressi
ngmodes.
I
fthel
ocat
iontowhi
chthecont
roli
stobetransf
err
edl
i
esi
nadi
ff
erentsegmentot
hert
han
t
hecurr
entone,t
hemodeiscal
ledi
nter
segmentmode.
I
fthedest
inat
ionl
ocat
ionl
i
esi
nthesamesegment
,themodei
scal
l
edi
ntr
asegmentmode.
[BX]+[ SI]9.IntrasegmentDi r
ectMode:Inthi
smode, t
headdr esstowhichthecontr
ol i
sto
betransferredliesint hesamesegmenti nwhichthecontrol
transf
erinstr
ucti
onli
esand
appearsdi r
ect l
yint heinstr
uct
ionasanimmedi at
edispl
acementv alue.I
nthisaddr
essing
mode, t
hedi spl
acementi scomputedr
elati
vetothecontentoftheinstr
ucti
onpoint
erIP.
Theef
fecti
veaddresst
owhichthecontr
ol wil
lbetr
ansferr
edisgivenbyt hesum of8or16-
bi
tdi
splacementandcurr
entcont
entofIP.Inthecaseofjumpinstruct
ion,ift
hesigned
di
spl
acement(d)isof8-
bit
s(i.
e–128<d<+128)wet er
mi tasshortjumpandi fiti
sof16-bi
ts
(
i.
e-32,
768<d<+32,
768)i
tist
ermedasl
ongj
ump.
10.IntrasegmentIndi
rectMode:Inthismode, thedi
splacementtowhi chthecontroli
stobe
transferr
ed,i
sinthesamesegmenti nwhi chthecont
roltransf
erinstr
ucti
onli
es,butitis
passedt otheinst
ruct
ionindir
ectl
y.Here,thebranchaddressisfoundast hecontentofa
registeroramemor ylocat
ion.Thi
saddr essingmodemaybeusedi nuncondi
ti
onal br
anch
i
nst ructi
ons.
11.I
ntersegmentDir
ect:I
nthi
smode,
theaddr
esst
owhi
cht
hecont
rol
ist
obet
ransf
err
edi
s
i
nadi f
ferentsegment.
Thisaddressi
ngmodeprov
idesameansofbr
anchingf
rom onecodesegmenttoanot
her
codesegment .Her
e,t
heCSandIPoft
hedest
inat
ionaddr
essarespeci
fi
eddir
ectl
yinthe
i
nstruct
ion.
12.Int
ersegmentIndi
rect:I
nthismode, t
headdr
esst owhichthecontroli
stobetransfer
red
l
iesinadiffer
entsegmentandi ti
spassedtotheinstr
uct
ionindirect
ly,
i.
econtent
sofa
memor yblockcontai
ningfourbytes,i
.eI
P(LSB)
,IP(MSB),CS(LSB)andCS( MSB)
sequenti
all
y.Thestart
ingaddressofthememoryblockmayber efer
redusinganyofthe
addressi
ngmodes, exceptimmedi at
emode.