SlideShare a Scribd company logo
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)Evaluate simple 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)Addition of three 8-bit BCD numbers and obtain result 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

Alp 8051
Alp 8051Alp 8051
8085 instruction-set
8085 instruction-set8085 instruction-set
8085 instruction-set
sudheerkethamreddy
 
8085 instruction-set
8085 instruction-set8085 instruction-set
8085 instruction-set
Muhammadalizardari
 
Microcontroller 8051 soft
Microcontroller 8051  softMicrocontroller 8051  soft
Microcontroller 8051 soft
baluusa8
 
implementation of data instrucions in emu8086
implementation of data instrucions in emu8086implementation of data instrucions in emu8086
implementation of data instrucions in emu8086
COMSATS Abbottabad
 
Real Time Embedded System
Real Time Embedded SystemReal Time Embedded System
Real Time Embedded System
Vrushali Lanjewar
 
Aeav 301 lec 19
Aeav 301 lec 19Aeav 301 lec 19
Aeav 301 lec 19
0mehdi
 
Introduction to 8085 by adi ppt
Introduction to 8085 by adi pptIntroduction to 8085 by adi ppt
Introduction to 8085 by adi ppt
Prof. Dr. K. Adisesha
 
Intel codetable
Intel codetableIntel codetable
Intel codetable
J R7
 
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
Saumitra Rukmangad
 
Adc(pic)
Adc(pic)Adc(pic)
Adc(pic)
shahbhaumikk
 
Understanding Tomasulo Algorithm
Understanding Tomasulo AlgorithmUnderstanding Tomasulo Algorithm
Understanding Tomasulo Algorithm
onesuper
 
Instruction Set 8085
Instruction Set 8085Instruction Set 8085
Instruction Set 8085
Stupidsid.com
 
Shift rotate
Shift rotateShift rotate
Shift rotate
fika sweety
 
Lec15 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Re...
Lec15 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Re...Lec15 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Re...
Lec15 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Re...
Hsien-Hsin Sean Lee, Ph.D.
 
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
Tsuyoshi Horigome
 
Code 8051
Code 8051Code 8051
Code 8051
harihiet
 
INTEL 8085 DATA FORMAT AND INSTRUCTIONS
INTEL 8085 DATA FORMAT AND INSTRUCTIONSINTEL 8085 DATA FORMAT AND INSTRUCTIONS
INTEL 8085 DATA FORMAT AND INSTRUCTIONS
Swapnil Mishra
 

What's hot (18)

Alp 8051
Alp 8051Alp 8051
Alp 8051
 
8085 instruction-set
8085 instruction-set8085 instruction-set
8085 instruction-set
 
8085 instruction-set
8085 instruction-set8085 instruction-set
8085 instruction-set
 
Microcontroller 8051 soft
Microcontroller 8051  softMicrocontroller 8051  soft
Microcontroller 8051 soft
 
implementation of data instrucions in emu8086
implementation of data instrucions in emu8086implementation of data instrucions in emu8086
implementation of data instrucions in emu8086
 
Real Time Embedded System
Real Time Embedded SystemReal Time Embedded System
Real Time Embedded System
 
Aeav 301 lec 19
Aeav 301 lec 19Aeav 301 lec 19
Aeav 301 lec 19
 
Introduction to 8085 by adi ppt
Introduction to 8085 by adi pptIntroduction to 8085 by adi ppt
Introduction to 8085 by adi ppt
 
Intel codetable
Intel codetableIntel codetable
Intel codetable
 
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
 
Adc(pic)
Adc(pic)Adc(pic)
Adc(pic)
 
Understanding Tomasulo Algorithm
Understanding Tomasulo AlgorithmUnderstanding Tomasulo Algorithm
Understanding Tomasulo Algorithm
 
Instruction Set 8085
Instruction Set 8085Instruction Set 8085
Instruction Set 8085
 
Shift rotate
Shift rotateShift rotate
Shift rotate
 
Lec15 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Re...
Lec15 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Re...Lec15 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Re...
Lec15 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Re...
 
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
 
Code 8051
Code 8051Code 8051
Code 8051
 
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.ppt
steffydean
 
Programs using Microcontrollers.ppt
Programs using Microcontrollers.pptPrograms using Microcontrollers.ppt
Programs using Microcontrollers.ppt
SasiBhushan22
 
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 - summarize
Hisham Mat Hussin
 
unit5_8051_microcontroller presentation.pdf
unit5_8051_microcontroller presentation.pdfunit5_8051_microcontroller presentation.pdf
unit5_8051_microcontroller presentation.pdf
tchandoo1
 
Micro task1
Micro task1Micro task1
Micro task1
ChetanShahukari
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
jokersclown57
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
karthiga selvaraju
 
8085 paper-presentation
8085 paper-presentation8085 paper-presentation
8085 paper-presentation
JiMs ChAcko
 
Microprocessor Part 3
Microprocessor    Part  3Microprocessor    Part  3
Microprocessor Part 3
Sajan Agrawal
 
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
logesh waran
 
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
Jathin 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-2
Jathin Kanumuri
 
8085 Architecture
8085 Architecture8085 Architecture
8085 Architecture
Kumar Anand Singh
 
6 arithmetic logic inst and prog
6 arithmetic logic inst and prog6 arithmetic logic inst and prog
6 arithmetic logic inst and prog
Channabasappa Kudarihal
 
3 jump, loop and call instructions
3 jump, loop and call instructions3 jump, loop and call instructions
3 jump, loop and call instructions
Channabasappa Kudarihal
 
New text document
New text documentNew text document
New text document
zocaniveb
 
8085 micro processor
8085 micro processor8085 micro processor
8085 micro processor
Poojith Chowdhary
 
8085-paper-presentation.ppt
8085-paper-presentation.ppt8085-paper-presentation.ppt
8085-paper-presentation.ppt
KalaiSelvan911913
 
8051 Programming Instruction Set
 8051 Programming Instruction Set 8051 Programming Instruction Set
8051 Programming Instruction Set
Shreyans Pathak
 

Similar to Maicrocontroller lab basic experiments (20)

Microcontroller 8051- soft.ppt
Microcontroller 8051- soft.pptMicrocontroller 8051- soft.ppt
Microcontroller 8051- soft.ppt
 
Programs using Microcontrollers.ppt
Programs using Microcontrollers.pptPrograms using Microcontrollers.ppt
Programs using Microcontrollers.ppt
 
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
 
unit5_8051_microcontroller presentation.pdf
unit5_8051_microcontroller presentation.pdfunit5_8051_microcontroller presentation.pdf
unit5_8051_microcontroller presentation.pdf
 
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
 
Microprocessor Part 3
Microprocessor    Part  3Microprocessor    Part  3
Microprocessor Part 3
 
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
 
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
 
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
 
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 micro processor
8085 micro processor8085 micro processor
8085 micro processor
 
8085-paper-presentation.ppt
8085-paper-presentation.ppt8085-paper-presentation.ppt
8085-paper-presentation.ppt
 
8051 Programming Instruction Set
 8051 Programming Instruction Set 8051 Programming Instruction Set
8051 Programming Instruction Set
 

Recently uploaded

A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 

Recently uploaded (20)

A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 

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)Evaluate simple 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)Addition of three 8-bit BCD numbers and obtain result 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.