SlideShare a Scribd company logo
1 of 18
Basic Experiments
(Using ALP code)
Data Movement
a) Move a block of data within internal RAM
8051 ALP code
ORG 00H
MOV R1,#50H
MOV RO,#60H
MOV R3,#0AH
LOOP:MOV A,@R1
MOV @R0,A
INC R1
INC R0
DJNZ R3,LOOP
HERE:SJMP HERE
END
Result : Enter 10 numbers in the memory location d:0x59.Run
the program and see the result in memory location d:0x60 to
0x69
Sample Run:
Before execution: d:0x50 = 45 25 60 25 60 55 44 12 41 58
After execution : d:0x60 = 45 25 60 25 60 55 44 12 41 58
b) Exchange a block of data between internal RAM and
External memory
8051 ALP code
ORG 00H
MOV R0,#50H //SOURCE ADDRESS
MOV DPTR,#0150H //DESTINATION ADDRESS
MOV R3,#05H //COUNT
BACK:MOV A,@R0
MOV R2,A
MOVX A,@DPTR
MOV @R0,A
XCH A,R2
MOVX @DPTR,A
INC R0
INC DPTR
DJNZ R3,BACK
HERE:SJMP HERE
END
Sample Run:
Before execution: d:0x50 = 45 58 52 92 25
After execution : x:0x0150 = 45 58 52 92 25
Arithmetic Operation :
a)Evaluatesimple arithmetic expression such as y=((5*2)-(4-1))/3)%2
8051 ALP code
ORG 00H
MOV A,#4
MOV R1,#1
ADD A,R1
MOV R1,A
MOV B,#05H
MOV A,#02H
MUL AB
SUBB A,R1
MOV B,#03H
DIV AB
MOV 30H,A
HERE:SJMP HERE
END
Sample Run:
Before execution: d:0x30 = 00
After execution : d:0x30 = 01
b)Additionof three 8-bit BCD numbers and obtainresult in BCD form
8051 ALP code
ORG 00H
START:MOV R0,#02H
MOV R2,#00H
MOV R1,#50H
MOV A,@R1
INC R1
UP : ADD A,@R1
DA A
JNC NEXT
INC R2
NEXT : INC R1
DJNZ R0,UP
MOV O3H,A
HERE:SJMP HERE
END
Sample Run:
Before execution: d:0x50 = 05 06 04
After execution : d:0x02 = 00 15
Logical Operation :
a)Evaluate logical expression Y=a&&b||c^!d where a,b,c and d
are 8-bit data
8051 ALP code
ORG 00H
MOV R0,40H
MOV A,41H
ANL A,R0
MOV B,A
MOV R0,42H
MOV A,43H
CPL A
XRL A,R0
ORL A,B
MOV 44H,A
HERE:SJMP HERE
END
Sample Run:
Before execution: d:0x40 = 45 56 14 85
After execution : d:0x44 = 6E
b)Rotation or Shift operation on 16 bit data
8051 ALP code
ORG 00H
CLR C
MOV A,41H
RLC A
MOV B,A
MOV A,40H
RLC A
MOV 40H,A
MOV A,B
MOV ACC.0,C
MOV 41H,A
HERE:SJMP HERE
END
Sample Run:
Before execution: d:0x40 = 45 56
After execution : d:0x44 = 8A A C
Code Conversions :
a)(1)Two digit packed BCD to unpacked BCD
8051 ALP code
ORG 00H
MOV A,40H
MOV B,A
ANL A,#0F0H
SWAP A
MOV 41H,A
MOV A,B
ANL A,#0FH
MOV 42H,A
HERE:SJMP HERE
END
Sample Run:
Before execution: d:0x40 = 32
After execution : d:0x41 = 03 02
a)(2)Two digit unpacked BCD to packed BCD
8051 ALP code
ORG 00H
MOV A,40H
SAWP A
ORL A,41H
MOV 42H,A
HERE:SJMP HERE
END
Sample Run:
Before execution: d:0x40 = 03 02
After execution : d:0x44 = 32
b)(1) BCD to Binary Conversion
8051 ALP code
ORG 00H
MOV DPTR,#40H
MOVX A,@DPTR
ANL A,#0F0H
SWAP A
MOV B,#0AH
MUL AB
MOV R1,A
MOVX A,@DPTR
ANL A,0FH
ADD A,R1
INC DPTR
MOVX @DPTR,A
HERE:SJMP HERE
END
Sample Run:
Before execution: X:0x0040 = 45(Decimal/BCD)
After execution : X:0x0041 = 2D(Hex/Binary value)
b)(2) Binary to BCD Conversion
8051 ALP code
ORG 00H
MOV DPTR,#9000H
MOVX A,@DPTR
MOV B,#10
DIV AB
INC DPTR
XCH A,B
MOVX @DPTR,A
XCH A,B
MOV B,#10
DIV AB
INC DPTR
MOVX A,@DPTR
HERE:SJMP HERE
END
Sample Run:
Before execution: X:0x9000 = FF(Hex/Binary value)
After execution : X:0x9001 = 05(BCD Value)lower digit first
X:0x9002H = 05(BCD Value)
X:0x9002H = 02(BCD Value)Higher digit first
c)(1) Two digit packed BCD to ASCII
8051 ALP code
ORG 00H
MOV R1,#50H
MOV A,@R1
MOV R2,A
SWAP A
ANL A,#OFH
ORL A,#30H
INC R1
MOV @R1,A
MOV A,R2
ANL A,#0FH
ORL A,#30H
INC R1
MOV @R1,A
HERE:SJMP HERE
END
Sample Run:
Before execution: d:0x50 = 48
After execution : d:0x51 = 34 38
b)(2) Binary to BCD Conversion
8051 ALP code
ORG 00H
CLR C
MOV A,40H
SUBB A,#30H
SWAP A
MOV B,A
CLR C
MOV A,41H
SUBB A,#30H
ADD A,B
MOV 42H,A
HERE:SJMP HERE
END
Sample Run:
Before execution: d:0x40 = 34 38
After execution : d:0x42 = 48
Program to search a given 8bit number in an array of N numbers.
8051 ALP code
ORG 00H
MOV R0,#40H
MOV R1,#0AH
MOV A,#76H
BACK:MOV B,@RO
CJNE A,B,NEXT
MOV A,OFFH
SJMP LAST
NEXT:INC R0
DJNZ R1,BACK
MOV A,#0AAH
LAST:MOV 78H,B
HERE:SJMP HERE
END
Sample Run:
Before execution: d:0x40 = 45 58 39 45 89 45 22 69 76 33
Reg B = 76
After execution : d:0x78 = FF
a)To sort an array of an 6 byte of data in ascending order.
8051 ALP code
ORG 00H
MOV R0,#50
L1:MOV DPTR,#9000H
MOV A,R0
MOV R1,A
L2:MOVX A,@DPTR
MOV B,A
INC DPTR
MOVX A,@DPTR
CLR C
MOV R2,A
SUBB A,B
JNC NOEXCHG
MOV A,B
MOVX @DPTR,A
DEC DPL
MOV A,R2
MOVX @DPTR,A
INC DPTR
NOEXCHG:DJNZ R1,L2 Sample Run:
DJNZ RO,L1 Before execution:X:0x9000 = 45 58 39 45 89 95
HERE:SJMP HERE After execution :X:0x9000 = 39 45 45 58 89 95
END
a)To sort an array of an 6 byte of data in descending order.
8051 ALP code
ORG 00H
MOV R0,#50
L1:MOV DPTR,#9000H
MOV A,R0
MOV R1,A
L2:MOVX A,@DPTR
MOV B,A
INC DPTR
MOVX A,@DPTR
CLR C
MOV R2,A
SUBB A,B
JC NOEXCHG
MOV A,B
MOVX @DPTR,A
DEC DPL
MOV A,R0
MOVX @DPTR,A
INC DPTR
NOEXCHG:DJNZ R1,L2 Sample Run:
DJNZ RO,L1 Before execution:X:0x9000 = 45 58 39 45 89 95
HERE:SJMP HERE After execution :X:0x9000 = 95 89 58 45 45 39
END
Program to count the number of ones and zeros in the data
saved in two consecutive memory location.
8051 ALP code
ORG 00H
MOV R0,#00H
MOV R1,#00H
MOV R2,#08H
MOV A,#0F0H
LOOP3:CLR C
RLC A
JC LOOP1
INC R0
SJMP LOOP2
LOOP1:INC R1
LOOP2:DJNZ R2,LOOP3
HERE:SJMP HERE
END
Sample Run:
Input for execution : Ri = OFOH
Output of execution : R0 = 04
R1 = 04
Program to toggle a particular bit in the internal RAM with the
delay of N ms given the clock frequency f MHz with the use of
delay subroutine.
8051 ALP code
ORG 00H
AGAIN:
SETB P1.2
ACALL DELAY
CLR P1.2
ACALL DELAY
SJMP AGAIN
DELAY:MOV TMOD,#10H
MOV TL1,#0B0H
MOV TH1,3CH
SETB TR1
BACK:
JNB TF1,BACK
CLR TR1
CLR TF1
RET
END
Result : Run the program and observe the toggling of P1.2 bit.

More Related Content

What's hot

implementation of data instrucions in emu8086
implementation of data instrucions in emu8086implementation of data instrucions in emu8086
implementation of data instrucions in emu8086COMSATS Abbottabad
 
Aeav 301 lec 19
Aeav 301 lec 19Aeav 301 lec 19
Aeav 301 lec 190mehdi
 
Intel codetable
Intel codetableIntel codetable
Intel codetableJ R7
 
Lathe Spindle Sensor
Lathe Spindle SensorLathe Spindle Sensor
Lathe Spindle SensorJoeCritt
 
8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set
8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set
8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction setSaumitra Rukmangad
 
Understanding Tomasulo Algorithm
Understanding Tomasulo AlgorithmUnderstanding Tomasulo Algorithm
Understanding Tomasulo Algorithmonesuper
 
NetBeez - What's the ARP cache
NetBeez - What's the ARP cacheNetBeez - What's the ARP cache
NetBeez - What's the ARP cacheNetBeez, Inc.
 
Device Modeling of RSQB Flip Flop using PSpice
Device Modeling of RSQB Flip Flop using PSpiceDevice Modeling of RSQB Flip Flop using PSpice
Device Modeling of RSQB Flip Flop using PSpiceTsuyoshi Horigome
 
Instruction Set 8085
Instruction Set 8085Instruction Set 8085
Instruction Set 8085Stupidsid.com
 
INTEL 8085 DATA FORMAT AND INSTRUCTIONS
INTEL 8085 DATA FORMAT AND INSTRUCTIONSINTEL 8085 DATA FORMAT AND INSTRUCTIONS
INTEL 8085 DATA FORMAT AND INSTRUCTIONSSwapnil Mishra
 

What's hot (18)

8085 instruction-set
8085 instruction-set8085 instruction-set
8085 instruction-set
 
8085 instruction-set
8085 instruction-set8085 instruction-set
8085 instruction-set
 
implementation of data instrucions in emu8086
implementation of data instrucions in emu8086implementation of data instrucions in emu8086
implementation of data instrucions in emu8086
 
mup
mupmup
mup
 
Aeav 301 lec 19
Aeav 301 lec 19Aeav 301 lec 19
Aeav 301 lec 19
 
Intel codetable
Intel codetableIntel codetable
Intel codetable
 
Adc(pic)
Adc(pic)Adc(pic)
Adc(pic)
 
Code 8051
Code 8051Code 8051
Code 8051
 
Introduction to 8085 by adi ppt
Introduction to 8085 by adi pptIntroduction to 8085 by adi ppt
Introduction to 8085 by adi ppt
 
Lathe Spindle Sensor
Lathe Spindle SensorLathe Spindle Sensor
Lathe Spindle Sensor
 
Boolean and comparison_instructions
Boolean and comparison_instructionsBoolean and comparison_instructions
Boolean and comparison_instructions
 
8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set
8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set
8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set
 
Shift rotate
Shift rotateShift rotate
Shift rotate
 
Understanding Tomasulo Algorithm
Understanding Tomasulo AlgorithmUnderstanding Tomasulo Algorithm
Understanding Tomasulo Algorithm
 
NetBeez - What's the ARP cache
NetBeez - What's the ARP cacheNetBeez - What's the ARP cache
NetBeez - What's the ARP cache
 
Device Modeling of RSQB Flip Flop using PSpice
Device Modeling of RSQB Flip Flop using PSpiceDevice Modeling of RSQB Flip Flop using PSpice
Device Modeling of RSQB Flip Flop using PSpice
 
Instruction Set 8085
Instruction Set 8085Instruction Set 8085
Instruction Set 8085
 
INTEL 8085 DATA FORMAT AND INSTRUCTIONS
INTEL 8085 DATA FORMAT AND INSTRUCTIONSINTEL 8085 DATA FORMAT AND INSTRUCTIONS
INTEL 8085 DATA FORMAT AND INSTRUCTIONS
 

Similar to Maicrocontroller lab basic experiments

Microcontroller 8051- soft.ppt
Microcontroller 8051- soft.pptMicrocontroller 8051- soft.ppt
Microcontroller 8051- soft.pptsteffydean
 
Buy Embedded Systems Projects Online,Buy B tech Projects Online
Buy Embedded Systems Projects Online,Buy B tech Projects OnlineBuy Embedded Systems Projects Online,Buy B tech Projects Online
Buy Embedded Systems Projects Online,Buy B tech Projects OnlineTechnogroovy
 
Programs using Microcontrollers.ppt
Programs using Microcontrollers.pptPrograms using Microcontrollers.ppt
Programs using Microcontrollers.pptSasiBhushan22
 
Microcontroller 8051 soft
Microcontroller 8051  softMicrocontroller 8051  soft
Microcontroller 8051 softbaluusa8
 
Https _doc-0o-c4-apps-viewer.googleusercontent
Https  _doc-0o-c4-apps-viewer.googleusercontent Https  _doc-0o-c4-apps-viewer.googleusercontent
Https _doc-0o-c4-apps-viewer.googleusercontent vijaydeepakg
 
Microprocessor system - summarize
Microprocessor system - summarizeMicroprocessor system - summarize
Microprocessor system - summarizeHisham Mat Hussin
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontrollerjokersclown57
 
8085 paper-presentation
8085 paper-presentation8085 paper-presentation
8085 paper-presentationJiMs ChAcko
 
Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051logesh waran
 
Microprocessor Part 3
Microprocessor    Part  3Microprocessor    Part  3
Microprocessor Part 3Sajan Agrawal
 
microp-8085 74 instructions for mct-A :P
microp-8085 74 instructions for mct-A :Pmicrop-8085 74 instructions for mct-A :P
microp-8085 74 instructions for mct-A :PJathin Kanumuri
 
microp-8085 74 instructions for mct-A :P-2
microp-8085 74 instructions for mct-A :P-2microp-8085 74 instructions for mct-A :P-2
microp-8085 74 instructions for mct-A :P-2Jathin Kanumuri
 
New text document
New text documentNew text document
New text documentzocaniveb
 

Similar to Maicrocontroller lab basic experiments (20)

Microcontroller 8051- soft.ppt
Microcontroller 8051- soft.pptMicrocontroller 8051- soft.ppt
Microcontroller 8051- soft.ppt
 
Buy Embedded Systems Projects Online,Buy B tech Projects Online
Buy Embedded Systems Projects Online,Buy B tech Projects OnlineBuy Embedded Systems Projects Online,Buy B tech Projects Online
Buy Embedded Systems Projects Online,Buy B tech Projects Online
 
Programs using Microcontrollers.ppt
Programs using Microcontrollers.pptPrograms using Microcontrollers.ppt
Programs using Microcontrollers.ppt
 
Microcontroller 8051 soft
Microcontroller 8051  softMicrocontroller 8051  soft
Microcontroller 8051 soft
 
Https _doc-0o-c4-apps-viewer.googleusercontent
Https  _doc-0o-c4-apps-viewer.googleusercontent Https  _doc-0o-c4-apps-viewer.googleusercontent
Https _doc-0o-c4-apps-viewer.googleusercontent
 
Microprocessor system - summarize
Microprocessor system - summarizeMicroprocessor system - summarize
Microprocessor system - summarize
 
Micro task1
Micro task1Micro task1
Micro task1
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
 
8085 paper-presentation
8085 paper-presentation8085 paper-presentation
8085 paper-presentation
 
Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051
 
Microprocessor Part 3
Microprocessor    Part  3Microprocessor    Part  3
Microprocessor Part 3
 
microp-8085 74 instructions for mct-A :P
microp-8085 74 instructions for mct-A :Pmicrop-8085 74 instructions for mct-A :P
microp-8085 74 instructions for mct-A :P
 
microp-8085 74 instructions for mct-A :P-2
microp-8085 74 instructions for mct-A :P-2microp-8085 74 instructions for mct-A :P-2
microp-8085 74 instructions for mct-A :P-2
 
3 jump, loop and call instructions
3 jump, loop and call instructions3 jump, loop and call instructions
3 jump, loop and call instructions
 
New text document
New text documentNew text document
New text document
 
8085 Architecture
8085 Architecture8085 Architecture
8085 Architecture
 
6 arithmetic logic inst and prog
6 arithmetic logic inst and prog6 arithmetic logic inst and prog
6 arithmetic logic inst and prog
 
Real Time Embedded System
Real Time Embedded SystemReal Time Embedded System
Real Time Embedded System
 
8085 micro processor
8085 micro processor8085 micro processor
8085 micro processor
 

Recently uploaded

How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 

Recently uploaded (20)

Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 

Maicrocontroller lab basic experiments

  • 2. Data Movement a) Move a block of data within internal RAM 8051 ALP code ORG 00H MOV R1,#50H MOV RO,#60H MOV R3,#0AH LOOP:MOV A,@R1 MOV @R0,A INC R1 INC R0 DJNZ R3,LOOP HERE:SJMP HERE END Result : Enter 10 numbers in the memory location d:0x59.Run the program and see the result in memory location d:0x60 to 0x69 Sample Run: Before execution: d:0x50 = 45 25 60 25 60 55 44 12 41 58 After execution : d:0x60 = 45 25 60 25 60 55 44 12 41 58
  • 3. b) Exchange a block of data between internal RAM and External memory 8051 ALP code ORG 00H MOV R0,#50H //SOURCE ADDRESS MOV DPTR,#0150H //DESTINATION ADDRESS MOV R3,#05H //COUNT BACK:MOV A,@R0 MOV R2,A MOVX A,@DPTR MOV @R0,A XCH A,R2 MOVX @DPTR,A INC R0 INC DPTR DJNZ R3,BACK HERE:SJMP HERE END Sample Run: Before execution: d:0x50 = 45 58 52 92 25 After execution : x:0x0150 = 45 58 52 92 25
  • 4. Arithmetic Operation : a)Evaluatesimple arithmetic expression such as y=((5*2)-(4-1))/3)%2 8051 ALP code ORG 00H MOV A,#4 MOV R1,#1 ADD A,R1 MOV R1,A MOV B,#05H MOV A,#02H MUL AB SUBB A,R1 MOV B,#03H DIV AB MOV 30H,A HERE:SJMP HERE END Sample Run: Before execution: d:0x30 = 00 After execution : d:0x30 = 01
  • 5. b)Additionof three 8-bit BCD numbers and obtainresult in BCD form 8051 ALP code ORG 00H START:MOV R0,#02H MOV R2,#00H MOV R1,#50H MOV A,@R1 INC R1 UP : ADD A,@R1 DA A JNC NEXT INC R2 NEXT : INC R1 DJNZ R0,UP MOV O3H,A HERE:SJMP HERE END Sample Run: Before execution: d:0x50 = 05 06 04 After execution : d:0x02 = 00 15
  • 6. Logical Operation : a)Evaluate logical expression Y=a&&b||c^!d where a,b,c and d are 8-bit data 8051 ALP code ORG 00H MOV R0,40H MOV A,41H ANL A,R0 MOV B,A MOV R0,42H MOV A,43H CPL A XRL A,R0 ORL A,B MOV 44H,A HERE:SJMP HERE END Sample Run: Before execution: d:0x40 = 45 56 14 85 After execution : d:0x44 = 6E
  • 7. b)Rotation or Shift operation on 16 bit data 8051 ALP code ORG 00H CLR C MOV A,41H RLC A MOV B,A MOV A,40H RLC A MOV 40H,A MOV A,B MOV ACC.0,C MOV 41H,A HERE:SJMP HERE END Sample Run: Before execution: d:0x40 = 45 56 After execution : d:0x44 = 8A A C
  • 8. Code Conversions : a)(1)Two digit packed BCD to unpacked BCD 8051 ALP code ORG 00H MOV A,40H MOV B,A ANL A,#0F0H SWAP A MOV 41H,A MOV A,B ANL A,#0FH MOV 42H,A HERE:SJMP HERE END Sample Run: Before execution: d:0x40 = 32 After execution : d:0x41 = 03 02
  • 9. a)(2)Two digit unpacked BCD to packed BCD 8051 ALP code ORG 00H MOV A,40H SAWP A ORL A,41H MOV 42H,A HERE:SJMP HERE END Sample Run: Before execution: d:0x40 = 03 02 After execution : d:0x44 = 32
  • 10. b)(1) BCD to Binary Conversion 8051 ALP code ORG 00H MOV DPTR,#40H MOVX A,@DPTR ANL A,#0F0H SWAP A MOV B,#0AH MUL AB MOV R1,A MOVX A,@DPTR ANL A,0FH ADD A,R1 INC DPTR MOVX @DPTR,A HERE:SJMP HERE END Sample Run: Before execution: X:0x0040 = 45(Decimal/BCD) After execution : X:0x0041 = 2D(Hex/Binary value)
  • 11. b)(2) Binary to BCD Conversion 8051 ALP code ORG 00H MOV DPTR,#9000H MOVX A,@DPTR MOV B,#10 DIV AB INC DPTR XCH A,B MOVX @DPTR,A XCH A,B MOV B,#10 DIV AB INC DPTR MOVX A,@DPTR HERE:SJMP HERE END Sample Run: Before execution: X:0x9000 = FF(Hex/Binary value) After execution : X:0x9001 = 05(BCD Value)lower digit first X:0x9002H = 05(BCD Value) X:0x9002H = 02(BCD Value)Higher digit first
  • 12. c)(1) Two digit packed BCD to ASCII 8051 ALP code ORG 00H MOV R1,#50H MOV A,@R1 MOV R2,A SWAP A ANL A,#OFH ORL A,#30H INC R1 MOV @R1,A MOV A,R2 ANL A,#0FH ORL A,#30H INC R1 MOV @R1,A HERE:SJMP HERE END Sample Run: Before execution: d:0x50 = 48 After execution : d:0x51 = 34 38
  • 13. b)(2) Binary to BCD Conversion 8051 ALP code ORG 00H CLR C MOV A,40H SUBB A,#30H SWAP A MOV B,A CLR C MOV A,41H SUBB A,#30H ADD A,B MOV 42H,A HERE:SJMP HERE END Sample Run: Before execution: d:0x40 = 34 38 After execution : d:0x42 = 48
  • 14. Program to search a given 8bit number in an array of N numbers. 8051 ALP code ORG 00H MOV R0,#40H MOV R1,#0AH MOV A,#76H BACK:MOV B,@RO CJNE A,B,NEXT MOV A,OFFH SJMP LAST NEXT:INC R0 DJNZ R1,BACK MOV A,#0AAH LAST:MOV 78H,B HERE:SJMP HERE END Sample Run: Before execution: d:0x40 = 45 58 39 45 89 45 22 69 76 33 Reg B = 76 After execution : d:0x78 = FF
  • 15. a)To sort an array of an 6 byte of data in ascending order. 8051 ALP code ORG 00H MOV R0,#50 L1:MOV DPTR,#9000H MOV A,R0 MOV R1,A L2:MOVX A,@DPTR MOV B,A INC DPTR MOVX A,@DPTR CLR C MOV R2,A SUBB A,B JNC NOEXCHG MOV A,B MOVX @DPTR,A DEC DPL MOV A,R2 MOVX @DPTR,A INC DPTR NOEXCHG:DJNZ R1,L2 Sample Run: DJNZ RO,L1 Before execution:X:0x9000 = 45 58 39 45 89 95 HERE:SJMP HERE After execution :X:0x9000 = 39 45 45 58 89 95 END
  • 16. a)To sort an array of an 6 byte of data in descending order. 8051 ALP code ORG 00H MOV R0,#50 L1:MOV DPTR,#9000H MOV A,R0 MOV R1,A L2:MOVX A,@DPTR MOV B,A INC DPTR MOVX A,@DPTR CLR C MOV R2,A SUBB A,B JC NOEXCHG MOV A,B MOVX @DPTR,A DEC DPL MOV A,R0 MOVX @DPTR,A INC DPTR NOEXCHG:DJNZ R1,L2 Sample Run: DJNZ RO,L1 Before execution:X:0x9000 = 45 58 39 45 89 95 HERE:SJMP HERE After execution :X:0x9000 = 95 89 58 45 45 39 END
  • 17. Program to count the number of ones and zeros in the data saved in two consecutive memory location. 8051 ALP code ORG 00H MOV R0,#00H MOV R1,#00H MOV R2,#08H MOV A,#0F0H LOOP3:CLR C RLC A JC LOOP1 INC R0 SJMP LOOP2 LOOP1:INC R1 LOOP2:DJNZ R2,LOOP3 HERE:SJMP HERE END Sample Run: Input for execution : Ri = OFOH Output of execution : R0 = 04 R1 = 04
  • 18. Program to toggle a particular bit in the internal RAM with the delay of N ms given the clock frequency f MHz with the use of delay subroutine. 8051 ALP code ORG 00H AGAIN: SETB P1.2 ACALL DELAY CLR P1.2 ACALL DELAY SJMP AGAIN DELAY:MOV TMOD,#10H MOV TL1,#0B0H MOV TH1,3CH SETB TR1 BACK: JNB TF1,BACK CLR TR1 CLR TF1 RET END Result : Run the program and observe the toggling of P1.2 bit.