SlideShare a Scribd company logo
1 of 18
Download to read offline
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

What's hot (20)

8086 alp
8086 alp8086 alp
8086 alp
 
Microprocessor 8085 Chapter 3
Microprocessor 8085 Chapter 3Microprocessor 8085 Chapter 3
Microprocessor 8085 Chapter 3
 
Memory Reference Instructions
Memory Reference InstructionsMemory Reference Instructions
Memory Reference Instructions
 
8086 Instruction set
8086 Instruction set8086 Instruction set
8086 Instruction set
 
8086 String Instructions.pdf
8086 String Instructions.pdf8086 String Instructions.pdf
8086 String Instructions.pdf
 
8051-mazidi-solution
8051-mazidi-solution8051-mazidi-solution
8051-mazidi-solution
 
boolean 8051
boolean 8051boolean 8051
boolean 8051
 
Pda to cfg h2
Pda to cfg h2Pda to cfg h2
Pda to cfg h2
 
Flag register 8086 assignment
Flag register 8086 assignmentFlag register 8086 assignment
Flag register 8086 assignment
 
ARM Processors
ARM ProcessorsARM Processors
ARM Processors
 
Chomsky classification of Language
Chomsky classification of LanguageChomsky classification of Language
Chomsky classification of Language
 
Microprocessor-Based Automatic Door Opener
Microprocessor-Based Automatic Door OpenerMicroprocessor-Based Automatic Door Opener
Microprocessor-Based Automatic Door Opener
 
Embedded C programming based on 8051 microcontroller
Embedded C programming based on 8051 microcontrollerEmbedded C programming based on 8051 microcontroller
Embedded C programming based on 8051 microcontroller
 
8085 architecture
8085 architecture8085 architecture
8085 architecture
 
Mid point circle algorithm
Mid point circle algorithmMid point circle algorithm
Mid point circle algorithm
 
Arduino and its hw architecture
Arduino and its hw architectureArduino and its hw architecture
Arduino and its hw architecture
 
verilog code for logic gates
verilog code for logic gatesverilog code for logic gates
verilog code for logic gates
 
8051 Assembly Language Programming
8051 Assembly Language Programming8051 Assembly Language Programming
8051 Assembly Language Programming
 
Verilog VHDL code Parallel adder
Verilog VHDL code Parallel adder Verilog VHDL code Parallel adder
Verilog VHDL code Parallel adder
 
Loop invariant computation
Loop invariant computationLoop invariant computation
Loop invariant computation
 

Similar to Micro Controller lab basic experiments (1)

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
 
Microprocessor Part 3
Microprocessor    Part  3Microprocessor    Part  3
Microprocessor Part 3Sajan 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 8051logesh waran
 
Winter training,Readymade Projects,Buy Projects,Corporate Training
Winter training,Readymade Projects,Buy Projects,Corporate TrainingWinter training,Readymade Projects,Buy Projects,Corporate Training
Winter training,Readymade Projects,Buy Projects,Corporate TrainingTechnogroovy
 
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
 
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
 
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 Micro Controller lab basic experiments (1) (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
 
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
 
Winter training,Readymade Projects,Buy Projects,Corporate Training
Winter training,Readymade Projects,Buy Projects,Corporate TrainingWinter training,Readymade Projects,Buy Projects,Corporate Training
Winter training,Readymade Projects,Buy Projects,Corporate Training
 
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
 
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
 
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
 

Recently uploaded

Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 

Recently uploaded (20)

Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 

Micro Controller lab basic experiments (1)

  • 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.