0% found this document useful (0 votes)
110 views

MPMC Lab Student Manual

This document appears to be the cover page and table of contents for a lab manual for a Microprocessors and Microcontrollers laboratory course. It lists the name of the college and department, along with 16 experiments to be conducted across two cycles that involve arithmetic operations, data transfers, programming, and interfacing with devices like keyboards, displays, and motors using microprocessors like 8085 and microcontrollers like 8051. It also includes augmented experiments on studying the 8085 microprocessor.

Uploaded by

Nandhini Shree
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
110 views

MPMC Lab Student Manual

This document appears to be the cover page and table of contents for a lab manual for a Microprocessors and Microcontrollers laboratory course. It lists the name of the college and department, along with 16 experiments to be conducted across two cycles that involve arithmetic operations, data transfers, programming, and interfacing with devices like keyboards, displays, and motors using microprocessors like 8085 and microcontrollers like 8051. It also includes augmented experiments on studying the 8085 microprocessor.

Uploaded by

Nandhini Shree
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 118

Col

l
egeofEngi
neer
ing&Technol
ogy

Kot
handar
amanNagar
,Dindi
gul
-624622.
Tami
lNadu.

DEPARTMENTOFI
NFORMATI
ON

TECHNOLOGYSTUDENTSLABMANUAL

EC8681-
MICROPROCESSORSAND
MI
CROCONTROLLER LABORATORY
Name : ……………………….
Regi
sterNo: ……………………….
.
Year&Sec: ……………………….
.

1
PSNA
Col
l
egeofEngi
neer
ing&Technol
ogy

Kot
handar
amanNagar
,Di
ndi
gul
-624622.TAMI
LNADU.

RECORDNOTEBOOK

Reg.
No.

Cert
if
ythatt
hisi
sthebonaf
ider
ecor
dofwor
k
done by
Sel
van/
Sel
vi
…………….
…….
…………………….
..
oft
hesi
xthsemest
er,
B.
E -BI CAL Br
OMEDI anch dur
ing t
hey
ear2022-
2023 i
n
EC8681-

Mi
cropr
ocessor
s&Mi
crocont
rol
l
ersLabor
ator
y.

St
aff-
in-Char
ge Headoft
he
Depar
t ment

Submi
tt
edf
ort
heUni
ver
sit
y
Pr
act
ical
Exami
nat
ionon 2023

I
nter
nal
Exami
ner Ex
ter
nal
Exami
ner

2
Sl Nameoft
heExper
iment
s Mar
ks Page Si
gn
No. No.
1. Basi
car
it
hmet
icandLogi
cal
oper
ati
ons
2. Mov
eadat
abl
ockwi
thoutov
erl
ap
3. Codeconversi
on,Decimalari
thmeticand
Matri
xOperati
ons
4. Fl
oati
ngpointoperati
ons,St
ri
ng
manipul
ati
ons,Sorti
ngandSearching
5. PasswordChecking,Pri
ntRam si
zeand
syst
em update
6. Counter
sandTimedel ays.
7. Tr
aff
icLi
ghtcont
rol
l
er
8. St
eppermot
orcont
rol
.
9. Di
git
alcl
ock
10. Key
boar
dandDi
spl
ay
11. Pr
int
erst
atus.

12. Ser
ial
Int
erf
aceandPar
all
erI
nter
face.

13. Basi
car
it
hmet
icandLogi
cal
oper
ati
ons
14 Bi
tMani
pul
ati
on
15 Squar
eandCubepr
ogr
am
16 BCDt
oASCI
IConv
ersi
on

AUGMENTEDLABEXPERI
MENT

Sl Nameoft
heExperi
ments Mar
ks Page Si
gn
No. No.
1. Studyof8085(
8bit)microprocessor
2. Ar
it
hmet
icoper
ati
onsusi
ng8085

3
PSNA
COLLEGEOFENGI
NEERI
NGANDTECHNOLOGY
KOTHANDARAMANNAGAR,
DINDI
GUL-624622

OBSERVATI
ONNOTEBOOK

MI
CROPROCESSORSANDMICROCONTROLLERS
LABORATORY
LabcodeEC8681
Depar
tmentofBi
o-Medi
cal
Engi
neer
ing

Name-
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--Rol
lNo.-
--
--
--
--
--
--
--
--
--
--
--

Year-
--
--
--
--
--
--Br
anch-
--
--
--
--
--
-Semest
er-
--
--
--
--
--
-

4
LI
STOFEXPERI
MENTS

CYCLE-
I

1.Basi
cari
thmeticandLogi
caloper at
ions
2.Mo v
eaDat aBlockWit
houtOv er
lap
3.Codeconversi
on,deci
malar
ithmet i
candMat
ri
x
Operati
ons.
4.Fl
oatingpointoper
ati
ons,st
ri
ngmanipul
ati
ons,sort
ingandsear
chi
ng
5.PasswordChecking,Pri
ntRam Si
zeAndSystem Date
6.CountersandTimeDelay
7.Tr
afficli
ghtcontr
ol
8.St
eppermot orcontr
ol

CYCLE-
II

9.Di
git
alcl
ock

Keyboar
10. dandDi
spl
ay

Pr
11. i
nterst
atus

Ser
12. ial
int
erf
aceandPar
all
eli
nter
face

A/
13. DandD/
Aint
erf
aceandWav
efor
m Gener
ati
on

Basi
14. car
it
hmet
icandLogi
cal
oper
ati
onsUSI
NG8051

Squar
15. eandCubepr
ogr
am,
Find2’
scompl
ementofa
Number

16.UnpackedBCD t
oASCI
I

Augument
edExper
iment
s

1.
Studyof8085(
8bit
)micr
oprocessor
2.Ari
thmeti
coper
ati
onsusi
ng8085

5
6
EXPTNO:
01
DATE:
AI
M:
To wr
ite an Assembl
y Language Pr
ogr
am (
ALP)f
orper
for
ming t
he
Ar
it
hmet
icoperat
ionoftwobyt
enumber s.

APPARATUSREQUI
RED:

SL.
N I
TEM SPECIFI
CATI
ON QUANTI
TY
O
1. Mi
cropr
ocessorki
t 8086kit 1
2. PowerSupply +5Vdc 1

PROBLEM STATEMENT:
WriteanALPi n8086toaddandsubtracttwoby t
enumber sstor
edi n
thememor ylocati
on1000Ht o1003Handst orether esulti
nthememor y
l
ocation1004Ht o1005H.Al
soprovi
deaninstructi
onint heaboveprogram
toconsi derthecar r
yalsoandst or
ethecar r
yi nthememor ylocation
1006H.
ALGORI THM:
(i
)16-bitaddit
ion (i
i
i) Mul ti
pli
cati
on of 16-

I
nit
ial
i
zet
heMSBsofsum t
o0 bi
tnumber
s:
 
Gett
hef
ir
stnumber
. Gett
hemul
ti
pli
er.
 
Gett
hemul
ti
pli
cand
Addthesecondnumbert
othef
ir
st 
number
. I
nit
ial
i
zet
hepr
oductt
o0.
 
I
fther
eisanycar r
y,i
ncr
ement Pr
oduct = pr
oduct +

MSBsofsum by1.
St
oreLSBsofsum. mult
ipl
i
cand
 
St
oreMSBsofsum. Decr
ementt
hemul
ti
pli
erby1

I
fmul ti
pli
candisnotequalt o
(
ii
)16-
bitsubt
ract
ion 0,
repeat f rom step ( d)

I
nit
ial
i
zet
heMSBsofdi
ff
erencet
o ot
herwisestoret
heproduct
.
0 (
iv) Di
vi
sionof16-
bitnumber
s.
 
Gett
hef
ir
stnumber Gett
hedi
vi
dend

 Gett
hedi
vi
sor
Subt
ractt
hesecondnumberf
rom t
he 
f
ir
stnumber. I
nit
ial
i
zet
hequot
ientt
o0.

 Di
vi
dend=di
vi
dend–di
vi
sor
Ift
hereisanybor
row,
incr
ementMSBs 
ofdi

f
fer
enceby1. I
ft hedi
visorisgreat
er,st
oret
he
St
oreLSBsofdi
ff
erence quoti
ent
.Got ost
epg.

St
oreMSBsofdi
ff
erence.

I
f di vidend is gr eater
,
quoti
ent= quot ient+ 1.
Repeatf rom st
ep( d)
Store
the di vi
dend v alue as
remainder.

7
8
FLOWCHART

ADDI
TION SUBTRACTI
ON

START START

SETUPCOUNTER(
CY) SETUPCOUNTER(
CARRY)

GETFI
RSTOPERAND GETFIRST
OPERANDTOA

GETSECONDOPERAND SUBTRACT
TO A SECONDOPERAND
FROM MEMORY

YES
A=A+B
I
STHERE
ANYCY
YES
I
STHERE NO COUNTER=
ANYCARRY COUNTER +1
COUNTER=
COUNTER+1
STORETHE
NO DIFFERENCE

STORETHESUM
STORETHECARRY

9
ADDI
TION
ADDRESS Opcodes PROGRAM COMMENTS

MOVCX,
0000H I
nit
ial
i
zecount
erCX

MOVAX,
[
1200] Gett
hef
ir
stdat
ainAXr
eg

MOVBX,
[1202] Gett
heseconddat
ainBXr
eg

ADDAX,
BX Addthecont
ent
sofbot
hthe
regsAX&BX

JNCL1 Checkf
orcar
ry

I
NCCX I
fcar
ryexi
sts,
incr
ementt
he
CX

L1:
MOV[
1206]
,
CX St
oret
hecar
ry

MOV[
1204]
,AX St
oret
hesum

HLT St
opt
hepr
ogr
am

SUBTRACTI
ON
ADDRESS OPCODES PROGRAM COMMENTS

MOVCX,
0000H I
nit
ial
i
zecount
erCX

MOVAX,
[
1200] Gett
hef
ir
stdat
ainAXr
eg

MOVBX,
[1202] Gett
heseconddat
ainBXr
eg

Subt
ractt
hecont
ent
sofBX
SUBAX,
BX fr
om
AX

JNCL1 Checkf
orbor
row

I
NCCX I
fbor
rowexi
sts,
incr
ementt
he
CX

L1:
MOV[
1206]
,
CX St
oret
hebor
row

MOV[
1204]
,AX St
oret
hedi
ff
erence

10
HLT St
opt
hepr
ogr
am

RESULT:
.
ADDI
TION

MEMORY

DATA

SUBTRACTI
ON

MEMORY

DATA

MANUALCALCULATI
ON

11
YES

FLOWCHART STORETHERESULT

MULTI
PLI
CATI
ON

St
art

GetMult
ipl
i
er&
Mult
ipl
i
cand
MULTIPLI
CAND

REGI
STER=00

REGI
STER=REGI
STER
+MULTI
PLI
CAND

Mul
ti
pli
er=MULTI
PLI
ER–1

NO I
S
MULTIPLI
ER=0?

12
DI
VISI
ON

St
art

LoadDivi
sor&
Divi
dend

QUOTI
ENT=0

DI
VIDEND=
DI
VIDEND-
DIVISOR

QUOTI
ENT=
QUOTI
ENT+1

I
S
NO DI
VIDEN
D<
DI
VISOR
?

YES

STORE
QUOTI
ENT
STORE
REMAI
NDER

13
MULTI
PLI
CATI
ON

ADDRESS Opcodes PROGRAM COMMENTS

Getthef
ir
st
MOVAX,
[
1200] dat
a

MOVBX,
[1202] Gett
heseconddat
a

MULBX Mul
ti
plybot
h

MOV[
1206]
,
AX St
oret
hel
oweror
derpr
oduct

MOVAX,
DX Copyt
hehi
gheror
derpr
oductt
o
AX
MOV[
1208]
,
AX St
oret
hehi
gheror
derpr
oduct

St
opthe
HLT pr
ogr
am

DI
VISI
ON

ADDRESS Opcodes PROGRAM COMMENTS

Getthef
ir
st
MOVAX,
[
1200] dat
a

MOVDX,
[1202] Gett
heseconddat
a

MOVBX,
[1204] Di
vi
det
hedi
vi
dendbydi
vi
sor

DI
VBX St
oret
hel
oweror
derpr
oduct

Copythehi
gheror
derpr
oduct
MOV[
1206]
,
AX to
AX
MOVAX,
DX Stor
ethehi
gheror
derpr
oduct

St
opthe
MOV[
1208]
,
AX pr
ogr
am

Getthef
ir
st
HLT dat
a

14
RESULT:

MULTI
PLI
CATI
ON

MEMORY

DATA

DI
VISON

MEMORY

DATA

MANUALCALCULATI
ON

15
ThusAri
thmet
icoper
ati
onsoft
woby
tenumber
sar
eper
for
medandt
her
esul
tis
st
ored.

16
EXP.
NO:
02 DATE:
AI
M:
Toconver
tagi
venMov
eadat
abl
ockwi
thoutov
erl
ap
.
ALGORI
THM:
1.
Ini
ti
ali
zethememor ylocat
iontothedatapointer
.
2.
Incr
ementBr egister.
3.
Incr
ementaccumul at
orby1andadj ustitt
odecimal ev
eryti
me.
4.
Compar ethegi vendecimal numberwithaccumulatorval
ue.
5.
Whenbot hmat ches,theequival
enthexadeci
mal val
ueisinBregi
ster
.
6.
Storetheresultantinmemor yl
ocati
on.

PROGRAM:

DATASEGMENT
X DB01H,
02H,03H,
04H,
05H;
Ini
ti
ali
zeDat
aSegment
sMemor
yLocat
ions
Y DB05DUP(0)
DATAENDS
CODESEGMENT
ASSUMECS: CODE, DS:DATA
START:MOVAX, DATA; I
niti
alizeDStopoi
nttostartofthememoryMOVDS,
AX; set
asi
deforstori
ngofdat a
MOVCX, 05H; Loadcount er
LEASI,X+04;SIpointerpointedtotopoft
hememor yblock
LEADI,X+04+03; 03isdisplacementofoverl
apping,DIpoi
ntedt
o;t
het
opofthe
dest
inati
onblock
CODEENDS
ENDSTART

Out
put
:

RESULT:
Thustheoutputf
ort
heMov
eadat
abl
ockwi
thoutov
erl
apwasexecut
ed
successf
ull
y

17
EXP.
NO:
03 CODECONVERSI
ONS–DECI
MALTOHEX DATE:
AI
M:
Toconv
ertagi
vendeci
mal
numbert
ohex
adeci
mal
.
ALGORITHM:
1.
Ini
ti
ali
zethememor ylocat
iontothedatapointer
.
2.
Incr
ementBr egister.
3.
Incr
ementaccumul at
orby1andadj ustitt
odecimal ev
eryti
me.
4.
Compar ethegi vendecimal numberwithaccumulatorval
ue.
5.
Whenbot hmat ches,theequival
enthexadeci
mal val
ueisinBregi
ster
.
6.
Storetheresultantinmemor yl
ocati
on.
FLOWCHART:

18
PROGRAM:

I
NPUT OUTPUT

MEMORY

DATA

19
CODECONVERSI
ON–HEXADECI
MALTODECI
MAL
AIM:
Toconvertagi v
enhexadeci mal numbert odeci
mal .
ALGORITHM:
1.Init
ial
i
zet hememor ylocati
ontothedatapoi nt
er.
2.I
ncrementBr egist
er.
3.I
ncrementaccumul atorby1andadj ustitt
odecimal ever
yt ime.
4.Compar ethegi venhexadecimalnumberwi thBr egistervalue.
5.Whenbot hmat ch,t
heequi v
alentdecimalval
ueisi nAr egister
.
6.Storetheresultanti
nmemor ylocati
on.

20
RESULT:
MEMORY

DATA

21
DECI
MALARI
THMETI
CANDMATRI
XOPERATI
ONS
AI
M:
Towr
it
eapr
ogr
am f
oraddi
ti
onoft
womat
ri
xbyusi
ng8086.
APPARATUSREQUI
RED:
8086Mi
cropr
ocessorKi
t
ALGORI
TH:
1.
Ini
ti
ali
zethepoint
eronlyf
ordataandr
esul
t
2.
LoadALwi thcount
3.
Addt womat r
ixbyeachel
ement
4.
Processconti
nuesunti
lCLiszero
5.
Storeresul
t.

FLOWCHART

22
23
PROGRAM

RESULT:

MEMORY

DATA

Thust
heout
putf
ort
headdi
ti
onf
ort
womat
ri
xeswasexecut
edsuccessf
ull
y.

24
EXPTNO:
04 COPYI
NGASTRI NG DATE:
AIM:
Tomov
east
ri
ngofl
engthFFf
rom sour
cet
odest
inat
ion.

ALGORITHM:
a.Init
iali
zethedatasegment. (DS)
b.Init
iali
zetheextradatasegment. (
ES)
c.Init
iali
zethestartofstr
ingintheDS.(SI
)
d.Init
iali
zethestartofstr
ingintheES.(DI
)
e.Mov ethelengt
hoft hestr
ing(FF)i
nCXregi
ster
.
f. Mov ethebytefr
om DSTOES, t
il
lCX=0.

START

I
nit
ial
i
zeDS,
ES,
SI,
DI

CX=lengt
hofst
ri
ng,
DF=0.

Moveabytefrom sourcestr
ing
(
DS)todesti
nati
onst r
ing(ES)

Decr
ementCX

NO

Checkf
or
ZF=1

STOP

25
COPYI
NGASTRING
ADDRESS OPCODES PROGRAM COMMENTS

MOVSI
,
1200H I
nit
ial
i
zedest
inat
ionaddr
ess

MOVDI
,
1300H I
nit
ial
i
zest
art
ingaddr
ess

MOVCX,
0006H I
nit
ial
i
zear
raysi
ze

CLD Cl
eardi
rect
ionf
lag

REPMOVSB Copythecontent
sofsourceint
o
dest
inat
ionunti
lcountr
eacheszer
o
HLT Stop

RESULT:

I
NPUT
MEMORY

DATA

OUTPUT

MEMORY

DATA

Thusastr
ingofapar
ti
cul
arl
engt
hismov
edf
rom sour
cesegmentt
odest
inat
ion
segment

26
27
SEARCHI
NGASTRI
NG
AIM:
Toscanforagiv
enbyteinthestr
ingandf
indt
her
elat
iveaddr
essoft
heby
te
fr
om t
hestar
ti
nglocati
onofthestr
ing.

ALGORI
THM:
a.Init
iali
zetheextrasegment.(
ES)
b.Init
iali
zethestartofst
ri
ngintheES.(DI)
c.Mov ethenumberofelementsinthestri
ngi
nCXr egi
ster
.
d.Mov ethebyt
et obesearchedintheALregi
ster
.
e.Scanf orthebyteinES.Ift
heby t
eisfoundZF=0,movetheaddr
esspoi
ntedby
ES:DItoBX.
START

I
nit
ial
i
zeDS,
ES,
SI,
DI

CX=lengt
hoft
hest
ri
ng,
DF=0.

Scanforaparti
cul
ar
char
acterspeci
fi
edinAL
Regi
ster.

NO

Checkf
or
ZF=1

Mov
eDIt
oBX

STOP

28
29
SEARCHI
NGFORACHARACTERI
NTHESTRI
NG
ADDRESS OPCODES PROGRAM COMMENTS

MOVDI
,
1300H I
nit
ial
i
zedest
inat
ionaddr
ess

MOVSI
,1400H I
nit
ial
i
zest
art
ingaddr
ess

MOVCX,
0006H I
nit
ial
i
zear
raysi
ze

CLD Cl
eardi
rect
ionf
lag

MOVAL,
08H St
oret
hest
ri
ngt
obesear
ched

REPNESCASB Scanunt
ilt
hest
ri
ngi
sfound

DECDI Decr
ementt
hedest
inat
ionaddr
ess

MOVBL,
[
DI] St
oret
hecont
ent
sint
oBLr
eg

Stor
econtentofBLi
nsour
ce
MOV[
SI]
,
BL address

HLT St
op

RESULT:

I
NPUT

MEMORY

DATA

OUTPUT

MEMORY

DATA

30
Thusagi
v enbyteorwordinastringofaparti
cul
arlengthi
ntheextr
a
segment
(desti
nati
on)isfound.
FI
NDANDREPLACE
AIM:
Tof i
ndachar act
erinthestri
ngandrepl
aceitwithanot
hercharact
er.

ALGORITHM:
a.Initiali
zetheextrasegment. (ES)
b.Initiali
zethestartofstri
ngi ntheES.(DI
)
c.Mov ethenumberofel ement sinthestr
inginCXr egi
ster.
d.Mov ethebyt
et obesear chedi ntheALregist
er.
e.St oret heASCIIcodeoft hechar act
erthathast oreplacethescanned
by teinBLregister.
f. Scanf orthebytei nES.Iftheby t
eisnotfound,ZF≠1andr epeatscanni
ng.
g.Ift heby t
eisfound, ZF=1.Movet hecont
entofBLr egist
ertoES:DI.
START

I
nit
ial
i
zeDS,
ES,
SI,
DI

CX=lengt
hoft
hest
ri
ngi
nES,
DF=0.

Scanforaparti
cul
ar
char
acterspeci
fi
edinAL
Regi
ster.

NO

Checkf
orZF=1

YES

Movet
hecont
entof
BLt
oES:DI

STOP

31
32
FI
NDANDREPLACEACHARACTERINTHESTRI
NG
ADDRESS OPCODES PROGRAM COMMENTS

MOVDI
,
1300H I
nit
ial
i
zedest
inat
ionaddr
ess

MOVSI
,
1400H I
nit
ial
i
zest
art
ingaddr
ess

MOVCX,
0006H I
nit
ial
i
zear
raysi
ze

CLD Cl
eardi
rect
ionf
lag

MOVAL,
08H St
oret
hest
ri
ngt
obesear
ched

MOVBH,
30H St
oret
hest
ri
ngt
ober
epl
aced

REPNESCASB Scanunt
ilt
hest
ri
ngi
sfound

DECDI Decr
ementt
hedest
inat
ionaddr
ess

MOVBL,
[
DI] St
oret
hecont
ent
sint
oBLr
eg

MOV[
SI]
,
BL St
orecont
entofBLi
nsour
ceaddr
ess

MOV[
DI]
,
BH Repl
acet
hest
ri
ng

HLT St
op

RESULT:

I
NPUT

MEMORY

DATA

OUTPUT

MEMORY

DATA

Thusagi
v enbyteorwordi
nastri
ngofapart
icul
arl
engt
hintheext
ra
segment
(desti
nati
on)i
sfoundandisr
epl
acedwithanot
herchar
act
er.
33
34
ASCENDI
NG&DESCENDI
NG

AI
M:
Towri
teanAssemblyLanguagePr
ogr
am (
ALP)t
osor
tagi
ven
ar
rayi
nascendi
nganddescendi
ngorder
.

APPARATUSREQUI
RED:

SL.
N I
TEM SPECI
FICATI
ON QUANTI
TY
O
1. Mi
cropr
ocessorki
t 8086 1
2. PowerSupply +5Vdc 1

PROBLEM STATEMENT:

Anarr
ayofl
ength10i
sgiv
enfrom t
helocati
on.Sor
titi
nto
descendi
ngandascendi
ngor
derandst
oretheresult
.

ALGORI
THM:
(i
) Sorti
ngi
nascendi
ngor
der
:
a.Loadthearraycountintworegi
ster
sC1andC2.
b.Getthefi
rsttwonumber s.
c.Comparet henumber sandexchangei fnecessar
ysot hatthetwo
numbersareinascendingorder
.
d.Decr
ementC2.
e.Getthethi
rdnumberf rom t
hearrayandrepeatt
heprocessunti
lC2i
s
0.
f.Decr
ementC1andr epeatt
heprocessunti
lC1is0.
(
ii
) Sor
ti
ngi
ndescendi
ngor
der
:
a.Loadthearraycountintworegi
stersC1andC2.
b.Getthefi
rsttwonumber s.
c.Comparet henumber sandexchangei fnecessar
ysot hatthetwo
numbersareindescendingorder.
d.Decr
ementC2.
e.Getthethi
rdnumberf rom t
hear r
ayandr epeatt
heprocessunti
lC2i
s
0.
f.Decr
ementC1andr epeatt
hepr ocessunti
lC1is0.

35
FLOWCHART
ASCENDI
NGORDER

START

I
NITI
ALI
ZEPOI
NTER

COUNT=COUNT–1

YES
I
SPOI
NTER
POI
NTER

NO

TEMP=POINTER
POI
NTER=POINTER+1
POINTER+1=TEMP

POINTER=POI
NTER+1
COUNT=COUNT+1

NO

I
S

YES

NO

36
37
ASCENDI
NG

ADDRESS OPCODES PROGRAM COMMENTS


Ini
ti
ali
zememoryl
ocat
ionf
orar
ray
MOVSI
,
1200H siz
e
MOVCL,
[
SI] Numberofcompari
sonsinCL
Ini
ti
ali
zememor
ylocati
onforar
ray
L4:
MOVSI
,
1200H siz
e
MOVDL,
[
SI] Gett
hecounti
nDL
I
NCSI Gotonextmemorylocat
ion
Gett
hefir
stdat
ain
MOVAL,
[
SI] AL
L3:
INCSI Got
onextmemor
ylocat
ion
MOVBL,
[
SI] Gett
heseconddat
ainBL
CMPAL,
BL Compar
etwodat
a’s
JNBL1 I
fAL<BLgot
oL1
DECSI El
se,Decr
ementthememor
ylocat
ion
Stor
ethesmal
lest
MOV[
SI]
,
AL data
MOVAL,
BL Gett
henextdat
aAL
JMPL2 Jumpt
oL2
L1:
DECSI Decr
ementt
hememor
ylocat
ion
MOV[
SI]
,
BL St
orethegr
eat
estdat
ainmemor
y
l
ocat
ion
L2:
INCSI Got
onextmemor
ylocat
ion
DECDL Decrementt
hecount
Jumpt oL3,
ift
hecounti
snot
JNZL3 reached
zero
MOV[
SI]
,
AL St
oredat
ainmemor
ylocat
ion
DECCL Decrementt
hecount
Jumpt oL4,
ift
hecounti
snot
JNZL4 reached
zero
HLT St
op

DESCENDI
NG

ADDRESS OPCODES PROGRAM COMMENTS


Ini
ti
ali
zememoryl
ocat
ionf
orar
ray
MOVSI
,
1200H siz
e
MOVCL,
[
SI] Numberofcompar
isonsi
nCL

38
Ini
ti
ali
zememor
ylocat
ionf
orar
ray
L4:
MOVSI
,
1200H siz
e
MOVDL,
[
SI] Gett
hecounti
nDL
I
NCSI Gotonextmemorylocat
ion
Gett
hefir
stdat
ain
MOVAL,
[
SI] AL
L3:
INCSI Got
onextmemor
ylocat
ion

39
MOVBL,
[
SI] Gett
heseconddat
ainBL
CMPAL,
BL Compar
etwodat
a’s
JBL1 I
fAL>BLgot
oL1
DECSI El
se,Decrementthememor
ylocat
ion
Stor
ethelargest
MOV[
SI]
,
AL data
Getthenextdata
MOVAL,
BL AL
JMPL2 Jumpt
oL2
L1:
DECSI Decr
ementt
hememor
ylocat
ion
MOV[
SI]
,
BL St
orethesmal
l
estdat
ainmemor
y
l
ocat
ion
L2:
INCSI Got onextmemorylocat
ion
Decrementthe
DECDL count
Jumpt oL3,ift
hecounti
snot
JNZL3 reached
zero
MOV[
SI]
,
AL Storedatai
nmemor ylocat
ion
Decrementthe
DECCL count
Jumpt oL4,ift
hecountisnot
JNZL4 reached
zero
HLT St
op

RESULT:
.
ASCENDI
NG

MEMORY

DATA

40
DESCENDI
NG

MEMORY

DATA

Thusgi
venar
rayofnumber
sar
esor
tedi
nascendi
ng&descendi
ngor
der
.

41
LARGEST&SMALLEST

AI
M:
Towri
teanAssemblyLanguageProgr
am (
ALP)t
ofi
ndt
he
l
argestandsmall
estnumberi
nagi venar
ray
.

APPARATUSREQUI
RED:

SL.
N I
TEM SPECI
FICATI
ON QUANTI
TY
O
1. Mi
cropr
ocessorki
t 8086 1
2. PowerSupply +5Vdc 1

PROBLEM STATEMENT:

Anarrayofl
ength10i
sgiv
enfrom t
hel
ocat
ion.Fi
ndt
hel
argest
andsmal
lestnumberandst
orether
esul
t.

ALGORI
THM:
(i
) Findi
ngl
argestnumber
:
a.Loadthearraycounti
naregist
er
C1.b.Getthefir
sttwonumbers.
c.Compar ethenumbersandexchangeift
henumberissmall.
d.Getthet hi
rdnumberfr
om thearr
ayandrepeatt
heprocessunt
ilC1i
s
0.

(
ii
) Fi
ndi
ngsmal
l
estnumber
:
e.Loadthear r
aycounti
naregist
erC1.
f.Getthefi
rsttwonumbers.
g.Comparet henumbersandexchangei
fthenumberi
slar
ge.
h.Getthethi
r dnumberfr
om t
hear r
ayandrepeatt
hepr
ocessunt
ilC1i
s
0.

42
FLOWCHART
SMALLESTNUMBERI
NANARRAY
LARGESTNUMBERI
NANARRAY
START
START

I
NITI
ALI
ZE I
NITI
ALI
ZE
COUNT COUNT

PONITER=
PONITER= POINTER+1
POINTER+1

YES
I
SMIN
I
SMAX
POI
NTER
YES
NO
NO
MI
N =POI
NTER
MAX=POI
NTER

COUNT=COUNT-
1
COUNT=COUNT-
1
NO
NO
I
SCOUNT=0
I
SCOUNT=0 ?
?
YES YES
STOREMI
NII
MUM
STOREMAXI
MUM

STOP
STOP

43
LARGEST

ADDRESS OPCODES PROGRAM COMMENTS

MOVSI
,
1200H I
nit
ial
i
zear
raysi
ze
MOVCL,
[
SI] I
nit
ial
i
zet
hecount
I
NCSI Gotonextmemor yl
ocat
ion
Movethefi
rstdat
ain
MOVAL,
[
SI] AL
DECCL Reducet
hecount
L2:
INCSI Mov
etheSIpoi
ntert
onextdat
a
CMPAL,
[
SI] Compar
etwodat
a’s
JNBL1 I
fAL>[
SI]t
hengot
oL1(noswap)
MOVAL,
[
SI] El
semov
ethel
argenumbert
oAL
L1:
DECCL Decr
ementt
hecount
JNZL2 I
fcounti
snotzer
ogot
oL2
MOVDI
,
1300H I
nit
ial
i
zeDIwi
th1300H
MOV[
DI]
,
AL El
sestor
ethebi
ggestnumberi
n1300
l
ocat
ion
HLT St
op

SMALLEST

ADDRESS OPCODES PROGRAM COMMENTS

MOVSI
,
1200H I
nit
ial
i
zear
raysi
ze
MOVCL,
[
SI] I
nit
ial
i
zet
hecount
I
NCSI Gotonextmemor yl
ocat
ion
Movethefi
rstdat
ain
MOVAL,
[
SI] AL
DECCL Reducet
hecount
L2:
INCSI Mov
etheSIpoi
ntert
onextdat
a
CMPAL,
[
SI] Compar
etwodat
a’s
JBL1 I
fAL<[
SI]t
hengot
oL1(noswap)
MOVAL,
[
SI] El
semov
ethel
argenumbert
oAL
L1:
DECCL Decr
ementt
hecount
JNZL2 I
fcounti
snotzer
ogot
oL2
MOVDI
,
1300H I
nit
ial
i
zeDIwi
th1300H
MOV[
DI]
,
AL El
sest
oret
hebi
ggestnumberi
n1300
44
l
ocat
ion
HLT St
op

45
RESULT:
.
LARGEST

MEMORY

DATA

SMALLEST

MEMORY

DATA

Thusl
argestandsmal
l
estnumberi
sfoundi
nagi
venar
ray
.

46
PASSWORDCHECKI
NG,
PRI
NTRAM SI
ZEANDSYSTEM DATE

EXPTNO:05 DATE:
AIM:
Towrit
eanAssemblyLanguagePr
ogr
am (
ALP)f
orper
for
mingt
he
Ari
thmet
icoperat
ionoft
wobytenumbers

APPARATUSREQUI
RED:

SL.
N I
TEM SPECIFI
CATI
ON QUANTI
TY
O
1. Mi
cropr
ocessorki
t 8086kit 1
2. PowerSupply +5Vdc 1

PROGRAM:
;
PASSWORDI SMASM1234
DATASEGMENTPASSWORD
DB'MASM1234' LENEQU($-
PASSWORD)
MSG1DB10, 13,'
ENTERYOURPASSWORD:$'
MSG2DB10, 13,'
WELCOMETOELECTRONICSWORLD!
!$'
MSG3DB10, 13,'
INCORRECTPASSWORD!
$'
NEW DB10,13,
'
$'
I
NSTDB10DUP( 0)
DATAENDSCODE
SEGMENT
ASSUMECS: CODE,DS:DATA
START:
MOVAX, DATA
MOVDS, AX
LEADX,MSG1
MOVAH, 09H
INT21H
MOVSI ,
00
UP1:
MOVAH, 08H
I
NT21HCMP
AL,
0DHJE
DOWN
MOV[INST+SI]
,
AL
MOVDL,'*'
MOVAH, 02H
I
NT21H
I
NCSI
JMP
UP1
DOWN:

47
48
MOVBX,00
MOVCX,LEN
CHECK:
MOVAL,[INST+BX]
MOVDL,[PASSWORD+BX]
CMPAL,DL
JNEFAIL
I
NCBX
LOOPCHECK
LEADX,MSG2
MOVAH, 09H
I
NT21H
JMPFINISH
FAI
L:
LEADX,MSG3
MOVAH, 009H
I
NT21H
FI
NISH:
I
NT3
CODEENDS
ENDSTART
END

;Today.asm Displ
ay
month/day/year.;
Feb1st,2012
;
CIS206KenHowar d
.MODELsmal l
.STACK100h
.DATA
mess1DB10, 13,'
Todayis$'
;10=LF,
13=CR
.CODE

TodayPROC
MOVAX,@data
MOVDS, AX
MOVDX,OFFSETmess1 ; Movestr
ingtoDX
;09hcal
ltodi
splaystr
ing(DX>AH>
MOVAH, 09h DOS)
INT21H ;
Sendt oDOS
;CXyear
,DHmonth,DLday
MOVAH, 2AH ;Gett
hedate(appendixD)
INT21H ;
Sendt oDOS
PUSHCX ;Moveyeartothestack
MOVCX, 0 ;ClearCX

MOVCL, DL
PUSHCX ;Movedaytost
ack
MOVCL, DH ;Movemonth>CL
PUSHCX ;Movemonthtost
ack
MOVDH, 0 ;Cl
earDH
;*
*****
****
***
***
***
****
***DISPLAYMONTH* *
***
***
***
***
***
***
***
*

49
50
Setupf ordi
vi
sion
Div
idendwillbei
nDX/ AXpai r(4by tes)
Quotientwi llbei nAX
Remai nderwi llbeinDX
MOVDX, 0 ;ClearDX
POPAX ;
Remov emont hfrom st acki
ntoAX
MOVCX, 0 ;Init
ial
izethecount er
MOVBX, 10 ;Setupt hedivi
sor
di
vi
dem:
DI VBX ;Divide(wi l
lbewor dsi zed)
PUSHDX ;Sav eremai ndertost ack
ADDCX, 1 ; Addonet ocount er
MOVDX, 0 ;Cl earther emainder
CMPAX, 0 ;Compar equot i
entt ozero
JNEdividem ;I
fquoi entisnotzer o, goto"
divi
dem:
"
di
vdispm:

POPDX ;
Remov et opofstacki nt
oDX
ADDDL, 30h ;ADD30h( 2)toDL
MOVAH, 02h ;02ht odi spl
ayAH( DL)
INT21H ;Sendt oDOS
LOOPdivdispm ; I
fmor etodo, divdispm again
;
LOOPsubt r
act s1from CX.I fnon-
zero,l
oop.
MOVDL, '/
' ;Char actertodisplaygoesi nDL
MOVAH, 02h ;02ht odi spl
ayAH( DL)
INT21H ;Sendt oDOS
*
*******
***
*******
* *
******DI SPLAYDAY* ********
***
*****
****
***
Setupfordivisi
on
Div
idendwi llbei nDX/AXpai r(4bytes)
Quotientwi llbei nAX
Remai nderwi l
lbeinDX
MOVDX, 0 ;Cl earDX
POPAX ;
Remov edayf r
om st acki nt
oAX
MOVCX, 0 ;Initi
ali
zet hecount er
MOVBX, 10 ;Setupt hedivi
sor
di
vided:
DIVBX ;Divide(wi ll
bewor dsi zed)
PUSHDX ;Sav eremai ndertost ack

ADDCX, 1 ; Addonet ocount er


MOVDX, 0 ;Cleartheremai nder
CMPAX, 0 ; Compar equotienttozero
JNEdivi
ded ;Ifquoientisnotzer o,goto"di
vided:
"
di
vdispd:
POPDX ;Remov et opofst ack
ADDDL, 30h ; ADD30h( 2)toDL
MOVAH, 02h ;02ht odisplayAH( DL)
I
NT21H ;Sendt oDOS
LOOPdiv dispd ;Ifmoret odo, di
vdispdagain
;
LOOPsubt racts1f rom CX.I fnon-
zero,l
oop.

51
52
MOVDL, '
/' ;Char act ert odi splaygoesi nDL
MOVAH, 02h ;02ht odi splayAH( DL)
I
NT21H ;Sendt oDOS
*** *
*****
*** **
*** *
********DI SPLAYYEAR* *****
*****
*****
****
***
*
Setupf ordi vi
sion
Div
idendwi ll bei nDX/ AXpai r(4bytes)
Quotientwi llbei nAX
Remai nderwi llbei nDX
MOVDX, 0 ;ClearDX
POPAX ;Remov emont hf rom st ackintoAX
MOVCX, 0 ;Init
ializet hecount er
MOVBX, 10 ;Setupt hedi visor
div
idey :
DIVBX ;Div i
de( wi llbewor dsi zed)
PUSHDX ;Sav er emai ndert ost ack
ADDCX, 1 ;Addonet ocount er
MOVDX, 0 ; Cleart her emai nder
CMPAX, 0 ;Compar equot ientt ozero
JNEdividey ;Ifquoi enti snotzer o,got o"di
videy
:"
di
vdispy:
POPDX ;Remov et opofst acki ntoDX
ADDDL, 30h ; ADD30h( 2)t oDL
MOVAH, 02h ;02ht odi spl ayAH( DL)
I
NT21H ;
Sendt oDOS
LOOPdi vdispy ;Ifmor et odo, di vdispagain
;LOOPsubt r
act s1f rom CX.I fnon-zero,
loop.
MOVal ,
0 ;Use0asr etur ncode
MOVAH, 4ch ;Sendr etur ncodet oAH
I
NT21H ;
Sendr et ur ncodet oDOSt oexit.

Today ENDP ;Endprocedure


;Endcode.St ar
tusing"
Today
"
END Today procedure.
MVIA,80H:Init
ial
ize8255, portAandpor tB
OUT83H( CR):i
nout putmode
START:MVIA, 09H
OUT80H( PA):Senddat aonPAt oglowR1andR2
MVIA,24H
OUT81H( PB):Senddat aonPBt oglowG3andG4
MVIC,28H:Loadmul ti
pli
ercount(40ı)f ordel
ay
CALLDELAY: Call
delaysubr outi
ne
MVIA,12H
OUT(81H)PA: Senddat aonPor tAt oglowY1andY2
OUT(81H)PB: Senddat aonpor tBtogl owY3andY4
MVIC,0AH:Loadmul ti
pli
ercount(10ı)f ordel
ay
CALL:DELAY:Calldelaysubr out
ine
MVIA,24H
OUT(80H)PA: Senddat aonpor tAt oglowG1andG2
MVIA,09H
OUT(81H)PB: Senddat aonpor tBtogl owR3andR4
53
MVIC,
28H:
Loadmul
ti
pli
ercount(
40ı)f
ordel
ay

54
CALLDELAY: Calldelaysubroutine
MVIA,12H
OUTPA: Senddat aonpor tAt oglowY1andY2
OUTPB: Senddat aonpor tBt oglowY3andY4
MVIC,0AH: Loadmul t
ipl
iercount(10ı)fordelay
CALLDELAY: Calldelaysubroutine
JMPSTART
Del
aySubroutine:
DELAY:LXID, Count:Loadcountt ogive0.5secdelay
BACK:DCXD: Decrementcount er
MOVA, D
ORAE: Checkwhet hercountis0
JNZBACK: Ifnotzero,repeat
DCRC: Checkifmul t
ipli
erzero,other
wiserepeat
JNZDELAY
RET:Retur
nt omai nprogram

Ram si
ze:

ORG0000H
CLR PSW3
CLRPSW4
CPLA
ADDA,#01H
MOVA,R3
AGAI
N: SJMPAGAI N

RESULT:
Thustheout
putfort
hePasswor
dchecki
ng,
Pri
ntRAM si
zeandsy
stem dat
e
wasexecut
edsuccessf
ull
y

55
56
EXP.
NO:
06 DATE:

AI
M:
Towri
teanassembl
ylanguagepr
ogr
am i
n8086t
oCount
ersandTi
me
Del
ay

APPARATUSREQUI RED:
SL.NO I
TEM SPECI
FICATI
ON QUANTI
TY
1. Mi croprocessorki
t 8086 1
2. PowerSuppl y +5V,dc,
+12Vdc 1
3. St epperMot orI
nter
faceboar
d - 1
4. St epperMot or - 1

PROGRAM:
.MODELSMALL
.DATA

MSGINDB'Enterdel
aydurat
ion(0-50)
:$'
MSG1DB'ThisisMicropr
ocessor!
$'
DELAYTI
MEDW 0000H

.
CODE

MOVDX, @DATA
MOVDS,DX
LEADX,MSGIN
MOVAH, 09H
INT21H

I
N1:
MOVAH, 01H
INT21H
CMPAL, 0DH ;
JENXT
SUBAL,30H
MOVDL, AL
MOVAX, BX
MOVCL, 0AH
MULCL
MOVBX, AX
ANDDX,00FFH
ADDBX,DX
MOVDELAYTI ME,
BX
LOOPIN1

57
NXT: MOVCX, DELAYTI
ME
MOVDL,
10
MOVAH,02H
I
NT21H

LEASI
,
MSG1

LP: PUSHDX
MOVDL, [SI
]
CMPDL, '
$'
JENXT2
MOVAH, 02H
INT21H
ADDSI ,
1
POPDX
MOVDI ,DELAYTI
ME
MOVAH, 0
INT1Ah
MOVBX, DX

Del
ay:
MOVAH, 0
I
NT1Ah
SUBDX,BX
CMPDI,DX
JADel
ay

LOOPLP

NXT2:MOVAH,
4CH
I
NT21H

END

RESULT:
Thust
heout
putf
ort
heCount
ersandTi
meDel
aywasexecut
edsuccessf
ull
y

58
EXP.
NO:
07 DATE:

AI
M:
Towr i
teanassemblylanguageprogram in8086toTr
aff
icl
ight
contr
ol
APPARATUSREQUI RED:
SL.NO ITEM SPECIFICATION QUANTITY
1. Mi cropr
ocessorkit 8086 1
2. PowerSuppl y +5V,dc,+12Vdc 1
3. Tr af
ficl
ightcont
rolI
nter
face - 1
board

PROGRAM:

59
60
EXP.
NO:
08 DATE:

AI
M:
Towr i
teanassembl
ylanguagepr
ogr
am i
n8086t
orot
atet
hemot
oratdi
ff
erent
speeds.

APPARATUSREQUI
RED:

SL.NO I
TEM SPECI
FICATI
ON QUANTI
TY
1. Microprocessorki
t 8086 1
2. PowerSuppl y +5V,dc,
+12Vdc 1
3. StepperMot orI
nter
faceboar
d - 1
4. StepperMot or - 1

PROBLEM STATEMENT:

Wri
teacodeforachiev
ingaspeci
fi
cangl
eofr
otat
ioni
nagi
vent
imeand
par
ti
cul
arnumberofr
otat
ionsi
naspeci
fi
cti
me.

THEORY:

A motorinwhi chtherotorisabletoassumeonl ydiscretestati


onary
angularposi
ti
onisast eppermotor.Therot
arymot i
onoccursinast epwisemanner
fr
om oneequi li
bri
um posi t
iontothenext.Two-phasescheme:Anyt woadj acent
stat
orwi ndi
ngsareener gi
zed.Therearetwomagnet icfi
eldsacti
vei nquadrature
andnoneoft herotorpolefacescanbei ndir
ectali
gnmentwi t
hthest atorpol
es.A
part
ialbutsymmetri
calignmentoftherot
orpolesisofcour
sepossible.

ALGORI
THM:

Forr
unni
ngst eppermotorclockwiseandant i
clockwisedirecti
ons
(
i) Gett hef i
rstdat
afrom thelookuptable.
(
ii
) I ni
ti
ali
zethecounterandmov edataintoaccumul ator.
(
ii
i) Dri
vethest eppermotorcir
cuitr
yandi nt
roducedel ay
(
iv) Decrementt hecounteri
snotzer orepeatfrom st
ep( i
ii
)
(
v) Repeatt heabov eprocedur
ebot hforbackwar dandf orwarddi
rect
ions.

SWI
TCHI
NGSEQUENCEOFSTEPPERMOTOR:

MEMORY A1 A2 B1 B2 HEX
LOCATI
ON CODE
4500 1 0 0 0 09H
4501 0 1 0 1 05H
4502 0 1 1 0 06H
4503 1 0 1 0 0AH

61
FLOWCHART:
START

I
NTI
ALI
ZECOUNTERFORLOOKUPTABLE

GETTHEFI
RSTDATAFROM THEACCUMULATOR

MOVEDATAI
NTOTHEACCUMULATOR

DRI
VETHEMOTOR

DELAY

DECREMENTCOUNTER

I
SB=0?

GETTHEDATAFROM LOOKUP

PROGRAM TABLE
ADDRESS OPCODE PROGRAM COMMENTS
Ini
ti
ali
zememor
ylocat
iont
ost
ore
START:
MOVDI
,1200H the
arr
ayof
number
MOVCX,
0004H I
nit
ial
i
zear
raysi
ze
LOOP1:
MOVAL,
[
DI] Copyt
hef
ir
stdat
ainAL
OUT0C0,
AL Sendi
tthr
oughpor
taddr
ess
MOVDX,
1010H
L1:
DECDX I
ntr
oducedel
ay
JNZL1
I
NCDI Gotonextmemor yl
ocati
on
Loopunt
ilal
lthedat
a’shavebeen
LOOPLOOP1 sent
JMPSTART Gotostar
tlocat
ionf
orcont
inuous
r
otat
ion
1200:
09,
05,
06,
0A Ar
rayofdat
a’s

62
RESULT:Thustheassemblyl
anguagepr
ogr
am forr
otati
ngsteppermot
ori
nbot
h
cl
ockwiseandanti
cl
ockwisedi
rect
ionsi
swri
tt
enandv er
if
ied.

63
.

DI
GITALCLOCK

EXP.
NO:
09 DATE:

Ai
m
Todi
spl
aythedi
git
alcl
ockspeci
fi
cal
l
ybydi
spl
ayi
ngt
hehour
s,mi
nut
esand
secondsusi
ng8086kit
s

Appar
atusr
equi
red

S.
No It
em Speci
fi
cat
ion
Micr
opr
ocessor
1 ki
t 8086
2 PowerSuppl
y 5V

Prel
iminar
ySetti
ngs
Org1000h
St
oretime value in memor
ylocati
on 1500-
Seconds
1501-
Minutes
1502-Hours
Digi
tal
clockprogram

64
65
66
67
Result
Thusthedigit
alclockpr
ogram hasbeenwri
tt
enandexecut
edusing8086
microprocessorki
tandt heout
putofdigi
talcl
ockwasdi
spl
ayedas[hours:
minut
es:
seconds]successful
ly.

68
69
EXP.
NO:
10 DATE:

AI
M:
Todi
spl
ayt
her
oll
i
ngmessage“HELPUS“i
nthedi
spl
ay.

APPARATUSREQUIRED:
8086Mi
cropr
ocessorki
t,Powersuppl
y,I
nter
faci
ngboar
d.

ALGORITHM :
Displ
ayofrol
l
ingmessage“HELPUS“
1.Ini
ti
ali
zethecount er
2.Set8279f or8di gi
tchar
acterdispl
ay,r
ightent
ry
3.Set8279f orcleari
ngthedispl
ay
4.Writethecommandt odisplay
5.Loadthechar acteri
ntoaccumul at
oranddispl
ayit
6.Int
roducethedel ay
7.Repeatfrom step1.

1.
Displ
ayModeSet
up:
Cont
rol
wor
d-10H

0 0 0 1 0 0 0 0
0 0 0 D D K K K

DD
00-8Bi
tchar acterdisplayleftentr
y
01-16Bitcharacterdisplayleftentr
y
10-8Bi
tchar acterdisplayrightentr
y
11-16Bi tcharacterdispl
ayr i
ght
entr
yKKK-KeyBoar dMode
000-2Keyl ockout.
2.Cl
earDisplay:Controlwor d-DCH

1 1 0 1 1 1 0 0
1 1 0 CD CD CD CF CA

11 A0-
3;B0-
3=FF
1-
EnablesCleardi
spl
ay
0-
ContentsofRAM wil
lbedi
spl
ayed
1-
FIFOSt
atusi
scl
ear
ed

1-
Clearal
lbi
ts

70
3.Wr
it
eDi
spl
ay:
Cont
rol
wor
d-90H

1 0 0 1 0 0 0 0
1 0 0
AI A A A A

Sel
ect
soneoft
he16r
owsofdi
spl
ay.

Aut
oincr
ement=1,therowaddressselect
edwi
l
lbei
ncr
ement
edaf
tereach
ofr
eadandwri
teoperat
ionoft
hedisplayRAM.

FLOWCHART

71
SEGMENTDEFI
NITI
ON

DATABUS D7 D6 D5 D4 D3 D2 D1 D0

SEGMENTS d c b a dp g f e

PROGRAM TABLE

PROGRAM COMMENTS
START:
MOVSI
,
1200H I
nit
ial
i
zear
ray
MOVCX,
000FH I
nit
ial
i
zear
raysi
ze
MOVAL,
10 St
oret
hecont
rol
wor
dfordi
spl
aymode
OUTC2,
AL Sendt
hroughout
putpor
t
MOVAL,
CC St
oret
hecont
rol
wor
dtocl
eardi
spl
ay
OUTC2,
AL Sendt
hroughout
putpor
t
MOVAL,
90 St
oret
hecont
rol
wor
dtowr
it
edi
spl
ay
OUTC2,
AL Sendt
hroughout
putpor
t
L1:
MOVAL,
[
SI] Gett
hef
ir
stdat
a
OUTC0,
AL Sendt
hroughout
putpor
t
CALLDELAY Gi
vedel
ay
I
NCSI Go&getnextdat
a
LOOPL1 Loopunt
ilal
lthedat
a’shav
ebeent
aken
JMPSTART Got
ost
art
ingl
ocat
ion
DELAY:
MOVDX,
0A0FFH St
ore16bi
tcountv
alue
LOOP1:
DECDX Decr
ementcountv
alue
JNZLOOP1 Loopunt
ilcountv
aluesbecomeszer
o
RET Ret
urnt
omai
npr
ogr
am

LOOK-
UPTABLE:

1200 98 68 7C C8
1204 FF 1C 29 FF

RESULT:

MEMORY 7-
SEGMENTLEDFORMAT HEXDATA
LOCATI
ON d c b a dp e g f
72
1200H 1 0 0 1 1 0 0 0 98
1201H 0 1 1 0 1 0 0 0 68
1202H 0 1 1 1 1 1 0 0 7C
1203H 1 1 0 0 1 0 0 0 C8
1204H 1 1 1 1 1 1 1 1 FF
1205H 0 0 0 0 1 1 0 0 1C
1206H 0 0 1 0 1 0 0 1 29
1207H 1 1 1 1 1 1 1 1 FF

Thust
her
oll
i
ngmessage“
HELPUS”i
sdi
spl
ayedusi
ng8279i
nter
faceki
t.

73
DATE:
EXP.
NO:
11

AI
M:
Todispl
ayt
hePr
int
er
Stat
us i
nthedi
spl
ay

APPARATUSREQUIRED:
8086Mi
cropr
ocessorki
t,Powersuppl
y,i
nter
faci
ngboar
d.

PROGRAM:

XORAX,
AX
XORBX,
BX

;t
hisdi
vi
desmy3di
gitnumberby100gi
vi
ngmemy
,hundr
edt
h
di
gitMOVAX,RES
MOVBX,100
DI
VBX

;pri
ntst
hehundr edt
h
digitADDAL, '0'
MOVDL, AL
PUSHAX; saveAXont he
stackMOVAH, 02h
INT21h
POPAX; restoreax

;div
idest
her
emai
nderby10gi
vi
ngmemyt
ens
di
gitMOVBX,10
DI
VBX

;pri
ntsmyt ens
digitADDAL, '0'
MOVDL, AL
PUSHAX; saveAXont
he
stackMOVAH, 02h
INT21h
POPAX; restoreax

;
pri
ntmylastr
emai
nderwhi
chi
smy
onesADDAH, '
0'
MOVDL, AH
MOVAH, 02h
I
NT21h

RESULT:
Thustheoutputf
ort
heMov
eadat
abl
ockwi
thoutov
erl
apwasexecut
ed
successf
ull
y
74
75
EXP.
NO:
12 DATE:
Ai
m
Toconnecttwo8086mi cr
oprocessorki
tsandtoserial
l
ycommuni
cat
e
wit
heachotherbyconsi
der
ingtr
ansmitterandrecei
verki
ts.
Appar
atusr
equired

Pr
ocedure
1.
Taketwonoof8086mi
cropr
ocessorki
ts.
2.Enterthetransmi tterprogram intr
ansmi t
terki
t.
3.Entertherecei verprogram inrecei
v erki
t.
4.Int
erfacethet woki tswith9-9serialcableint
heser i
alportoft
hemi
cropr
ocessor
ki
ts.(LCDkitmeansPC- PCcable.LEDki tmeanskit-
kitcabl
e)
5.Enterthedatai nt r
ansmi tt
erkituset hememor yl
ocation1500.
6.Executether eceiverkit.
7.Executethet ransmi tt
erkit.
8.Resultwil
lbeav ail
ableinreceiverkitmemor yl
ocati
on1500.
Tr
ansmi
tt
erPr
ogr
am

76
Recei
verPr
ogr
am

Resul
t
Thustheser
ialcommuni cati
onbetweentwo8086micr
oprocessorki
ts
hasbeenestabli
shedandt hedat
aistransmi
tt
edinoneki
tandr ecei
ved
i
ntheotherkitsuccessf
ull
y

77
PARALLELCOMMUNICATI
ONBETWEENTWO8086
MICROPROCESSORSKI
TS
Aim
Toconnecttwo8086micropr
ocessorki
tsandtoest
abli
shparal
l
elcommuni
cat
ion
wit
heachotherbyconsi
deri
ngtransmit
terandr
ecei
verki
ts.
Appar
atusrequi
red

Pr
ocedure
1.
Taket wo8086mi croprocessorki t
s.
2.
Enterthetransmi t
terprogr am int r
ansmit
terkit
.
3.
Entertherecei v
erprogr am inreceiverki
t.
4.
Int
erfacethet wokitswi th26-cor ecableonPPI-1.
5.
Executether eceiv
erki t
.
6.
Executethet ransmitterkit
.
7.
Goandseet hememor ylocati
on1200i nrecei
vertogetsameeightdat
a.
8.
Dataisav ai
lableintransmi tt
erki ti
nthememor yl
ocat
ion.
9.
Changet hedat a&execut ethef oll
owingprocedur
e&gett her
esulti
nrecei
verki
t.

Tr
ansmi
tt
erpr
ogr
am

78
79
Recei
verPr
ogr
am

Result
Thustheserial
communicat
ionbet
weentwo8086micropr
ocessorki
tshasbeen
establ
ishedandthedat
aist
ransmi
ttedi
noneki
tandrecei
vedintheotherki
t
successful
ly
.

80
EXPTNO:
13 DATE:
AIM:

Towr i
teanassembl ylanguagepr ogram toconv ertananalogsignali
ntoa
digit
alsi
gnal usinganADCi nt er
facing.
APPARATUSREQUI RED:
SL.NO ITEM SPECI FICATION QUANTI TY
1. Mi croprocessorki t 8086 1
2. PowerSuppl y +5Vdc, +12Vdc 1
3. ADCI nterfaceboar d - 1
THEORY:
AnADCusual l
yhast woaddi t
ionalcont rolli
nes:theSOCi nputt otellt
heADC
whent ost arttheconv ersi
onandt heEOCout puttoannouncewhent heconver
sion
i
scompl et
e.Thef ollowi ngpr ogram i nit
iatestheconv ersi
onprocess,checkstheEOC
pinofADC0809ast owhet hert heconv ersionisoverandt heninputsthedatatothe
processor.Italsoi nst r
uct sthepr ocessort ost oretheconvert
eddi gi
taldataatRAM
l
ocat i
on.
ALGORI THM:
(i
) Sel ectthechannel andl atchtheaddr ess.
(i
i) Sendt hest artconv ersionpul se.
(i
ii
) ReadEOCsi gnal.
(i
v) I fEOC=1cont i
nueel segot ost ep(iii
)
(v) Readt hedi gitaloutput.
(vi
) St oreitinamemor ylocat i
on.
FLOW CHART:
START

SELECTTHECHANNELANDLATCH

SENDTHESTARTCONVERSI
ONPULSE

NO
I
SEOC=1?

YES

READTHEDI
GITALOUTPUT

STORETHEDIGI
TALVALUEI
NTHE
MEMORYLOCATI
ONSPECI
FIED

STOP

81
82
PROGRAM TABLE
PROGRAM COMMENTS

MOVAL,
00 Loadaccumul
atorwi
thv
aluef
orALEhi
gh
OUT0C8H,
AL Sendt
hroughout
putpor
t
MOVAL,
08 Loadaccumul
atorwi
thv
aluef
orALEl
ow
OUT0C8H,
AL Sendt
hroughout
putpor
t
MOVAL,
01 St
oret
hev
aluet
omakeSOChi
ghi
ntheaccumul
ator
OUT0D0H,
AL Sendt
hroughout
putpor
t
MOVAL,
00
MOVAL,
00 I
ntr
oducedel
ay

MOVAL,
00
MOVAL,
00 St
oret
hev
aluet
omakeSOCl
owt
heaccumul
ator
OUT0D0H,
AL Sendt
hroughout
putpor
t
L1:
INAL,
0D8H
ANDAL,
01 ReadtheEOCsi
gnal
from por
t&checkf
orendof
conver
sion
CMPAL,
01
Iftheconver
sioni
snoty
etcompl
eted,
readEOC
JNZL1 signal
from por
tagain
I
NAL,
0C0H Readdat
afr
om por
t
I
nit
ial
i
zet
hememor
ylocat
iont
ost
ore
MOVBX,
1100 dat
a
MOV[
BX]
,
AL St
oret
hedat
a
HLT St
op
RESULT:
ANALOG DI
GITALDATAONLED HEXCODEI
NMEMORY
VOLTAGE DI
SPLAY LOCATI
ON

83
ThustheADCwasi
nter
facedwi
th8086andt
hegi
venanal
ogi
nput
swer
econv
ert
ed
i
ntoit
s
di
git
alequi
val
ent
.

I
NTERFACI NGDI GI TAL–TO–ANALOGCONVERTER
AIM:
1.Towr i
t eanassembl ylanguagepr ogram f ordi git
al toanal ogconv ersi
on
2.To conv ertdi gitali nput si nto anal og out puts & To gener ate different
wav efor ms
APPARATUSREQUI RED:
SL.NO I
TEM SPECI FICATI ON QUANTI TY
1. Mi cr oprocessorki t 8086Vi Mi crosy stems 1
2. PowerSuppl y +5V, dc,+12Vdc 1
3. DACI nterfaceboar d - 1
PROBLEM STATEMENT:
Thepr ogram i sexecut edf orv ari
ousdi gitalval uesandequi v al
entanal og
voltagesar emeasur edandal sot hewav ef ormsar emeasur edatt heout putpor ts
usingCRO.
THEORY:
SinceDAC0800i san8bi tDACandt heout putv ol t
agev ariationi sbet ween
–5vand+5v .Theout putv oltagev ariesinst epsof10/ 256=0. 04( appr oximat ely)
.
Thedi gi
taldat ai nputandt hecor respondi ngout putv oltagesar epr esent edi nt he
table.The basi ci dea behi nd t he gener ati
on ofwav eforms i st he cont inuous
gener ati
onofanal ogout putofDAC.Wi th00( Hex)asi nputt oDAC2t heanal og
outputi s–5v .Si milar l
ywi thFFHasi nput,theout putis+5v .Out putti
ngdi git
aldat a
00andFFatr egul ari nter vals,t oDAC2,r esul tsi nasquar ewav eofampl it
ude
5v.Out putdi gitaldat af rom 00t oFFi nconst antst epsof01t oDAC2.Repeatt his
sequenceagai nandagai n.Asar esul tasaw- toot hwav ewi l
lbegener at edatDAC2
output .Out putdi gitaldat af r
om 00t oFFi nconst antst epsof01t oDAC2.Out put
digitaldataf rom FFt o00i nconst antst epsof01t oDAC2.Repeatt hissequence
againandagai n.Asar esul tat ri
angul arwav ewi l
l begener atedatDAC2out put.
ALGORI THM:
Measur ementofanal ogv ol tage:
(i
) Sendt hedi gitalv al
ueofDAC.
(i
i) Readt hecor respondi nganal ogv alueofi tsout put.
Wav ef orm gener ation:
Squar eWav efor m:
(i
) Sendl owv al ue( 00)t ot heDAC.
(i
i) I ntroducesui tabledel ay .
(i
ii
) Sendhi ghv al uet oDAC.
(i
v) I ntroducedel ay .
(v) Repeat t he abov e
procedur e.Saw- toot hwav ef orm:
(i
) Loadl owv alue( 00)t oaccumul ator .
(i
i) Sendt hisv al uet oDAC.
(i
ii
) I ncrementt heaccumul ator.
(i
v) Repeatst ep( i
i)and( ii
i)unt i
laccumul atorv aluer eachesFF.
(v) Repeatt heabov epr ocedur efrom st ep1.
Tri
angul arwav ef or m:
(i
) Loadt hel owv alue( 00)i naccumul ator .
84
(
ii
) Sendt hi
saccumulatorcontenttoDAC.
(
ii
i) I ncrementtheaccumulator
.
(
iv) Repeatst ep 2 and 3 unt i
lt he accumulatorreaches FF,
decrement the accumul at
or and send t he accumulator
contentstoDAC.
(
v) Decr ement
ingandsendingt heaccumulatorcont
entstoDAC.
(
vi) Theabov eprocedur
eisrepeat edfr
om step(i)

85
FLOWCHART:
MEASUREMENTOFANALOGVOLTAGE SQUAREWAVEFORM
START
START
INTI
ALI
SETHE
ACCUMULATORSENDACC
SENDTHE
DI
GITALVALUETO
ACCUMULATOR
DELAY

TRANSFERTHE
ACCUMULATOR LOADTHEACCWITHMAX
VALUESENDACCCONTENT

READTHECORRESPONDI
NG DELAY
ANALOGVALUE

STOP TRI
ANGULARWAVEFORM
START
SAWTOOTHWAVEFORM
START I
NITI
ALI
ZE
ACCUMULATOR

I
NITI
ALI
ZE SENDACCUMULATOR
ACCUMULATOR CONTENTTODAC

SENDACCUMULATOR INCREMENT
ACCUMULATOR

YES
INCREMENT I
SACC
ACCUMULATOR FF
NO
NO YES
DECREMENT
I
SACC ACCUMULATORCONTENT
FF

SEND
ACCUMULATOR

I
SACC
YES 00 NO
86
87
MEASUREMENTOFANALOGVOLTAGE:

PROGRAM COMMENTS

MOVAL,
7FH Loaddi
git
alv
alue00i
naccumul
ator
OUTC0,
AL Sendt
hroughout
putpor
t
HLT St
op

DI
GITALDATA ANALOGVOLTAGE

PROGRAM TABLE:Squar
eWav
e
PROGRAM COMMENTS

L2:
MOVAL,
00H Load00i
naccumul
ator
OUTC0,
AL Sendt
hroughout
putpor
t
CALLL1 Gi
veadel
ay
MOVAL,
FFH LoadFFi
naccumul
ator
OUTC0,
AL Sendt
hroughout
putpor
t
CALLL1 Gi
veadel
ay
JMPL2 Got
ost
art
ingl
ocat
ion
L1:
MOVCX,
05FFH Loadcountv
aluei
nCXr
egi
ster
L3:
LOOPL3 Decr
ementunt
ili
treacheszer
o
RET Ret
urnt
omai
npr
ogr
am

PROGRAM TABLE:Sawt
oot
hWav
e
PROGRAM COMMENTS

L2:
MOVAL,
00H Load00i
naccumul
ator
L1:
OUTC0,
AL Sendt
hroughout
putpor
t
I
NCAL I
ncr
ementcont
ent
sofaccumul
ator
JNZL1 Sendt
hroughout
putpor
tunt
ili
treachesFF
JMPL2 Got
ost
art
ingl
ocat
ion

88
89
PROGRAM TABLE:Tr
iangul
arWav
e
PROGRAM COMMENTS

L3:
MOVAL,
00H Load00i
naccumul
ator
L1:
OUTC0,
AL Sendt
hroughout
putpor
t
I
NCAL I
ncr
ementcont
ent
sofaccumul
ator
JNZL1 Sendt
hroughout
putpor
tunt
ili
treachesFF
MOVAL,
0FFH LoadFFi
naccumul
ator
L2:
OUTC0,
AL Sendt
hroughout
putpor
t
DECAL Decr
ementcont
ent
sofaccumul
ator
JNZL2 Sendt
hroughout
putpor
tunt
ili
treaches00
JMPL3 Got
ost
art
ingl
ocat
ion

WAVEFORM GENERATI
RESULT: ON:

WAVEFORMS AMPLI
TUDE TI
MEPERI
OD

Squar
eWav
efor
m
Saw-
toot
hwav
efor
m

Tr
iangul
arwav
efor
m

MODELGRAPH:

Squar
eWav
efor
m Saw-
toot
hwav
efor
m

Tr
iangul
arwav
efor
m

ThustheDACwasi
nter
facedwi
th8085anddi
ff
erentwav
efor
mshav
ebeen
gener
ated.
90
EXPTNO:
14 DATE:

8BI
TADDI
TION
AI
M:
Towr
it
eapr
ogr
am t
oaddt
wo8-
bitnumber
susi
ng8051mi
crocont
rol
l
er.

ALGORI
THM:

1.
ClearPr ogram St at
usWord.
2.
SelectRegi sterbankbygivingpr
opervaluestoRS1&RS0ofPSW.
3.
Loadaccumul atorAwithanydesi
red8-bitdat
a.
4.
Loadt her egisterR0withthesecond8-bitdata.
5.
Addt heset wo8- bi
tnumbers.
6.
Storet heresult.
7.
Stopt hepr ogram.

FLOW CHART:

START

Cl
earPSW

Sel
ectRegi
ster

LoadAandR
0wi t
h8-bi
t
datas

AddA&R0

St
oret
hesum

STOP

91
92
8BitAddit
ion(
Immedi
ate
Addressi
ng)
ADDRESS LABEL MNEMONI
C OPERAND HEX COMMENTS
CODE
4100 CLR C C3 Cl
earCYFl
ag

4101 MOV A,dat


a1 74,
dat
a1 Getthedat a1i
n
Accumul ator
4103 ADDC A,
#dat
a2 24,
dat
a2 Addt hedat a1with
data2
4105 MOV DPTR,# 90,
45,
00 I
niti
alizet hememor y
4500H l
ocation
4108 MOVX @ DPTR,A F0 Storet her esul
tin
memor ylocat i
on
4109 L1 SJMP L1 80,
FE Stopt hepr ogram

RESULT:

OUTPUT
MEMORYLOCATI
ON DATA

4500

Thust
he8051ALPf
oraddi
ti
onoft
wo8bi
tnumber
sisexecut
ed.

93
94
8BI
TSUBTRACTI
ON
AI
M:
Toper
for
m subt
ract
ionoft
wo8bi
tdat
aandst
oret
her
esul
tinmemor
y.

ALGORITHM:
a.Cl earthecar ryfl
ag.
b.Initi
alizether egi
sterforborr
ow.
c.Gett hef i
rstoperandintotheaccumulat
or.
d.Subt ractt hesecondoper andfrom t
heaccumulat
or.
e.Ifabor rowr esul
tsincrementthecarr
yregi
ster
.
f. Storet heresulti
nmemor y.

FLOWCHART:
START

CLEARCARRY
FLAG

GETI’
ST
OPERANDI
N
ACCR

SUBTRACTTHE
2’
NDOPERAND
FROM ACCR

N
I
SCF=1

Y
I
NCREMENT
THEBORROW
REGI
STER

STORE
RESULTI
N
MEMORY

STOP

95
8BitSubtr
act
ion(
Immedi
ate
Addressi
ng)
ADDRESS LABEL MNEMONI
C OPERAND HEX COMMENTS
CODE
4100 CLR C C3 Cl
earCYf
lag

4101 MOV A,
#dat
a1 74,data1 Storedat a1in
accumul ator
4103 SUBB A,#data2 94,
data2 Subt ractdata2f rom
data1
4105 MOV DPTR,#4500 90,
45,00 I ni
ti
alizememor y
l
ocation
4108 MOVX @ DPTR,A F0 Storet hedif
ference
i
nmemor ylocati
on
4109 L1 SJMP L1 80,
FE Stop

RESULT:

OUTPUT
MEMORY LOCATI
ON DATA

4500

Thust
he8051ALPf
orsubt
ract
ionoft
wo8bi
tnumber
sisexecut
ed.

96
97
8BITMULTI
PLICATION
AI
M:
Toper
for
m mul
ti
pli
cat
ionoft
wo8bitdataandstor
ether
esul
tinmemor
y.

ALGORI
THM:
a.Getthemul
ti
pli
erint
heaccumul
ator
.
b.Getthemul
ti
pli
candint
heBregi
ster
.
c.Mult
ipl
yAwithB.
d.Stor
ethepr
oductinmemory.

FLOWCHART:

START

GET
MULTI
PLI
ER
I
NACCR

GET
MULTI
PLI
CAND
I
NBREG

MULTI
PLYA
WI
THB

STORE
RESULTI
N
MEMORY

STOP

98
99
8BitMul
ti
pli
cat
ion
ADDRESS LABEL MNEMONI
C OPERAND HEX COMMENTS
CODE
4100 MOV A,
#dat
a1 74,
data1 Stor
edat
a1in
accumul
ator
4102 MOV B,
#dat
a2 75,
dat
a2 St or
edat
a2inBr
eg

4104 MUL A,
B F5,
F0 Mul
ti
plybot
h

4106 MOV DPTR,# 90,


45,
00 I
niti
ali
zememor y
4500H l
ocation
4109 MOVX @ DPTR,A F0 Storelowerorder
resul
t
401A I
NC DPTR A3 Got onextmemor y
l
ocation
410B MOV A,
B E5,
F0
Storehigherorder
410D MOV @ DPTR,
A F0 resul
t

410E STOP SJMP STOP 80,


FE St
op

RESULT:

INPUT OUTPUT
MEMORYLOCATION DATA MEMORYLOCATION DATA

4500 4502

4501 4503

Thust
he8051ALPf
ormul
ti
pli
cat
ionoft
wo8bi
tnumber
sisexecut
ed.

100
8BI
TDI
VISI
ON

AI
M:
Toper
for
m di
vi
si
onoft
wo8bi
tdat
aandst
oret
her
esul
tinmemor
y.

ALGORITHM:
1.GettheDi
vi
dendintheaccumulat
or.
2.GettheDi
vi
sorintheBregi
ster
.
3.Divi
deAbyB.
4.Stor
etheQuot
ientandRemainderi
nmemor
y.

FLOWCHART:

START

GETDI
VIDEND
I
NACCR

GETDI
VISORI
N
BREG

DI
VIDEABYB

STORE
QUOTI
ENT&
REMAI
NDER
I
NMEMORY

STOP

101
8BitDi
vi
sion
ADDRESS LABEL MNEMONI
C OPERAND HEX COMMENTS
CODE
4100 MOV A,
#dat
a1 74,
dat
a1 Stor
edat
a1in
accumul
ator
4102 MOV B,
#dat
a2 75,
dat
a2 Stor
edat
a2inBr
eg

4104 DI
V A,
B 84 Di
vi
de

4015 MOV DPTR,#4500H 90,


45,
00 I
nit
ial
i
zememory
l
ocati
on
4018 MOVX @ DPTR,
A F0 St
oreremai
nder

4109 I
NC DPTR A3 Gotonextmemor
y
l
ocat
ion
410A MOV A,
B E5,
F0
St
orequot
ient
410C MOV @ DPTR,
A F0

410D STOP SJMP STOP 80,


FE St
op

RESULT:

I
NPUT OUTPUT
MEMORYLOCATION DATA MEMORYLOCATION DATA
4500 (di
vi
dend) 4502 (
remainder
)

4501 (
div
isor
) 4503 (
quot
ient
)

Thust
he8051ALPf
ordi
vi
sionoft
wo8bi
tnumber
sisexecut
ed.

102
LOGI
CALANDBI
TMANI
PULATI
ON
AI
M:

Towri
teanALPt
oper
for
mlogi
cal
andbi
tmani
pul
ati
onoper
ati
onsusi
ng8051
mi
crocont
rol
l
er.

APPARATUSREQUIRED:
8051mi
crocont
rol
l
erki
t

ALGORI
THM:

1.I
niti
ali
zecontentofaccumul at
orasFFH
2.Setcarryfl
ag(cy=1).
3.ANDbi t7ofaccumul at
orwi t
hcyandstor
ePSW f
ormat
.
4.ORbi t6ofPSW andst orethePSW f
ormat.
5.Setbit5ofSCON.
6.Clearbit1ofSCON.
7.Mov eSCON. 1tocarr
yr egi
ster
.
8.Stoptheexecutionofprogram.

FLOWCHART:

START

SetCYf
lag,
ANDCYwi
thMSBof

St
oret
hePSW f
ormat
,ORCYwi
thbi
t2I
Ereg

Cl
earbi
t6ofPSW,
Stor
ePSW

Setbi
t5ofSCON,
clearbi
t1andst
ore
SCON

Mov
ebi
t1ofSCONt
oCYandst
orePSW

STOP

103
PROGRAM TABLE

ADDRESS HEX LABEL MNEMONI


CS OPERAND COMMENT
CODE
4100 90,
45,
00 MOV DPTR,
#4500 Ini
ti
ali
ze memor
y
l
ocation
4103 74,
FF MOV A,
#FF Get t he dat
a i
n
accumulator
4105 D3 SETB C SetCYbi t
t
h
4016 82,
EF ANL C,
ACC.
7 Per
for
m ANDwi t
h7
bi
tofaccumul
ator
4018 E5,
D0 MOV A,
DOH
410A F0 MOVX @DPTR,
A St
oret
her
esul
t

410B A3 I
NC DPTR Got
onextl
ocat
ion
nd
410C 72,
AA ORL C,
IE.
2 ORCYbi twit
h2 bi t
i
fIEreg
th
410E C2,
D6 CLR PSW.
6 Cl
ear6 bi tofPSW

4110 E5,
D0 MOV A,
DOH
4112 F0 MOVX @DPTR,
A St
oret
her
esul
t

4113 A3 I
NC DPTR Got
onextl
ocat
ion
t
h
4114 D2,
90 SETB SCON.
5 Set5 ofSCONr eg
st
4116 C2,
99 CLR SCON.
1 Clear1 bitofSCON
reg
4118 E5,
98 MOV A,
98H
411A F0 MOVX @DPTR,
A St
oret
her
esul
t

411B A3 I
NC DPTR Got
onextl
ocat
ion
st
411C A2,
99 MOV C,
SCON.
1 Copy1 bi
tofSCON
regt
oCYfl
ag
411E E5,
D0 MOV A,
DOH
St
oret
her
esul
t
4120 F0 MOVX @DPTR,
A

4122 80,
FE L2 SJMP L2 St
op

104
RESULT:

MEMORY SPECI
ALFUNCTI
ONREGI
STERFORMAT BEFORE AFTER
LOCATI
ON EXECUTI
ON EXECUTI
ON
4500
H (
PSW) CY AC FO RS1 RS0 OV - P 00H 88H

4501
H (
PSW) CY AC FO RS1 RS0 OV - P 40H 88H

4502
H (
SCON) SM0 SM1 SM2 REN TB8 RB8 TI RI 0FH 20H

4503
H (
PSW) CY AC FO RS1 RS0 OV - P FFH 09H

Thust
hebi
tmani
pul
ati
onoper
ati
oni
sdonei
n8051mi
crocont
rol
l
er.

105
106
EXPTNO:
15 DATE:

AI
M:
Toconv
ertSquareandCubepr
ogr
am,
Find2’
scompl
ementofanumber
usi
ng8051microcont
roll
er

RESOURCESREQUI ERED:
8051microcont
rol
l
er
ki
tKeyboard
Powersupply

PROGRAM:
or
g0000h;
set
sthepr
ogr
am count
ert
o0000h
mova,#n;
assi
gnvalue'n'
indeci
malt
oAwhi
chi
sconv
ert
ed
t
oit
'sequi
val
enthexadeci
malval
ue
movb,#n;
assi
gnvalue'n'
indeci
malt
oBwhi
chi
sconv
ert
ed
t
oit
'sequi
val
enthexadeci
malval
ue
movr0,#n;
assignvalue'
n'i
ndeci
malt
oR0whi
chi
sconv
ert
ed
t
oit
'sequiv
alenthexadeci
malval
ue
ab;mul
mul ti
ply
ing'
A'wi
th'
B'
a;l
mov40h, owerby
tei
sst
oredi
naddr
ess
40h mov41h,
b;hi
gherby
tei
s st
ored i
n
addr
ess41hmovr
1,a;mov
eval
ueof'
A't
o
R1
b;mov
mova, eval
ueof'
B't
o
'
A'movb,
r0;mov
eval
ueof
R0t
ob mulab;mul
ti
ply'
A'
and'
B'
movb, l
a;owerby
teobtainedi
smovedf
rom '
A'
t
o'B'
movr 2,
b;movevalueof'
B't
oR2
mova,
r1;mov
eval
ueofR1t
o
'
A'movb,
r0;mov
eval
ueofR0
t
o'B'mulab;mul
ti
ply
ing '
A'
and'
B'
a;Lowerby
mov50h, teobt
ainedi
sst
oredi
naddr
ess50h
107
108
movr
3,b;hi
gherby
teobt
ainedi
sst
oredi
nR3
mova,
r2;mov
eval
uef
rom R2t
o'A'
adda,
r addv
3; alueof'
A'wi
thR3andst
oret
hev
aluei
n'A'
a;mov
movb, eval
uef
rom '
A't
o'B'
b;st
mov51h, orev
alueobt
ainedi
naddr
ess51h
end
SQUAREPGM USI
NG8051
ORG00h
02 LJMPMAIN
03DELAY:
04;
MOVR0, #2
05MOVTMOD,#01H
06MOVTH0,
#HIGH(-50000)
07MOVTL0,#LOW (
-50000)
08SETBTR0
09JNBTF0,
10CLRTF0
12;
DJNZR0,
DELAY
13RET
14MAIN:
15MOVDPTR,
#300H
16MOVA,
#0FFH
17MOVP1,A
18BACK:
19LCALLDELAY
20MOVA,P1
21MOVCA,
@A+DPTR
22;
MOVP2,
#00H
23;
LCALLDELAY
24MOVP2,A
25SJMPBACK
26ORG300H
27XSQR_TABLE:
28DB0,1,
4,
9,16,
25,
36,
49,
64,
81
29END
ThustheSquareandCubepr
ogr
am,
Find2’
scompl
ementofanumberi
sdone
i
n8051micr
ocontr
oll
er

109
EXPTNO:
16 DATE:

AI
M:
Toconv
ertBCDnumberi
ntoASCI
Ibyusi
ng8051mi
crocont
rol
l
er

RESOURCESREQUI ERED:
8051microcont
rol
l
er
ki
tKeyboard
Powersupply

110
FLOWCHART:

RESULT:
Thegi
vennumberi
sconv
ert
edi
ntoASCI
Iusi
ng8051mi
crocont
rol
l
erki
t.

111
Augment
edExper
iment
s

Exp.
No.
1.St
udyof8085mi
cropr
ocessor

I
NTEL8085i
soneoft
hemostpopul
ar8-
bitmi
cropr
ocessorcapabl
eof
addr
essi
ng64KBofmemor
yandi
tsar
chi
tect
urei
ssi
mpl
e.Thedev
icehas40
pi
ns,r
equi
res+5Vpowersuppl
yandcanoper
atewi
th3MHzsi
ngl
ephase
cl
ock.

ALU(
Ari
thmet
icLogi
cUni
t)
:

The8085Ahasasi
mpl
e8-
bitALUandi
twor
ksi
ncoor
dinat
ionwi
tht
he
accumul
ator
,tempor
aryr
egi
ster
s,5f
lagsandar
it
hmet
icandl
ogi
cci
rcui
ts.
ALU has t
he capabi
l
ity ofper
for
ming sev
eralmat
hemat
icaland l
ogi
cal
oper
ati
ons.Thet
empor
aryr
egi
ster
sar
eused t
o hol
dthedat
adur
ing an
ar
it
hmet
icandl
ogi
coper
ati
on.Ther
esul
tisst
oredi
ntheaccumul
atorandt
he
f
lagsar
esetorr
esetaccor
dingt
other
esul
toft
heoper
ati
on.Thef
lagsar
e
af
fect
edbyt
hear
it
hmet
icandl
ogi
coper
ati
on.Theyar
easf
oll
ows:

 Si
gnf
lag
Af
tert
heexecut
ionoft
hear
it
hmet
ic-l
ogi
coper
ati
oni
fthe
bi
tD7oft
her
esul
tis1,t
hesi
gnf
lagi
sset
.Thi
sfl
agi
susedwi
th
si
gnednumber
s.I
fiti
s1,
iti
sanegat
ivenumberandi
fiti
s0,
iti
sa
posi
ti
venumber
.

 Zer
ofl
ag
Thezer
ofl
agi
sseti
ftheALUoper
ati
onr
esul
tsi
nzer
o.Thi
s
f
lagi
smodi
fi
edbyt
her
esul
tint
heaccumul
atoraswel
lasi
not
her
r
egi
ster
s.

 Auxi
l
lar
ycar
ryf
lag
I
nanar
it
hmet
icoper
ati
onwhenacar
ryi
sgener
atedbydi
git
D3andpassedont
oD4,
theauxi
l
lar
yfl
agi
sset
.

 Par
it
yfl
ag
Af
terar
it
hmet
ic–l
ogi
coper
ati
on,i
fther
esul
thasanev
en
numberof1’
sthef
lagi
sset
.Ifi
thasoddnumberof1’
siti
sreset
.

 Car
ryf
lag
112
I
fanar
it
hmet
icoper
ati
onr
esul
tsi
nacar
ry,t
hecar
ryf
lagi
s
set
.Thecar
ryf
lagal
soser
vesasabor
rowf
lagf
orsubt
ract
ion.

Ti
mingandcont
rol
uni
t

Thi
suni
tsy
nchr
oni
zesal
lthemi
cropr
ocessoroper
ati
onwi
thacl
ockand
gener
ates t
he cont
rolsi
gnal
s necessar
yforcommuni
cat
ion bet
ween t
he
mi
cropr
ocessorandper
ipher
als.Thecont
rolsi
gnal
sRD(
read)andWR(
wri
te)
i
ndi
cat
etheav
ail
abi
l
ityofdat
aont
hedat
abus.

I
nst
ruct
ionr
egi
steranddecoder

The i
nst
ruct
ion r
egi
sterand decoderar
e par
toft
he ALU.When an
i
nst
ruct
ioni
sfet
chedf
rom memor
yiti
sloadedi
nthei
nst
ruct
ionr
egi
ster
.The
decoderdecodest
hei
nst
ruct
ionandest
abl
i
shest
hesequenceofev
ent
sto
f
oll
ow.

Regi
sterar
ray

The8085hassi
xgener
alpur
poser
egi
ster
stost
ore8-
bitdat
adur
ing
pr
ogr
am execut
ion.Theser
egi
ster
sar
eident
if
iedasB,C,D,E,HandL.t
hey
canbecombi
nedasBC,
DEandHLt
oper
for
m 16-
bitoper
ati
on.

Accumul
ator

Accumul
atori
san8-
bitr
egi
stert
hati
spar
toft
heALU.Thi
sregi
steri
s
usedt
ost
ore8-
bitdat
aandt
oper
for
m ar
it
hmet
icandl
ogi
coper
ati
on.The
r
esul
tofanoper
ati
oni
sst
oredi
ntheaccumul
ator
.

Pr
ogr
am count
er

Thepr
ogr
am count
eri
sa16-
bitr
egi
sterusedt
opoi
ntt
othememor
y
addr
essoft
henexti
nst
ruct
iont
obeexecut
ed.

113
St
ackpoi
nter

I
tisa16-
bitr
egi
sterwhi
chpoi
ntst
othememor
ylocat
ioni
nR/
W memor
y,
cal
l
edt
heSt
ack.

Communi
cat
ionl
i
nes

8085 mi
cropr
ocessor per
for
ms dat
a t
ransf
er oper
ati
ons usi
ng t
hree
communi
cat
ionl
i
nescal
l
edbuses.Theyar
eaddr
essbus,
dat
abusandcont
rol
bus.

 Addr
essbus–i
tisagr
oupof16-
bitl
i
nesgener
all
yident
if
iedasA0
–A15. Theaddr
essbusi
suni
dir
ect
ionali
.e.
,thebi
tsf
low i
none
di
rect
ion f
rom mi
cropr
ocessort
othe per
ipher
aldev
ices.I
tis
capabl
eofaddr ng216memor
essi ylocat
ions.
 Dat
abus– i
tisagr
oupof8l
i
nesusedf
ordat
afl
ow andi
tis
bi
dir
ect
ional
.Thedat
arangesf
rom 00–FF.
 Cont
rolbus – i
t consi
st of v
ari
ous si
ngl
eli
nes t
hat car
ry
sy
nchr
oni
zi
ngsi
gnal
s.Themi
cropr
ocessorusessuchsi
gnal
sfor
t
imi
ngpur
pose.

114
Ex.
No.
2. 8BI
TDATAADDI
TION

AI
M:

Toaddt
wo8bi
tnumber
sst
oredatconsecut
ivememor
ylocat
ions.

ALGORI
THM:

1.I
nit
iali
zememor ypoint
ertodatal
ocati
on.
2.Getthefir
stnumberfrom memoryinaccumul
ator
.
3.Getthesecondnumberandaddi tt
otheaccumulat
or.
4.St
oret heansweratanothermemoryl
ocati
on.

RESULT:

Thusthe8bitnumber
sst
oredat4500&4501ar
eaddedandt
her
esul
t
st
oredat4502&4503.

115
START
FLOW CHART:

[
C] 00H

[
HL] 4500H

[
A] [
M]

[
HL] [
HL]
+1

[
A] [
A]+[
M]

I
sthere
acarr
y?

NO [
C] [
C]+1

[
HL] [
HL]
+1

[
M] [
A]
y
[
HL] [
HL]
+1

[
M] [
C]

STOP
116
PROGRAM:

ADDRESS OPCODE LABEL MNEMONICS OPERAND COMMENT


4100 START MVI C,00 Cl
earCr
eg.
4101
4102 LXI H,
4500 I
nit
ial
i
zeHLr eg.t
o
4103 4500
4104
4105 MOV A,
M Transferfir
stdatato
accumul at
or
4106 I
NX H I
ncrementHLr eg.to
pointnextmemor y
Location.
4107 ADD M Addf i
rstnumbert o
acc.Cont ent.
4108 JNC L1 Jumpt ol
ocationif
4109 resultdoesnoty i
eld
410A carr
y .
410B I
NR C I
ncrementCr eg.
410C L1 I
NX H IncrementHLr eg.to
poi ntnextmemor y
Location.
410D MOV M,
A Transferther esul
t
from acc.tomemor y.
410E I
NX H I
ncr ementHLr eg.to
poi ntnextmemor y
Location.
410F MOV M,
C Mov ecar r
ytomemor y
4110 HLT Stopt hepr ogram

OBSERVATI
ON:

INPUT OUTPUT
4500 4502
4501 4503

RESULT:

117
Thusthe8bitnumber
sst
oredat4500&4501ar
eaddedandt
he
r
esul
tstoredat4502&4503.

118

You might also like