SlideShare a Scribd company logo
1 of 21
8051
Part II
8051 ALP to load data from 50h to 54h
● org 0h
mov 50h,#0ah
mov 51h,#25h
mov 52h,#74h
mov 53h,#99h
mov 54h,#0bch
end
8051 ALP to move a block of data from 50-54h to
60-64h
● org 0h
mov a,50h
mov 60h,a
mov a,51h
mov 61h,a
mov a,52h
mov 62h,a
mov a,53h
mov 63h,a
mov a,54h
mov 64h,a
end
8051 ALP to block exchange w.r.t external ram using
loops
● org 0h
clr c
mov r5,#03
mov r0,#20h
mov dptr,#20h
up:movx a,@dptr
xch a,@r0
movx @dptr,a
inc r0
inc dptr
djnz r5,up
end
8051 ALP to find a given number is even or odd
● org 0h
clr c
mov a,#35h
rrc a
jc odd
mov a,#0aah
sjmp l1
odd:mov a,#0aah
l1:nop
end
8051 ALP to identify even and odd in an given array
● org 0h
clr c
mov r7,#05h
mov r4,#00h
mov r5,#00h
mov r0,#20h
up:mov a,@r0
rrc a
jc odd
inc r4
sjmp down
odd:inc r5
down:inc r0
djnz r7,up
end
8051 ALP to arrange in ascdending order
●
org 0h
mov r4,#04h
here:mov r0,#03h
mov r1,#30h
this:mov a,@r1
inc r1
mov b,@r0
cjne a,b,next
sjmp down
next:jc down
dec r0
mov @r0,b
inc r0
mov @r0,a
down:djnz r1,this
djnz r4,here
end
8051 ALP to indicate no of 1’s and 0’s
● org 0h
mov r6,#00h
mov r5,#00h
mov r7,#08h
mov a,#37h
up:rrc a
jc one
inc r6
sjmp down
one:inc r5
down:djnz r7,up
end
8051 ALP To add two 32-bit numbers
R6 R4 R2 R0
23 15 60 70
+
30 40 63 77
R7 R5 R3 R1
● org 0h
mov r0,#70h
mov r1,#77h
mov r2,#60h
mov r3,#63h
mov r4,#15h
mov r5,#40h
mov r6,#23h
mov r7,#30h
mov a,r0
add a,r1
mov 43h,a
mov a,r2
addc a,r3
mov 42h,a
addc a,r5
mov 41h,a
mov a,r6
addc a,r7
mov 40h,a
end
8051 ALP to subtract two 8-bit numbers
● org 0000h
mov a,40h
subb a,41h
mov 50h,a
end
8051 ALP to subtract two 16-bit numbers
● org 0h
mov r0,41h
mov r1,51h
mov r2,40h
mov r3,50h
mov a,r0
subb a,r1
mov 61h,a
mov a,r2
subb a,r3
mov 60h,a
end
8051 ALP to multiply two 16-bit numbers
● org 0h
mov r1,#0ffh
mov r2,#0ffh
mov r3,#0ffh
mov r4,#0ffh
mov a,r3
mov b,r4
mul ab
mov 44h,a
mov 43h,b
mov b,r1
mov a,r4
mul ab
add a,43h
mov 43h,a
mov a,b
addc a,#0h
mov 42h,a
mov a,r3
mov b,r2
mul ab
mov 53h,a
mov 52h,b
mov b,r1
mov a,r2
mul ab
add a,52h
mov 52h,a
mov a,b
addc a,#0h
mov 51h,a
clr c
mov 64h,44h
mov a,43h
add a,53h
mov 63h,a
mov a,42h
addc a,#0h
add a,52h
mov 62h,a
mov a,51h
addc a,#00h
mov 61h,a
end
8051 ALP to compute average
of n numbers
● org 0h
mov r3,#09h
mov r0,#20h
mov a,@r0
mov r6,a
inc r5
back: inc r0
mov a,@r0
addc a, r6
mov r6, a
inc r5
djnz r3, back
mov b, r5
end
8051 ALP to compute factorial
● org 0h
mov r4, #4h
mov r1, #1h
mov a, r1
back: inc r1
mov b, r1
mul ab
djnz r4, back
end
8051 ALP to compute gcd
● org 0h
mov a, #6h
mov b, #10h
back: mov r1, b
div ab
mov a, r1
into r1
cjne r1, #00h, back
end
8051 ALP to compute lcm
● org 0h
mov a, #6h
mov r6, a
mov b, #10h
mov r7, b
back: mov r1, b
div ab
mov a, r1
mov r1, b
cjne r1, #00h, back
mov r5, a
mov a, r6
mov b, r7
mul ab
mov b, r5
end
ALP to find number of positive numbers in an array of 10
number
● org 0h
mov r3, #05h
mov r0, #40h
check: mov a, @r0
inc r0
rlc a
jc down
inc r5
down: djnz r3, check
end
THANK YOU

More Related Content

Similar to 8051 -2

1347 assemblylanguageprogrammingof8051-100523023308-phpapp01
1347 assemblylanguageprogrammingof8051-100523023308-phpapp011347 assemblylanguageprogrammingof8051-100523023308-phpapp01
1347 assemblylanguageprogrammingof8051-100523023308-phpapp01
bvenkanna
 
8051 addressing modes
 8051 addressing modes 8051 addressing modes
8051 addressing modes
ghoshshweta
 
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
 
Logic, shift and rotate instruction
Logic, shift and rotate instructionLogic, shift and rotate instruction
Logic, shift and rotate instruction
kashif Shafqat
 

Similar to 8051 -2 (20)

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
 
New text document
New text documentNew text document
New text document
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
 
mup
mupmup
mup
 
Microcontroller 8051 soft
Microcontroller 8051  softMicrocontroller 8051  soft
Microcontroller 8051 soft
 
Maicrocontroller lab basic experiments
Maicrocontroller lab basic experimentsMaicrocontroller lab basic experiments
Maicrocontroller lab basic experiments
 
Maicrocontroller lab basic experiments
Maicrocontroller lab basic experiments Maicrocontroller lab basic experiments
Maicrocontroller lab basic experiments
 
Arm chap 3 last
Arm chap 3 lastArm chap 3 last
Arm chap 3 last
 
Microcontroller (8051) general and simple alp n cprograms
Microcontroller (8051) general and simple alp n cprogramsMicrocontroller (8051) general and simple alp n cprograms
Microcontroller (8051) general and simple alp n cprograms
 
Linux Binary Exploitation - Return-oritend Programing
Linux Binary Exploitation - Return-oritend ProgramingLinux Binary Exploitation - Return-oritend Programing
Linux Binary Exploitation - Return-oritend Programing
 
1347 assemblylanguageprogrammingof8051-100523023308-phpapp01
1347 assemblylanguageprogrammingof8051-100523023308-phpapp011347 assemblylanguageprogrammingof8051-100523023308-phpapp01
1347 assemblylanguageprogrammingof8051-100523023308-phpapp01
 
Microcontroller 8051- soft.ppt
Microcontroller 8051- soft.pptMicrocontroller 8051- soft.ppt
Microcontroller 8051- soft.ppt
 
Embedded Systems Training & Live Projects @Technogroovy Systems India Pvt Ltd
Embedded Systems Training & Live Projects @Technogroovy Systems India Pvt Ltd Embedded Systems Training & Live Projects @Technogroovy Systems India Pvt Ltd
Embedded Systems Training & Live Projects @Technogroovy Systems India Pvt Ltd
 
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
 
lec15_x86procedure_4up.pdf
lec15_x86procedure_4up.pdflec15_x86procedure_4up.pdf
lec15_x86procedure_4up.pdf
 
The 8051 microcontroller
The 8051 microcontrollerThe 8051 microcontroller
The 8051 microcontroller
 
8051 addressing modes
 8051 addressing modes 8051 addressing modes
8051 addressing modes
 
Addressing modes of 8051
Addressing modes of 8051Addressing modes of 8051
Addressing modes of 8051
 
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
 
Logic, shift and rotate instruction
Logic, shift and rotate instructionLogic, shift and rotate instruction
Logic, shift and rotate instruction
 

Recently uploaded

一比一原版(UNK毕业证)内布拉斯加州立大学科尼分校毕业证成绩单
一比一原版(UNK毕业证)内布拉斯加州立大学科尼分校毕业证成绩单一比一原版(UNK毕业证)内布拉斯加州立大学科尼分校毕业证成绩单
一比一原版(UNK毕业证)内布拉斯加州立大学科尼分校毕业证成绩单
tuuww
 
ENCODERS & DECODERS - Digital Electronics - diu swe
ENCODERS & DECODERS - Digital Electronics - diu sweENCODERS & DECODERS - Digital Electronics - diu swe
ENCODERS & DECODERS - Digital Electronics - diu swe
MohammadAliNayeem
 
Paint shop management system project report.pdf
Paint shop management system project report.pdfPaint shop management system project report.pdf
Paint shop management system project report.pdf
Kamal Acharya
 

Recently uploaded (20)

E-Commerce Shopping for developing a shopping ecommerce site
E-Commerce Shopping for developing a shopping ecommerce siteE-Commerce Shopping for developing a shopping ecommerce site
E-Commerce Shopping for developing a shopping ecommerce site
 
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and VisualizationKIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
 
İTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopİTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering Workshop
 
Natalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in KrakówNatalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in Kraków
 
一比一原版(UNK毕业证)内布拉斯加州立大学科尼分校毕业证成绩单
一比一原版(UNK毕业证)内布拉斯加州立大学科尼分校毕业证成绩单一比一原版(UNK毕业证)内布拉斯加州立大学科尼分校毕业证成绩单
一比一原版(UNK毕业证)内布拉斯加州立大学科尼分校毕业证成绩单
 
Electrical shop management system project report.pdf
Electrical shop management system project report.pdfElectrical shop management system project report.pdf
Electrical shop management system project report.pdf
 
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWINGBRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
 
RM&IPR M5 notes.pdfResearch Methodolgy & Intellectual Property Rights Series 5
RM&IPR M5 notes.pdfResearch Methodolgy & Intellectual Property Rights Series 5RM&IPR M5 notes.pdfResearch Methodolgy & Intellectual Property Rights Series 5
RM&IPR M5 notes.pdfResearch Methodolgy & Intellectual Property Rights Series 5
 
Low rpm Generator for efficient energy harnessing from a two stage wind turbine
Low rpm Generator for efficient energy harnessing from a two stage wind turbineLow rpm Generator for efficient energy harnessing from a two stage wind turbine
Low rpm Generator for efficient energy harnessing from a two stage wind turbine
 
Supermarket billing system project report..pdf
Supermarket billing system project report..pdfSupermarket billing system project report..pdf
Supermarket billing system project report..pdf
 
Top 13 Famous Civil Engineering Scientist
Top 13 Famous Civil Engineering ScientistTop 13 Famous Civil Engineering Scientist
Top 13 Famous Civil Engineering Scientist
 
The battle for RAG, explore the pros and cons of using KnowledgeGraphs and Ve...
The battle for RAG, explore the pros and cons of using KnowledgeGraphs and Ve...The battle for RAG, explore the pros and cons of using KnowledgeGraphs and Ve...
The battle for RAG, explore the pros and cons of using KnowledgeGraphs and Ve...
 
Construction method of steel structure space frame .pptx
Construction method of steel structure space frame .pptxConstruction method of steel structure space frame .pptx
Construction method of steel structure space frame .pptx
 
Peek implant persentation - Copy (1).pdf
Peek implant persentation - Copy (1).pdfPeek implant persentation - Copy (1).pdf
Peek implant persentation - Copy (1).pdf
 
Online resume builder management system project report.pdf
Online resume builder management system project report.pdfOnline resume builder management system project report.pdf
Online resume builder management system project report.pdf
 
Research Methodolgy & Intellectual Property Rights Series 1
Research Methodolgy & Intellectual Property Rights Series 1Research Methodolgy & Intellectual Property Rights Series 1
Research Methodolgy & Intellectual Property Rights Series 1
 
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdfA CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
 
ENCODERS & DECODERS - Digital Electronics - diu swe
ENCODERS & DECODERS - Digital Electronics - diu sweENCODERS & DECODERS - Digital Electronics - diu swe
ENCODERS & DECODERS - Digital Electronics - diu swe
 
Paint shop management system project report.pdf
Paint shop management system project report.pdfPaint shop management system project report.pdf
Paint shop management system project report.pdf
 
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptxCloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
 

8051 -2

  • 2. 8051 ALP to load data from 50h to 54h ● org 0h mov 50h,#0ah mov 51h,#25h mov 52h,#74h mov 53h,#99h mov 54h,#0bch end
  • 3. 8051 ALP to move a block of data from 50-54h to 60-64h ● org 0h mov a,50h mov 60h,a mov a,51h mov 61h,a mov a,52h mov 62h,a mov a,53h mov 63h,a mov a,54h mov 64h,a end
  • 4. 8051 ALP to block exchange w.r.t external ram using loops ● org 0h clr c mov r5,#03 mov r0,#20h mov dptr,#20h up:movx a,@dptr xch a,@r0 movx @dptr,a inc r0 inc dptr djnz r5,up end
  • 5. 8051 ALP to find a given number is even or odd ● org 0h clr c mov a,#35h rrc a jc odd mov a,#0aah sjmp l1 odd:mov a,#0aah l1:nop end
  • 6. 8051 ALP to identify even and odd in an given array ● org 0h clr c mov r7,#05h mov r4,#00h mov r5,#00h mov r0,#20h up:mov a,@r0 rrc a jc odd inc r4 sjmp down odd:inc r5 down:inc r0 djnz r7,up end
  • 7. 8051 ALP to arrange in ascdending order ● org 0h mov r4,#04h here:mov r0,#03h mov r1,#30h this:mov a,@r1 inc r1 mov b,@r0 cjne a,b,next sjmp down next:jc down dec r0 mov @r0,b inc r0 mov @r0,a down:djnz r1,this djnz r4,here end
  • 8. 8051 ALP to indicate no of 1’s and 0’s ● org 0h mov r6,#00h mov r5,#00h mov r7,#08h mov a,#37h up:rrc a jc one inc r6 sjmp down one:inc r5 down:djnz r7,up end
  • 9. 8051 ALP To add two 32-bit numbers R6 R4 R2 R0 23 15 60 70 + 30 40 63 77 R7 R5 R3 R1 ● org 0h mov r0,#70h mov r1,#77h mov r2,#60h mov r3,#63h
  • 10. mov r4,#15h mov r5,#40h mov r6,#23h mov r7,#30h mov a,r0 add a,r1 mov 43h,a mov a,r2 addc a,r3 mov 42h,a addc a,r5 mov 41h,a mov a,r6 addc a,r7 mov 40h,a end
  • 11. 8051 ALP to subtract two 8-bit numbers ● org 0000h mov a,40h subb a,41h mov 50h,a end
  • 12. 8051 ALP to subtract two 16-bit numbers ● org 0h mov r0,41h mov r1,51h mov r2,40h mov r3,50h mov a,r0 subb a,r1 mov 61h,a mov a,r2 subb a,r3 mov 60h,a end
  • 13. 8051 ALP to multiply two 16-bit numbers ● org 0h mov r1,#0ffh mov r2,#0ffh mov r3,#0ffh mov r4,#0ffh mov a,r3 mov b,r4 mul ab mov 44h,a mov 43h,b mov b,r1 mov a,r4 mul ab
  • 14. add a,43h mov 43h,a mov a,b addc a,#0h mov 42h,a mov a,r3 mov b,r2 mul ab mov 53h,a mov 52h,b mov b,r1 mov a,r2 mul ab add a,52h mov 52h,a mov a,b addc a,#0h
  • 15. mov 51h,a clr c mov 64h,44h mov a,43h add a,53h mov 63h,a mov a,42h addc a,#0h add a,52h mov 62h,a mov a,51h addc a,#00h mov 61h,a end
  • 16. 8051 ALP to compute average of n numbers ● org 0h mov r3,#09h mov r0,#20h mov a,@r0 mov r6,a inc r5 back: inc r0 mov a,@r0 addc a, r6 mov r6, a inc r5 djnz r3, back mov b, r5 end
  • 17. 8051 ALP to compute factorial ● org 0h mov r4, #4h mov r1, #1h mov a, r1 back: inc r1 mov b, r1 mul ab djnz r4, back end
  • 18. 8051 ALP to compute gcd ● org 0h mov a, #6h mov b, #10h back: mov r1, b div ab mov a, r1 into r1 cjne r1, #00h, back end
  • 19. 8051 ALP to compute lcm ● org 0h mov a, #6h mov r6, a mov b, #10h mov r7, b back: mov r1, b div ab mov a, r1 mov r1, b cjne r1, #00h, back mov r5, a mov a, r6 mov b, r7 mul ab mov b, r5 end
  • 20. ALP to find number of positive numbers in an array of 10 number ● org 0h mov r3, #05h mov r0, #40h check: mov a, @r0 inc r0 rlc a jc down inc r5 down: djnz r3, check end