mp lab for bme.docx
TRANSCRIPT
-
8/15/2019 MP LAB FOR BME.docx
1/103
BM6511 - MICROPROCESSOR AND MICROCONTROLLER LABORATORY
Syllabus
LIST OF EXPERIMENTS:
8086 Pr!ra"s us#$! %#&s a$' MASM
1. Basic arithmetic and Logical operations
2. Move a data block without overlap
3. Code conversion, decimal arithmetic and Matri operations.
!. "loating point operations, string manipulations, sorting and searching
#. $assword checking, $rint %&M si'e and s(stem date
). Counters and *ime +ela(
P(r#)*(rals a$' I$&(r+a,#$! E-)(r#"($&s
. *raic light control
. /tepper motor control
0. +igital clock
1. e( board and +ispla(
11. $rinter status
12. /erial interace and $arallel interace
13. &+ and +& interace and 4aveorm 5eneration
8051 E-)(r#"($&s us#$! %#&s a$' MASM
1!. Basic arithmetic and Logical operations
1#. /6uare and Cube program, "ind 27s complement o a number
1). 8npacked BC+ to &/C99
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
2/103
INDEX
S.N T#&l( + &*( E-)(r#"($& Pa!(
N.
&rchitecture o ) 1
8086 Pr!ra"s
1a. Basic &rithmetic ;perations 11
1b. Basic Logical ;perations 1#
2 Move a +ata Block 4ithout ;verlap 1
3a Code Conversion 10
3b +ecimal &rithmetic ;perations 21
3c Matri ;perations 23
!a /tring Manipulations 2#
!b /orting and /earching 20
# $assword Checking, $rint %am /i'e and /(stem +ate 33
) Counters and *ime +ela(s 3#P(r#)*(rals a$' I$&(r+a,#$! E-)(r#"($&s
*raic light Controller 3
/tepper Motor 9nteracing 30
0 +igital Clock !1
1 9nteracing $rogrammable e(board and +ispla( Controller- 20 !3
11 $rinter /tatus !
12 9nteracing $$9 2## !0
13a 9nteracing &nalog to +igital Converter #1
13b 9nteracing +igital to &nalog Converter #3
8051/E-)(r#"($&s1!a Basic &rithmetic ;perations #
1!b Basic Logical ;perations #0
1# /6uare and Cube $rogram, "ind 27s Complement o a uestions 1
ASSEMBLIN AND EXECTIN T2E PRORAM
3r#$! a$ Ass("bly La$!ua!( Pr!ra" 4ALP
&ssembl( level programs generall( abbreviated as &L$ are written in tet editor :+9*.
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
3/103
*(pe :+9* in ront o the command prompt to open an untitled tet ile.
:+9*?ile [email protected]
&ter t(ping the program save the ile with appropriate ile name with an etension .&/M
:A &dd.&/M
Ass("bl#$! a$ ALP
*o assemble an &L$ an eecutable ile called M&/M.:: is re6uired. ;nl( i this ileis in current working director( the program can be assembled. *he command is
M&/M?ilename.&/M@
9 the program is ree rom all s(ntactical errors, this command will give the ;B:C* ile. 9ncase o errors it list out the number o errors, warnings and kind o error.
-
8/15/2019 MP LAB FOR BME.docx
4/103
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
5/103
ARC2ITECTRE OF 8086 MICROPROCESSOR
The internal architecture 8086 microprocessor is as shown in the fgure. The8086 CPU is divided into two independent unctional parts, the Bus interace unit B!U"and e#ecution unit $U". The Bus !nterace Unit contains Bus !nterace %ogic, &egmentregisters, 'emor( addressing logic and a &i# )(te instruction o)*ect code +ueue. The
e#ecution unit contains the ata and -ddress registers, the -rithmetic and %ogic Unit,the Control Unit and ags.
The B!U sends out address, etches the instructions rom memor(, read datarom ports and memor(, and writes the data to ports and memor(. !n other words theB!U handles all transers o data and addresses on the )uses or the e#ecution unit.
The e#ecution unit $U" o the 8086 tells the B!U where to etch instructions ordata rom, decodes instructions and e#ecutes instruction. The $U contains controlcircuitr( which directs internal operations. - decoder in the $U translates instructionsetched rom memor( into a series o actions which the $U carries out. The $U is has a/6)it -%U which can add, su)tract, -1, 23, 423, increment, decrement,
complement or shit )inar( num)ers. The $U is decoding an instruction or e#ecuting
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
6/103
an instruction which does not re+uire use o the )uses.
The Queue: The B!U etches up to 6 instruction )(tes or the ollowing instructions. The B!U stores these preetched )(tes in frstinfrstout register set called a +ueue.5hen the $U is read( or its ne#t instruction it simpl( reads the instruction )(tes" orthe instruction rom the +ueue in the B!U. This is much aster than sending out anaddress to the s(stem memor( and waiting or memor( to send )ac the ne#tinstruction )(te or )(tes. $#cept in the case o 7'P and C-%% instructions, where the+ueue must )e dumped and then reloaded starting rom a new address, this preetchand+ueue scheme greatl( speeds up processing. etching the ne#t instruction whilethe current instruction e#ecutes is called pipelining.
Word Read $ach o / 'B memor( address o 8086 represents a )(te wide location./6)itwords will )e stored in two consecutive memor( locations. ! frst )(te o the data isstored at an even address, 8086 can read the entire word in one operation.
or e#ample i the /6 )it data is stored at even address 009:0; is ; '2? B4, @009:0;A8086 reads the frst )(te and stores the data in B% and reads the :nd )(te and storesthedata in B; B% 009:0;"i.e.B%=>; B; 009:/;"B;
-
8/15/2019 MP LAB FOR BME.docx
7/103
is :0)its long is generated using segment and oEset registers each o the siFe /6)it.The content o a segment register also called as segment address, and content o an oEset register also called as oEset address. To get total ph(sical address, put thelower ni))le 0; to segment address and add oEset address. The fgure showsormation o :0)it ph(sical address.
R(!#s&(r Or!a$#a$ + 8086:
8086 has a powerul set o registers containing general purpose and specialpurpose registers. -ll the registers o 8086 are /6)it registers. The general purposeregisters, can )e used either 8)it registers or /6)it registers. The general purposeregisters are either used or holding the data, varia)les and intermediate resultstemporaril( or or other purpose lie counter or or storing oEset address or someparticular addressing modes etc. The special purpose registers are used as segmentregisters, pointers, inde# registers or as oEset storage registers or particular
addressing modes. ig shows register organiFation o 8086. 5e will categoriFe theregister set into our groups as ollowsD
The registers -4, B4, C4, and 4 are the general /6)it registers.
AX Register: -ccumulator register consists o two 8)it registers -% and -;, whichcan )e com)ined together and used as a /6 )it register -4. -% in this case containsthe loworder )(te o the word, and -; contains the highorder )(te. -ccumulator can)e used or !G2 operations, rotate and string manipulation.
BX Register: This register is mainl( used as a )ase register. !t holds the starting )aselocation o a memor( region within a data segment. !t is used as oEset storage ororming ph(sical address in case o certain addressing mode.
CX Register: !t is used as deault counter or count register in case o string and loopinstructions.
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
8/103
DX Register: ata register can )e used as a port num)er in !G2 operations andimplicit operand or destination in case o ew instructions. !n integer =:)it multipl(and divide instruction the 4 register contains highorder word o the initial orresulting num)er.
Segment registers: To complete /')(te memor( is divided into /6 logical segments. The complete/')(te memor( segmentation is as shown in fgure. $ach segment contains 6>H)(teo memor(. There are our segment registers.
Code segment (CS) is a /6)it register containing address o 6> HB segment withprocessor instructions. The processor uses C& segment or all accesses to instructionsreerenced )( instruction pointer !P" register. C& register cannot )e changed directl(.
The C& register is automaticall( updated during ar *ump, ar call and ar returninstructions. !t is used or addressing a memor( location in the code segment o thememor(, where the e#ecuta)le program is stored.
Stack segment (SS) is a /6)it register containing address o 6>HB segment withprogram stac. B( deault, the processor assumes that all data reerenced )( thestac pointer &P" and )ase pointer BP" registers is located in the stac segment. &®ister can )e changed directl( using P2P instruction. !t is used or addressing stacsegment o memor(. The stac segment is that segment o memor(, which is used tostore stac data.
Data segment (DS) is a /6)it register containing address o 6>HB segment withprogram data. B( deault, the processor assumes that all data reerenced )( generalregisters -4, B4, C4, 4" and inde# register &!, !" is located in the data segment.& register can )e changed directl( using P2P and %& instructions. !t points to thedata segment memor( where the data is resided.
Etra segment (ES) is a /6)it register containing address o 6>HB segment, usuall(with program data. B( deault, the processor assumes that the ! register reerencesthe $& segment in string manipulation instructions. $& register can )e changeddirectl( using P2P and %$& instructions. !t also reers to segment which essentiall( isanother data segment o the memor(. !t also contains data.
!ointers and inde registers:
The pointers contain within the particular segments. The pointers !P, BP, &Pusuall( contain oEsets within the code, data and stac segments respectivel(.
Stack !ointer (S!) is a /6)it register pointing to program stac in stac segment.
Base !ointer (B!) is a /6)it register pointing to data in stac segment. BP registeris usuall( used or )ased, )ased inde#ed or register indirect addressing.
Source "nde (S") is a /6)it register. &! is used or inde#ed, )ased inde#ed andregister indirect addressing, as well as a source data addresses in string manipulationinstructions.
Destination "nde (D") is a /6)it register. ! is used or inde#ed, )ased inde#ed andregister indirect addressing, as well as a destination data address in stringmanipulation instructions.
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
9/103
Fla! r(!#s&(r:
lags 3egister determines the current state o the processor. The( are modifedautomaticall( )( CPU ater mathematical operations, this allows to determine the t(peo the result, and to determine conditions to transer control to other parts o theprogram. The 8086 ag register as shown in the fgure. 8086 has < active ags andthe( are divided into two categoriesD/. Conditional lags:. Control lags
Conditiona# $#ags
Conditional ags are as ollowsD
Carry $#ag (C%): This ag indicates an overow condition or unsigned integerarithmetic. !t is also used in multipleprecision arithmetic.
Aui#iary $#ag (AC): ! an operation perormed in -%U generates a carr(G)arrow romlower ni))le i.e. 0 I =" to upper ni))le i.e. > I ", the -C ag is set i.e. carr(given )( = )it to > is -C ag. This is not a generalpurpose agJ it is used internall()( the Processor to perorm Binar( to BC conversion.!arity $#ag (!$): This ag is used to indicate the parit( o result. ! lower order 8)itso the result contains even num)er o /Ks, the Parit( lag is set and or odd num)er o /Ks, the Parit( ag is reset.
&ero $#ag (&$): !t is setJ i the result o arithmetic or logical operation is Fero else it is
reset.
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
10/103
Sign $#ag (S$): !n sign magnitude ormat the sign o num)er is indicated )( '&B )it.! the result o operation is negative, sign ag is set.
Contro# $#ags
Control ags are set or reset deli)eratel( to control the operations o the e#ecutionunit. Control ags are as ollowsD
Tra' $#ag (T$): !t is used or single step control. !t allows user to e#ecute oneinstruction o a program at a time or de)ugging. 5hen trap ag is set, program can)e run in single step mode.
"nterru't $#ag ("$): !t is an interrupt ena)leGdisa)le ag. ! it is set, the masa)leinterrupt o 8086 is ena)led and i it is reset, the interrupt is disa)led. !t can )e set )(e#ecuting instruction sit and can )e cleared )( e#ecuting C%! instruction.
Direction $#ag (D$): !t is used in string operation. ! it is set, string )(tes areaccessed rom higher memor( address to lower memor( address. 5hen it is reset, thestring )(tes are accessed rom lower memor( address to higher memor( address.
$%;5%&MM9
-
8/15/2019 MP LAB FOR BME.docx
11/103
E-. N.1a BASIC ARIT2METIC OPERATIONS
AIM
*o write an assembl( language program to perorm 1) bit &rithmetic operations such as
addition, subtraction, Multiplication, division using ) Microprocessor it and M&/M.
APPARATS RE7IRED
S. N R(u#r(' C")$($&s S)(,#+#,a$ 7ua$&
y
1. M9C%;$%;C://;% M9C%; ) 9* 1
2. $;4:% CG;%+ H#= /8$$LI 1
3. :I B;&%+ 1
!. $C 49*G M&/M 1
ALORIT2M:
4# 16/b#& A''#$ /tep 1A /tart the program/tep 2A 5et the irst number./tep 3A &dd the second number to the irst number./tep !A /tore the result./tep #A /top the program
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
12/103
4## 16/b#& Sub&ra,$ /tep 1A /tart the program/tep 2A 5et the irst number /tep 3A /ubtract the second number rom the irst number./tep !A /tore the result.
/tep #A /top the program.
4### 16 b#& Mul)l#,a$
/tep 1A /tart the program/tep 2A 5et the multiplier./tep 3A 5et the multiplicand/tep !A Multipl( second data with irst data/tep #A /tore the product in memor(/tep )A /top the program
4#9 168 a$' ;
-
8/15/2019 MP LAB FOR BME.docx
13/103
MLTIPLICATION DI=ISION
ADDITION
A''r(ss Lab(l M$("$#,s C""($&s
1 M;= &,J12K 5et the irst data in & reg.
1! &++ &,J122K&dd the contents o memor( locationto &
1 M;= J12!K,& /tore the sum
1B GL* /top the program
SBTRACTION:
A''r(ss Lab(l M$("$#,s C""($&s
1 M;= &,J12K 5et the irst data in & reg.
1! /8B &,J122K/ubtract the contents o memor(location rom &
1 M;= J12!K,& /tore the sum
1B GL* /top the program
MLTIPLICATION:
A''r(ss Lab(l M$("$#,s C""($&s
1 M;= &,J12K 5et the irst data in & reg.
1! M;= B,J122K 5et the second data in B reg.
1 M8L B Multipl( the contents o B with &
1B M;= J12!K,& /tore the lower order result in memor(
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
14/103
location
1: M;= J12)K,+/tore the higher order result inmemor( location
112 GL* /top the program
168 b#& DI=ISION:
A''r(ss Lab(l M$("$#,s C""($&s
1 M;= &,J12K 5et the dividend in & reg.
1! M;= C,J12!K 5et the divisor in C reg.
1 +9= C +ivide the contents o & b( C
1B M;= J12!K,&/tore the remainder in memor(location
1: M;= J12)K,+ /tore the 6uotient in memor( location
112 GL* /top the program
;
-
8/15/2019 MP LAB FOR BME.docx
15/103
M;= J/9K,&
-
8/15/2019 MP LAB FOR BME.docx
16/103
M;= J/9HK,+M;= &G,!CG9
-
8/15/2019 MP LAB FOR BME.docx
17/103
/*&%*
Move data to & and B
$erorm ;% with BL and BG
$erorm &
-
8/15/2019 MP LAB FOR BME.docx
18/103
Obs(r9a$:
M("ry L,a$ Da&a I$)u&Ou&)u&
E-. N.1b BASIC LOICAL OPERATIONS
AIM
*o write an assembl( language program to perorm logical operations using )
Microprocessor it and M&/M.
APPARATS RE7IRED
S.$ R(u#r(' C")$($&s S)(,#+#,a$ 7ua$&
y
1. M9C%;$%;C://;% M9C%; ) 9* 1
2. $;4:% CG;%+ H#= /8$LLI 1
3. :I B;&%+ 1!. $C 49*G M&/M 1
ALORIT2M:
/tep 1A /tart the program/tep 2A 5et the data to &L, &G, BL and BG registers./tep 3A $erorm ;% operation with contents o BL and BG registers./tep !A $erorm &
-
8/15/2019 MP LAB FOR BME.docx
19/103
Pr!ra" Tabl(:
A''r(ss Lab(l M$("$#,s C""($&s
M;= &L,2+G 5et the data in &L reg.
M;= &G,3:G 5et the data in &G reg.
M;= BL,!"G 5et the data in BL reg.
M;= BG,#&G 5et the data in BG reg.
;% BL,BG ;% contents o BL and BG registers.
&
-
8/15/2019 MP LAB FOR BME.docx
20/103
&
-
8/15/2019 MP LAB FOR BME.docx
21/103
2)servationD
M("ry L,a$ Da&a I$)u& Ou&)u&
$#D 1o : '2?$ - -T- B%2CH 5!T;2UT 2?$3%-P
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
22/103
-!'D
*o write an assembl( language program to move a block o data without overlappingusing ) Microprocessor it.
APPARATS RE7IRED:
S.$ R(u#r(' C")$($&s S)(,#+#,a$ 7ua$&
y
1. M9C%;$%;C://;% M9C%; ) 9* 1
2. $;4:% CG;%+ H#= /8$$LI 1
3. :I B;&%+ 1
!. $C 49*G M&/M 1
-%L23!T;'D
/tep 1A /tart the program
/tep 2A 9nitiali'e CL register with number o data to be transormed/tep 3A 9nitiali'e the pointer to the memor( where data to be transormed./tep !A Load the &L register with the data rom memor(./tep #A 9nitiali'e destination pointer to the memor( where data to be stored./tep )A /tore data rom &L register./tep A +ecrement count value. 9 count is not 'ero repeat steps 3 and !./tep A /top the program
Program Ta)leD
A''r(ss Lab(l M$("$#,s COMMENTSM;= /9,1#G Move starting address o block to /9 register
M;= +9,1)G Move +estination address o block to +9 register
M;= C,#G get number o data to be moved to C register
L1A M;= &,J/9K Move irst data to accumulator
M;= J+9K,& Move data rom &cc to destination
9
-
8/15/2019 MP LAB FOR BME.docx
23/103
%25C;-3TD
1F G: to &/C99
2F &/C99 to G: 3F BC+ to G:
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
24/103
$#. 1oD =a C2$ C21?$3&!21
-!'D
*o write an assembl( language program using ) Microprocessor it to convert theollowingA
1F G: to &/C992F &/C99 to G:3F BC+ to G:
APPARATS RE7IRED:
S.$ R(u#r(' C")$($&s S)(,#+#,a$ 7ua$&
y
1. M9C%;$%;C://;% M9C%; ) 9* 1
2. $;4:% CG;%+ H#= /8$$LI 1
3. :I B;&%+ 1
-%L23!T;'D
1F G: to &/C99/tep 1A /tart the program/tep 2A Load &L register with input data/tep 3A 9 &L is less than or e6ual to 0, add seven to &L/tep !A &dd 3h to &L/tep #A /tore result in memor(/tep )A /top the program
:" &/C99 to G:/tep 1A /tart the program/tep 2A Load &L register with input data/tep 3A subtract 3h rom &L/tep !A 9 &L greater than 0, subtract h rom &L/tep #A /tore the %esult/tep )A /top the program
3F BC+ to G:
/tep 1A /tart the program
/tep 2A Load the data in &L register./tep 3A /eparate higher nibbles and EinF lower nibbles./tep !A Move the higher nibbles EinF to lower nibbles position./tep #A Multipl( &L b( 1./tep )A &dd lower nibbles./tep A /tore the result into Memor(./tep A /top the program
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
25/103
Program Ta)leD
-&C!! ;$4
A''r(ss Lab(l M$("$#,s C""($&s
M;= /9,1#G Move the starting address to /9
M;= +9,1)G Move the destination address to +9
M;= &L,J/9K Move the content o /9 to accumulator
M;= CL,!G Move the count value to CL
&
-
8/15/2019 MP LAB FOR BME.docx
26/103
G: to &/C99
A''r(ss Lab(l M$("$#,s C""($&s
M;= /9,1#G Move the starting address to /9
M;= +9,1)G Move the destination address to +9M;= &L,J/9K Move the content o /9 to accumulator
/8B &L,3G /ubtract 3h rom &L
C L1 ump on carr( to L1
/8B &L, /ubtract 3h rom &L
L1A M;= J+9K,&L Move BL to destination
GL* /top
BC+ to G:
A''r(s
s
Lab(l M$("$#,s C""($&s
M;= /9,1# &llocate memor( to /9
M;= +9,1) &llocate memor( to +9
M;= &L,J/9K Move the contents o /9 to &L
M;= &G, Move to &GM;= BL,)! Move )! to BL
+9= BL +ivide &L b( BL
M;= +9,J&LK Move &L to B9
M;= &L,&G Move &G to &L
M;= &G, Move to &G
M;= +L,& Move & to +L
+9= +L +ivide &L b( +L
M;=J+9H1K,&L Move &L to +9H&
M;=J+9H2K,&G Move &G to +9H2
GL* /top the program
3$&U%TD
*hus code conversions are perormed using ) Microprocessor it.
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
27/103
/*&%*
5et the irst data
subtract second data rom irst data
&dDust the result to BC+ orm
/tore the result
/*;$
/*&%*
5et the irst data
&dd second data with irst data
&dDust the result to BC+ orm
/tore the result
/*;$
FLO3C2ART
16/b#& A''#$ 16/b#& Sub&ra,$
Obs(r9a$:
O)(ra$ M("ry L,a$ Da&a I$)u&Ou&)u&
A''#$
Sub&ra,$
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
28/103
$#. 1o. =) $C!'-% -3!T;'$T!C 2P$3-T!21&
AIM
*o perorm 1) bit +ecimal &rithmetic operation such as addition and subtraction using
) Microprocessor it.
APPARATS RE7IRED
S.$ R(u#r(' C")$($&s S)(,#+#,a$ 7ua$&
y
1. M9C%;$%;C://;% M9C%; ) 9* 1
2. $;4:% CG;%+ H#= /8$$LI 1
3. :I B;&%+ 1
ALORIT2M:
4# 16/b#& A''#$ /tep 1A 5et the irst number./tep 2A &dd the second number to the irst number./tep 3A &dDust the result to BC+./tep !A /tore the result./tep #A /top the program
4## 16/b#& Sub&ra,$ /tep 1A 5et the irst number
/tep 2A /ubtract the second number rom the irst number./tep 3A &dDust the result to BC+/tep !A /tore the result/tep #A /top the program
ADDITION
A''r(ss Lab(l M$("$#,s C""($&s
M;= &,J12K 5et the irst data in & reg.
&++ &,J122K &dd the contents o memor( location to &
+&& &dDust result to BC+ orm
M;= J12!K,& /tore the sum
GL* /top the program
SBTRACTION:
A''r(ss Lab(l M$("$#,s C""($&s
M;= &,J12K 5et the irst data in & reg.
/8B &,J122K/ubtract the contents o memor( locationrom &
+&/ &dDust result to BC+ orm
M;= J12!K,& /tore the sum
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
29/103
GL* /top the program
RESLT:
*hus decimal arithmetic operations are perormed using ) Microprocessor it.FLO3 C2ART
Obs(r9a$:
O)(ra$ M("ry L,a$ Da&a I$)u& Ou&)u&
A''#$
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
30/103
E-. N.;, MATRIX OPERATIONS
AIM
*o write an assembl( language program to perorm matri operation using )
Microprocessor it.
APPARATS RE7IRED
S.$ R(u#r(' C")$($&s S)(,#+#,a$ 7ua$&
y
1. M9C%;$%;C://;% M9C%; ) 9* 1
2. $;4:% CG;%+ H#= /8$$LI 13. :I B;&%+ 1
ALORIT2M:
/tep 1A /tart the program/tep 2A 9nitiali'e the pointer to memor( or data and result./tep 3A Load CL with count./tep !A &dd two matrices b( each element./tep #A i CL is not , repeat step !/tep )A /tore the result into Memor(/tep A /top the program
Pr!ra" Tabl(:
LABEL M$("$#,s COMMENTS
M;= CL, 0G 9nitiali'e 0 into CL register
M;= /9, 2G Load 2 into /9 or 1st matri
M;= +9, 3G Load 3 into +9 or 2nd matri
L1A M;= &L, J/9K Load &L with data o irst matri
M;= BL, J+9K Load BL with data o second matri
&++ &L, BL &dd two data o &L and BL
M;= J+9K, &L /tore &L with data into +9
9
-
8/15/2019 MP LAB FOR BME.docx
31/103
/*&%*
9nitiali'e /9, +9
9nitiali'e CL with length o string and +"
Move a b(te rom source string to destination string
9ncrement /9 and +9
+ecrement count
" 1N
/*;$
-
8/15/2019 MP LAB FOR BME.docx
32/103
-
8/15/2019 MP LAB FOR BME.docx
33/103
/tep A 9 not 'ero, increment + b( 1./tep A %epeat steps # to until &L matches with terminating string/tep 0A /tore length o string E+ register contentsF in memor(
/tep 1A /top the program
RESLT: *hus code conversions are perormed using ) Microprocessor it.
Pr!ra":
S&r#$! M9(:
A''r(ss Lab(l M$("$#,s C""($&s
M;= /9, 11G Load 11 to /9
M;= +9, 12G Load 12 to +9
M;= C,&G Load C with count value
CL+ +", increments /9 and +9
L1A M;=/B Move string rom source to destination
L;;$ L1 +ecrement count. 9 not 'ero, Dump to L1
GL* /top the program
S&r#$! S&r(:
A''r(ss Lab(l M$("$#,s C""($&s
M;= +9,12G &llocate memor( to +9
M;= C,&G Move &G to C
M;= &L,!3G Move !3G to &L
CL+ Clear direction lag
L1A /*;/B /tore string b(te
L;;$ L1 :ecute till condition is alse
GL* /top the program
L($!&* + &*( S&r#$!:
A''r(ss Lab(l M$("$#,s C""($&s
M;= /9,12G &llocate memor( to /9
M;= &G,!G Move the value o !h to &G
M;= +,G Move G to +
9
-
8/15/2019 MP LAB FOR BME.docx
34/103
L($!&* + &*(
s&r#$!
FLO3 C2ART
LAREST SMALLEST NMBER
Obs(r9a$:
O)(ra$ M("ry L,a$ Da&a I$)u& Ou&)u&
Lar!(s& Nu"b(r
S"all(s& Nu"b(r
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
35/103
FLO3 C2ART
ASCENDIN DESCENDIN ORDER
Obs(r9a$:
O)(ra$ M("ry L,a$ Da&a I$)u& Ou&)u&
As,($'#$! Or'(r
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
36/103
D(s,($'#$! Or'(r
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
37/103
E-. N. >b SORTIN AND SEARC2IN
AIM
*o write an assembl( language program using ) Microprocessor it to perorm the
ollowingA
EiF Largest /mallest number
EiiF &scending +escending order
APPARATS RE7IRED
S. N R(u#r(' C")$($&s S)(,#+#,a$ 7ua$&
y
1. M9C%;$%;C://;% M9C%; ) 9* 1
2. $;4:% CG;%+ H#= /8$LLI 1
3. :I B;&%+ 1
ALORIT2M:
LAREST SMALLEST NMBER
/tep 1A /tart the program/tep 2A Load the arra( count in a register CL/tep 3A 5et the irst two numbers/tep !A Compare the numbers and echange i the number is small large./tep #A 5et the third number rom the arra( and repeat the process until CL is /tep )A /tore the small large number in memor(/tep A /top the program
ASCENDIN DESCENDIN ORDER /tep 1A /tart the program/tep 2A Load the arra( count in two registers CL and +L./tep 3A 5et the irst two numbers./tep !A Compare the numbers and echange i necessar( so that the two numbers are in
ascending descending order./tep #A +ecrement +L./tep )A 5et the third number rom the arra( and repeat the process until +L is ./tep A +ecrement CL and repeat the process until CL is ./tep A /top the program
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
38/103
ASCENDIN DESCENDIN ORDER
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
39/103
LAREST NMBER
A''r(ss LABEL M$("$#,s C""($&s
M;= /9,12G 9nitiali'e arra( si'e
M;= CL,J/9K 9nitiali'e the count
9
-
8/15/2019 MP LAB FOR BME.docx
40/103
M;= J+9K,&L :lse store the biggest number in 13location
GL* /top
ASCENDIN ORDER
A''r(ss Lab(l M$("$#,s C""($&s
M;= /9,12G 9nitiali'e memor( location or arra( si'e
M;= CL,J/9K
-
8/15/2019 MP LAB FOR BME.docx
41/103
DESCENDIN ORDER
A''r(ss Lab(l M$("$#,s C""($&s
M;= /9,12G 9nitiali'e memor( location or arra( si'e
M;= CL,J/9K
-
8/15/2019 MP LAB FOR BME.docx
42/103
Obs(r9a$:
O)(ra$ M("ry L,a$ Da&a I$)u& Ou&)u&
Lar!(s& Nu"b(r
S"all(s& Nu"b(r
As,($'#$! Or'(r
D(s,($'#$! Or'(r
RESLT:
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
43/103
E-. N. 5 PASS3ORD C2EC?IN@ PRINT RAM SIE AND SYSTEM DATE
AIM
*o write an assembl( language program or the ollowing
EiF $assword checking,
EiiF $rint %&M si'e and
EiiiF /(stem date
APPARATS RE7IRED
S.$ R(u#r(' C")$($&s 7ua$&y
1. $C with M&/M 1
2. $;4:% CG;%+ 1
3. :I B;&%+ 1
ALORIT2M
$assword checkingA/tep 1A /tart the $rogram
/tep 2A /et string as password
/tep 3A :nter password
/tep !A compare entered password with set password
/tep #A 9 the( are not e6ual, displa( error message and go to step 3
/tep )A :lse displa( 4:LC;M: i password matches
/tep A /top the program
$rint %&M si'e
/tep 1A /tart the $rogram
/tep 2A %ead the %&M si'e in /9 using 9
-
8/15/2019 MP LAB FOR BME.docx
44/103
-
8/15/2019 MP LAB FOR BME.docx
45/103
-
8/15/2019 MP LAB FOR BME.docx
46/103
L:& /9,%/99
-
8/15/2019 MP LAB FOR BME.docx
47/103
&//8M: C/ASC;+:,+/A+&*& /*&%*A M;= &,S+&*& M;= +/,& M;= &G,2&G
9
-
8/15/2019 MP LAB FOR BME.docx
48/103
M;= J/9K,&L L;;$ %$*2 9
-
8/15/2019 MP LAB FOR BME.docx
49/103
FLO3 C2ART:
Obs(r9a$:
O)(ra$ M("ry L,a$ Da&a I$)u& Ou&)u&
Cu$&(r a$' T#"(r
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
/*&%*
9nitiali'e /9 with 12
Move &L with
/tore to memor(
9ncrement /9 and &L
5enerate time dela( or 1 sec
9s &L &
-
8/15/2019 MP LAB FOR BME.docx
50/103
E-. N. 6 CONTERS AND TIME DELAYS
AIM
*o write an assembl( language program to count with time dela( o 1 sec. using
M&/M.
APPARATS RE7IRED
S. N R(u#r(' C")$($&s S)(,#+#,a$ 7ua$&
y
1. $C 49*G M&/M 1
ALORIT2M:
/tepA 1 /tart the program/tep 2A 9nitiali'e /9 with 12/tep 3A Move &L with /tep !A /tore the counter value to memor(
/tep #A 9ncrement /9 and &L/tep )A 5enerate time dela( or 1 sec/tep A Check count is e6ual to &G/tep A 9 not e6ual, go to /tep !/tep 0A :lse, /top the program
Pr!ra" Tabl(:
A''r(s
s
Lab(l M$("$#,s C""($&s
M;= /9,12G 9nitiali'e /9 with memor( address
M;= &L, 9nitiali'e counter &L with
L3A M;= J/9K,&L Move to memor(
9
-
8/15/2019 MP LAB FOR BME.docx
51/103
-
8/15/2019 MP LAB FOR BME.docx
52/103
RESLT:
INTERFACIN ADD ON CARDS
3IT2 8086
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
53/103
E-. N. TRAFFIC LI2T CONTROLLER
AIM:
*o write an assembl( language program to implement a traic light controller.
APPARATS RE7IRED
S. N R(u#r(' C")$($&s s)(,#+#,a$ 7&y
1. M9C%;$%;C://;% M9C%; ) 9* 12. $;4:% CG;%+ H#= /8$LLI 1
3. :I B;&%+ 1
!. *%&""9C L95G* C;
-
8/15/2019 MP LAB FOR BME.docx
54/103
LABEL MNEMONICS COMMENTS
M;= &L,G Load accumulator with value o h
;8* #)G,&L /end through output port
L2A M;= +L,! Move ! to +L
M;= +9,12 Move the address 12 to /9
M;= &L,J/9K Move the content o /9 to &L
;8* #,&L /end through output port
9
-
8/15/2019 MP LAB FOR BME.docx
55/103
/*&%*
9nitiali'e Counter or Look 8p *able
5et the "irst +ata rom the &ccumulator
Move +ata into the &ccumulator
+rive *he Motor Circuitr(
+ecrement Counter
5 e t t h e + a t a - r o m L o o k 8 p * a b l e
9/ B N
+ela(
I:/
-
8/15/2019 MP LAB FOR BME.docx
56/103
-
8/15/2019 MP LAB FOR BME.docx
57/103
-
8/15/2019 MP LAB FOR BME.docx
58/103
RESLT: E-. N. DIITAL CLOC?
AIM
*o write an assembl( language program to count with time dela( o 1 sec. using
M&/M.
APPARATS RE7IRED
S. N R(u#r(' C")$($&s S)(,#+#,a$ 7ua$&
y
1. $C 49*G M&/M 1
ALORIT2M:
/tepA 1 /tart the program/tep 2A 9nitiali'e /9 with /tep 3A 9ncrement /9/tep !A $rint on standard displa( using 9
-
8/15/2019 MP LAB FOR BME.docx
59/103
PRORAM:
C;+: /:5M:
-
8/15/2019 MP LAB FOR BME.docx
60/103
E-. N. 10 INTERFACIN PRORAMMABLE ?EYBOARDAND DISPLAY
CONTROLLER/ 8
-
8/15/2019 MP LAB FOR BME.docx
61/103
1/E$abl(s Cl(ar '#s)lay
0/C$&($&s + RAM #ll b( '#s)lay('
1/FIFO S&a&us #s ,l(ar('
1/Cl(ar all b#&s
4C"b#$(' (++(,& + CD
1. D#s)lay M'( S(&u): C$&rl r'/10 2
1 0 0 1 0 0 0 0
0 0 0 D D ? ? ?
++ - Bit character displa( let entr( 1- 1)Bit character displa( let entr( 1- Bit character displa( right entr( 11- 1)Bit character displa( right entr(- e( Board Mode -2e( lockout.
-
8/15/2019 MP LAB FOR BME.docx
62/103
Pr!ra" Tabl(:
A''r(ss Lab(l M$("$#,s C""($&s
/*&%* A M;= /9,12G 9nitiali'e the lookup table
M;= C,"G Count or number o characters to bedispla(ed
M;= &L,1G /tore the control word or displa(mode
;8* C2,&L /end through output port
M;= &L,CCG /tore the control word to cleardispla(
;8* C2,&L /end through output port
M;= &L,0G /tore the control word to writedispla(
;8* C2,&L /end through output port
L1 A M;= &L,J/9K 5et the irst data
;8* C,&L /end through output port
C&LL +:L&I Call dela( routine
9
-
8/15/2019 MP LAB FOR BME.docx
63/103
SE=EN SEMENT DISPLAY G COMMON ANODE
LOO?/P TABLE:
MEMORY
LOCATIO
N
/SEMENT LED FORMAT 2EX DATA
' , b a ') ! + (
12G 1 1 1 0
121G 1 1 1 )
122G 1 1 1 1 1 C
123G 1 1 1 C
12!G 1 1 1 1 1 1 1 1 ""
12#G 1 1 1C
12)G 1 1 1 20
12G 1 1 1 1 1 1 1 1 ""
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
64/103
E-. N. 11 PRINTER STATS
AIM:*o write an assembl( language program b( interacing $rinter with )
microprocessor kit.
APPARATS RE7IRED:
S. N R(u#r(' C")$($&s S)(,#+#,a$ 7ua$&
y
1. M9C%;$%;C://;% M9C%; ) 9* 1
2. $;4:% CG;%+ H#= /8$LLI 1
3. :I B;&%+ 1
!. 9
-
8/15/2019 MP LAB FOR BME.docx
65/103
Pr!ra" Tabl(:
A''r(ss Lab(l M$("$#,s C""($&s
M;= BL,&L 5et the &/C99 code in BL
M;= &L,2G Control word or 2##
;8* ")G,&L Load C4% with the control word
B8/IA 9< &L,"2G %ead printer status rom the bus( pin
&
-
8/15/2019 MP LAB FOR BME.docx
66/103
/tore control word in control register
9nput to be read rom port &
/tore into accumulator
/*;$
/*&%*
/end the contents o &ccumulator to memor(
/tore control word in control register
9nput to be read rom port &
/tore into accumulator
/*;$
/*&%*
;utput written on port B
FLO3C2ART
M'( 0
Tra$s"#&&(r R(,(#9(r
C$&rl 3r': / IO M'(
Obs(r9a$:
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
67/103
-
8/15/2019 MP LAB FOR BME.docx
68/103
MODE 0 G Tra$s"#&&(r
PRORAM COMMENTS
M;= &L,00G /et the control word
;8* C),&L /end it to control port
9< &L,C 5et the contents o port & in &L
;8* C2,&L /end the contents o &ccumulator to port B
GL* /top
MODE 0 G R(,(#9(r
PRORAM COMMENTS
M;= &L,02G /et the control word to initiali'e $ort B as input port
;8* 2),&L /end it to control port
9< &L,22G 5et the contents o port & in &L
M;= J12K,&L /end the contents o &ccumulator to memor(
GL* /top
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
69/103
RESLT:
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
70/103
/*&%*
/end the start conversion pulse
%ead the digital output
/tore the digital value in the memor( location speciied
9/ :;C 1N
/*;$
-
8/15/2019 MP LAB FOR BME.docx
71/103
E-. N 1;a INTERFACIN ANALO TO DIITAL CON=ERTER
AIM:
*o write an assembl( language program to convert an analog signal into a digital signalusing an &+C interace.
T2EORY:
&n &+C usuall( has two additional control linesA the /;C input to tell the &+C when tostart the conversion and the :;C output to announce when the conversion is complete. *heollowing program initiates the conversion process, checks the :;C pin o &+C 0 as to
whether the conversion is over and then inputs the data to the processor. 9t also instructs the processor to store the converted digital data at %&M location.
ALORIT2M:
/tep 1A /tart the program
/tep 2A /elect the channel and latch the address.
/tep 3A /end the start conversion pulse.
/tep !A %ead :;C signal./tep #A 9 :;C e6ual to 1, continue else go to step !
/tep )A %ead the digital output./tep A /tore it in a memor( location./tep A /top the program
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
72/103
-
8/15/2019 MP LAB FOR BME.docx
73/103
I$&(r+a,#$! D#a!ra"
M'(l ra)*:
Obs(r9a$:
S#!$al A")l#&u'( Fr(u($,y T#"( P(r#' 4"s
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
74/103
E-. N. 1;b INTERFACIN DIITAL G TO G ANALO CON=ERTER
AIM :
*o write an assembl( language program or digital to analog conversion and to convertdigital inputs into analog outputs W to generate dierent waveorms
T2EORY:
/ince +&C is an bit +&C and the output voltage variation is between X#v and
H#v. *he output voltage varies in steps o 12#) .! Eapproimatel(F. *he digital data input
and the corresponding output voltages are presented in the table. *he basic idea behind the
generation o waveorms is the continuous generation o analog output o +&C. 4ith EGeF
as input to +&C2 the analog output is X#v. /imilarl( with "" G as input, the output is H#v.
;utputting digital data and "" at regular intervals, to +&C2, results in a s6uare wave o
amplitude #v.;utput digital data rom to "" in constant steps o 1 to +&C2. %epeat this
se6uence again and again. &s a result a saw-tooth wave will be generated at +&C2 output.;utput digital data rom to "" in constant steps o 1 to +&C2. ;utput digital data rom ""
to in constant steps o 1 to +&C2. %epeat this se6uence again and again. &s a result a
triangular wave will be generated at +&C2 output.
ALORIT2M:
3a9(+r" !($(ra$:
/6uare 4aveormA/tep 1A /tart the program/tep 2A /end low value EF to the +&C.
/tep 3A 9ntroduce suitable dela(./tep !A /end high value to +&C./tep #A 9ntroduce dela(./tep )A %epeat steps 2 to #
/aw-tooth waveormA/tep 1A /tart the program/tep 2A Load low value EF to accumulator./tep 3A /end this value to +&C./tep !A 9ncrement the accumulator./tep #A %epeat step 3 and ! until accumulator value reaches "".
/tep )A %epeat rom step 1 to get continuous waveorm
*riangular waveormA/tep 1A /tart the program/tep 2A Load the low value EF in accumulator./tep 3A /end this accumulator content to +&C./tep !A 9ncrement the accumulator./tep #A %epeat step 3 and ! until the accumulator reaches ""/tep )A +ecrement the accumulator/tep A /end the accumulator contents to +&C./tep A %epeat steps ) and until accumulator reaches
/tep 0A %epeat steps 1 to to get continuous waveorm
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
75/103
RESLT:
Suar( 3a9( ($(ra$
LABEL MNEMONICS COMMENTS
L2 A M;= &L,G Load in accumulator ;8* CG,&L /end through output port
C&LL +ela( Call dela( program
M;= &L,""G Load "" in accumulator
;8* CG,&L /end through output port
C&LL +ela( Call dela( program
M$ L2 5o to starting location
+ela( %outine
+ela( A M;= C,#""G Load count value in C register L3 A L;;$ L3 +ecrement until it reaches 'ero
%:* %eturn to main program
Ps#( Sa &&* 3a9(
LABEL MNEMONICS COMMENTS
L2 A M;= &L,G Load in accumulator
L1 A ;8* CG,&L /end through output port
9
-
8/15/2019 MP LAB FOR BME.docx
76/103
Tr#a$!ular 3a9(
LABEL MNEMONICS COMMENTS
L3 A M;= &L,G Load in accumulator
L1 A ;8* CG,&L /end through output port
9
-
8/15/2019 MP LAB FOR BME.docx
77/103
ARC2ITECTRE OF 8051 MICROCONTROLLER
*he unctions o each o these components are as ollowsA
1. AL
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
78/103
• &ll arithmetic and logical unctions are carried out b( the &L8.
• &ddition, subtraction with carr(, and multiplication come under arithmetic operations.
Logical &
-
8/15/2019 MP LAB FOR BME.docx
79/103
!. %/*A %eset.
>uart' cr(stal is used to generate periodic clock pulses.
5. I$&(r$al RAM a$' ROMROM
& code o ! memor( is incorporated as on-chip %;M in #1. *he #1 %;M is a non-
volatile memor( meaning that its contents cannot be altered and hence has a similar range o
data and program memor(, i.e, the( can address program memor( as well as a )! separate
block o data memor(.
RAM
*he #1 microcontroller is composed o 12 b(tes o internal %&M. *his is a volatile
memor( since its contents will be lost i power is switched o. *hese 12 b(tes o internal
%&M are divided into 32 working registers which in turn constitute ! register banks EBank -
Bank 3F with each bank consisting o registers E% - %F. *here are 12 addressable bits in
the internal %&M.
6. Fur ($(ral Pur)s( Parall(l I$)u&Ou&)u& Pr&s
*he #1 microcontroller has our -bit inputoutput ports. *hese areA
PORT P0: 4hen there is no eternal memor( present, this port acts as a general purposeinputoutput port. 9n the presence o eternal memor(, it unctions as a multipleed address anddata bus. 9t perorms a dual role.
PORT P1: *his port is used or various interacing activities. *his -bit port is a normal 9; port i.e. it does not perorm dual unctions.
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
80/103
PORT P
-
8/15/2019 MP LAB FOR BME.docx
81/103
*here are ! programmable modes in serial data communication. *he( areA
1. /erial +ata mode Eshit register modeF2. /erial +ata mode 1 Estandard 8&%*F
3. /erial +ata mode 2 Emultiprocessor modeF!. /erial +ata mode 3
. PS3 4Pr!ra" S&a&us 3r'
$rogram /tatus 4ord or $/4 is a hardware register which is a memor( location which holds a programOs inormation and also monitors the status o the program this is currentl( beingeecuted. $/4 also has a pointer which points towards the address o the net instruction to beeecuted. $/4 register has 3 ields namel( are instruction address ield, condition code ieldand error status ield. 4e can sa( that $/4 is an internal register that keeps track o thecomputer at ever( instant.
5enerall(, the instruction o the result o a program is stored in a single bit register called aOlagO. *he are lags in the $/4 o #1. &mong these lags, ! are math lags and 3 aregeneral purpose or user lags.
*he ! Math lags areA
[ Carr( EcF
[ &uiliar( carr( E&CF
[ ;verlow E;=F
[ $arit( E$F
*he 3 5eneral purpose lags or 8ser lags areA
[ ";
[ 5";
[ 5" 1
10. Da&a P#$&(r 4DPTR
*he data pointer or +$*% is a 1)-bit register. 9t is made up o two -bit registers called +$G
and +$L. /eparate addresses are assigned to each o +$G and +$L. *hese -bit registers are
used or the storing the memor( addresses that can be used to access internal and eternal
datacode.
11. S&a,% P#$&(r 4SP
*he stack pointer E/$F in #1 is an -bit register. *he main purpose o /$ is to access the
stack. &s it has -bits it can take values in the range G to "" G. /tack is a special area o
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
82/103
data in memor(. *he /$ acts as a pointer or an address that point to the top o the stack.
1
-
8/15/2019 MP LAB FOR BME.docx
83/103
$%;5%&MM9
-
8/15/2019 MP LAB FOR BME.docx
84/103
FLO3C2ART
ADDITION SBTRACTION
MLTIPLICATION DI=ISION
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
85/103
E-. N. 1>a BASIC ARIT2METIC OPERATIONS
AIM:
*o write an assembl( language program to perorm basic &rithmetic operations and storethe result in memor( using #1 microcontroller kit.
ALORIT2M:
4a 8 b#& A''#$
/tep1A /tart the program/tep 2A Load & register with irst data/tep 3A &dd the second data with irst data./tep !A /tore the result./tep#A /top the program.
4b 8 b#& Sub&ra,$
/tep1A /tart the program/tep 2A Clear carr( lag/tep 3A Load & register with irst data/tep !A subtract the second data with irst data./tep #A /tore the result./tep )A /top the program.
4, 8 b#& Mul)l#,a$
/tep1A /tart the program/tep 2A 5et the multiplier in the accumulator /tep 3A 5et the multiplicand in the B register /tep !A Multipl( & with B/tep #A /tore the product in memor(/tep )A /top the program
4' 8 b#& D#9#s#$
/tep1A /tart the program/tep 2A 5et the +ividend in the accumulator /tep 3A 5et the +ivisor in the B register /tep !A +ivide & b( B./tep #A /tore the >uotient and %emainder in memor(/tep )A /top the program
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
86/103
4a 8 B#& A''#$
A''r(ss Lab(l M$("$#,s C""($&s
CL% C Clear CI "lagM;= &,# data1 5et the data1 in &ccumulator
&++C &, T data 2 &dd the data2 with data1
M;= +$*%, T !#G 9nitiali'e the memor( location
M;= \ +$*%, & /tore the result in memor( location
L1A /M$ L1 /top the program
4b 8 B#& Sub&ra,$
A''r(ss Lab(l M$("$#,s C""($&s
CL% C Clear CI "lag
M;= &,# data1 5et the data1 in &ccumulator /8BB &, T data 2 subtract data2 rom data1
M;= +$*%, T !#G 9nitiali'e the memor( location
M;= \ +$*%, & /tore the result in memor( location
L1A /M$ L1 /top the program
4, 8 B#& Mul)l#,a$
A''r(ss Lab(l M$("$#,s C""($&s
CL% C Clear CI "lag
M;= &,# data1 5et the data1 in &ccumulator M;= B,# data2 5et the data2 in B register
M8L &B multipl( data2 with data1
M;= +$*%, T !#G 9nitiali'e the memor( location
M;= \ +$*%, & /tore the result in memor( location
9
-
8/15/2019 MP LAB FOR BME.docx
87/103
L1A /M$ L1 /top the program
Obs(r9a$:
O)(ra$ M("ry L,a$ Da&a I$)u& Ou&)u&
A''#$
Sub&ra,$
Mul)l#,a$
D#9#s#$
RESLT:
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
88/103
/*&%*
5et the irst data
5et the second data
&
-
8/15/2019 MP LAB FOR BME.docx
89/103
-
8/15/2019 MP LAB FOR BME.docx
90/103
/*&%*
5et the irst data
5et the second data
&
-
8/15/2019 MP LAB FOR BME.docx
91/103
4aAND )(ra$
A''r(ss Lab(l M$("$#,s C""($&s
M;= +$*%, T !#G 9nitiali'e the memor( locationM;= &, \+$*% 5et the data in &ccumulator
M;= B, & Complement &
9
-
8/15/2019 MP LAB FOR BME.docx
92/103
/*&%*
5et the data
"ind cube o data
/tore the result
/*;$
/*&%*
5et the data
"ind s6uare o data
/tore the result
/*;$
/*&%*
5et the data
"ind 17s complement
&dd 1 to the result
/tore the result
/*;$
O)(ra$ M("ry L,a$ Da&a C""($&s
AND
OR
XOR
4a Suar( + a Nu"b(r 4b Cub( + a $u"b(r
-
8/15/2019 MP LAB FOR BME.docx
93/103
O)(ra$ M("ry L,a$ Da&a I$)u& Ou&)u&
Suar( +
$u"b(r
Cub( + $u"b(r
-
8/15/2019 MP LAB FOR BME.docx
94/103
-
8/15/2019 MP LAB FOR BME.docx
95/103
LABEL PRORAM COMMENTS
M;= +$*%, T !#G 9nitiali'e the memor( location
M;= %,T"h 5et the data in % to ind the cube o it
M;= &,% Cop( data to %
M;= B,% Cop( data to B register M8L &B Multipl( contents o & and B register
M;= %1,B /tore partial product in %1
M;= B,% Move data to B register
M8L &B Multipl( contents o & and B register
M;= \+$*%,& Move result to memor(
9
-
8/15/2019 MP LAB FOR BME.docx
96/103
/*&%*
5et the data
;% 3G with & register to make it &/C99
/tore the result
/*;$
Obs(r9a$:
O)(ra$ M("ry L,a$ Da&a I$)u& Ou&)u&
$)a,%(' BCD
& ASCII
E-. N. 16 NPAC?ED BCD TO ASCII
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
97/103
-
8/15/2019 MP LAB FOR BME.docx
98/103
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
99/103
=#9a 7u(s$s1. 4hat is microprocessorN2. 4hat are the lags in )N3. List the dierent t(pes o registers in ) microprocessor arch!. 4hat is operating re6uenc( o ) W #N
#. :plain basic dierence between ) W .). 4hat do (ou mean b( assemblerN. 4hat do (ou mean b( linkerN. 4hat do (ou mean b( loaderN0. 4hat do (ou mean b( compilerN1. 4hat do (ou mean b( machine c(cleN11. Gow does ) dierentiated between an opcode and instruction dataN12. 4hat is use o timing and control unitN13. 4hat is maimum memor( addressing and 9; addressing capabilit( o )N1!. "rom which address )-start eecution ater reset.1#. 4hat is use o maimum mode in )N1). 4hat is use o 2! 9CN
1. 4hat is L;C preiN 4hat is its useN1. 4hat is %:$ preiN 4hat is its useN10. Gow does C$8 identi( between -bit and 1)-bit operationsN2. 4hat is the dierence between the Dump and loop instructionsN21. 4hich instruction o ) can be used or look up table manipulationsN22. 4hat is dierence between the respective shits and rotate instructionsN23. Gow will (ou enter the single step mode o )N2!. 4hat determines whether the microprocessor is an -bit, 1)-bit or 32-bit microprocessorN2#. 4hat is the si'e o )-address busN2). 4hat do (ou mean b( pipeliningN2. 4h( instruction 6ueue o ) o )-b(te longN2. 4hat are the uses o lagsN
20. 4hat is wrong with a M;= JBK, J+9K instructionN3. 4hat is wrong with a M;= &, +L instructionN31. 4hat do (ou understand b( machine languageN32. +ierentiate between direct and displacement addressing modesN33. Calculate the memor( address the ollowing instructions will access. &lso eplain the
addressing modes that are used b( each instruction.a. M;= C, J123!GK
b. M;= &, J2222GKc. M;= +, JB$Kd. M;= +, JB$H+9Ke. M;= +, JB$ H /9 H 2GK. M;= +, JB$ H +9 H 1GKg. M;= &, 123!G
3!. 4hat is the dierence between assembl( and high-level languagesN3#. 4hat is the unction o &+1# X &+N N3). 4hat is the unction o %:/:* pinN3. 4hat is the unction o M
-
8/15/2019 MP LAB FOR BME.docx
100/103
!). Gow +" 1 worksN!. Gow +" worksN!. 4hat is the dierence between L+/ and L:/N!0. 4hat is the dierence between L&G" and /&G"N#. 4hat is the operation o the L:& instructionN#1. :plain the direction lag and its use in string data transer instruction#2. 4hat are the dierences between L;+/B, L;+/4, /*;/B, and /*;/4N#3. 4hat are the dierences between L&G" instruction and $;$ lag reg. 9nstructionN#!. 4hat is &ssembl( languageN##. 4hat is the unction o +*%N#). Gow is the ) data address bus demultipleedN#. 4hat is a bus c(cleN#. 4hat is the unction o +:
-
8/15/2019 MP LAB FOR BME.docx
101/103
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
102/103
APPENDIX
BM)#11 Microprocessor and Microcontroller Lab +ept. o BM:
-
8/15/2019 MP LAB FOR BME.docx
103/103