SlideShare a Scribd company logo
1 of 21
8051
8051 Basic Programs
8051 ALP move locations from 10h-19h to 30h-
39h
● org 0h
mov 31h,11h
mov 32h,12h
mov 33h,13h
mov 34h,14h
mov 35h,15h
mov 36h,16h
mov 37h,17h
mov 38h,18h
mov 39h,19h
end
8051 ALP to move from internal to external
● org 0h
mov r0,#20h
mov a,@r0
mov dptr,#100h
movx @dptr,a
mov r1,#21h
mov a,@r1
mov dptr,#101h
movx @dptr,a
end
8051 ALP to add 2 8 bit numbers and use all
addressing modes
● IMMEDIATE MODE:
org 0h
add,#20h
add a,#30h
end
● REGISTER MODE:
org 0h
mov a,#20h
mov r0,#50h
add a,r0
end
● DIRECT MODE:
org 0h
mov a,#20h
add a,20h
end
● INDIRECT MODE:
org 0h
mov a,#20h
mov r0,#20h
add a,r0
end
8051 ALP to add 2 16 bit number
● org 0h
mov r0,#0a0h
mov r1,#0c0h
mov r2,#0d0h
mov r3,#0a0h
mov a,r0
add a,r2
mov r4,a
mov a,r1
add a,r3
mov r5,a
end
ALP to substract lower number from higher no
and vice versa
● org 0h
mov a,#50h
mov r0,#20h
subb a,r0
end
ALP TO multiply 2 8 bit numbers
● org 0h
mov a,#02h
movb,#04h
mul ab
end
8051 ALP to divide 2 numbers
● org 0h
mov a,#07h
mov a,#08h
div ab
end
8051 ALP to square a given number
● org 0h
mov a,#02h
mov b,#02h
mul ab
end
8051 ALP to cube a given number
● org 0h
mov a,#02h
mov b,#02h
mul ab
mov b,#02h
mul ab
end
8051 ALP to increment a number
● org 0h
mov r0,#10h
mov a,#50h
inc a
inc r0
end
ALP 8051 to rotate left
● org 0h
mov r0,#11h
mov a,r0
rl a
end
8051 ALP to rotate left with carry
● org 0h
mov r0,#95
mov a,ro
rlc a
end
8051 ALP to rotate right
● org 0h
mov r0,#11h
mov a,r0
rr a
end
8051 ALP to rotate right with carry
● org 0h
mov r0,#11h
mov a,r0
rrc a
end
8051 ALP to use djnz condition
● org 0h
mov r2,#05h
mov r5,#00h
up:inc r5
djnz r2,up
mov a,r5
end
8051 ALP to use cjne condition
● org 0h
mov r2,#05h
mov r5,#00h
up:inc r5
dec r2
cjne r2,#00,up
mov a,r5
end
THANK YOU

More Related Content

What's hot (7)

Logic Design - Chapter 2: Logic Gates
Logic Design - Chapter 2: Logic GatesLogic Design - Chapter 2: Logic Gates
Logic Design - Chapter 2: Logic Gates
 
Listing prog
Listing progListing prog
Listing prog
 
Describe the register
Describe the registerDescribe the register
Describe the register
 
Applications of microcontroller(8051)
Applications of microcontroller(8051) Applications of microcontroller(8051)
Applications of microcontroller(8051)
 
Day4 順序控制的循序邏輯實現
Day4 順序控制的循序邏輯實現Day4 順序控制的循序邏輯實現
Day4 順序控制的循序邏輯實現
 
Steppert Motor Interfacing With Specific Angle Entered Through Keypad
Steppert Motor Interfacing With Specific Angle Entered Through KeypadSteppert Motor Interfacing With Specific Angle Entered Through Keypad
Steppert Motor Interfacing With Specific Angle Entered Through Keypad
 
Trts d flip flop1
Trts d flip flop1Trts d flip flop1
Trts d flip flop1
 

Similar to 8051

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
 
432_17EC563_8051-microcontroller-moving-data_notes.pdf
432_17EC563_8051-microcontroller-moving-data_notes.pdf432_17EC563_8051-microcontroller-moving-data_notes.pdf
432_17EC563_8051-microcontroller-moving-data_notes.pdf
ShreeKrishnaTarai
 
Microcontrollers and RT programming 3
Microcontrollers and RT programming 3Microcontrollers and RT programming 3
Microcontrollers and RT programming 3
SSGMCE SHEGAON
 

Similar to 8051 (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
 
MCUnit 4and 5_New.pptx
MCUnit 4and 5_New.pptxMCUnit 4and 5_New.pptx
MCUnit 4and 5_New.pptx
 
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
 
Maicrocontroller lab basic experiments
Maicrocontroller lab basic experimentsMaicrocontroller lab basic experiments
Maicrocontroller lab basic experiments
 
Microcontroller 8051 soft
Microcontroller 8051  softMicrocontroller 8051  soft
Microcontroller 8051 soft
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
 
Maicrocontroller lab basic experiments
Maicrocontroller lab basic experiments Maicrocontroller lab basic experiments
Maicrocontroller lab basic experiments
 
Instruction types
Instruction typesInstruction types
Instruction types
 
Addressing modes of 8051
Addressing modes of 8051Addressing modes of 8051
Addressing modes of 8051
 
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 Week 8: Subroutine
Microprocessor Week 8: Subroutine Microprocessor Week 8: Subroutine
Microprocessor Week 8: Subroutine
 
432_17EC563_8051-microcontroller-moving-data_notes.pdf
432_17EC563_8051-microcontroller-moving-data_notes.pdf432_17EC563_8051-microcontroller-moving-data_notes.pdf
432_17EC563_8051-microcontroller-moving-data_notes.pdf
 
Microcontrollers and RT programming 3
Microcontrollers and RT programming 3Microcontrollers and RT programming 3
Microcontrollers and RT programming 3
 
Micro task1
Micro task1Micro task1
Micro task1
 
8051 training an interactive tutorial
8051 training an interactive tutorial8051 training an interactive tutorial
8051 training an interactive tutorial
 
Interrupt programming with 8051 microcontroller
Interrupt programming with 8051  microcontrollerInterrupt programming with 8051  microcontroller
Interrupt programming with 8051 microcontroller
 
MICROCONTROLLERS-module2 (7).pptx
MICROCONTROLLERS-module2 (7).pptxMICROCONTROLLERS-module2 (7).pptx
MICROCONTROLLERS-module2 (7).pptx
 
Unit iv introduction to 8051 microcontroller ppts
Unit iv introduction to 8051 microcontroller pptsUnit iv introduction to 8051 microcontroller ppts
Unit iv introduction to 8051 microcontroller ppts
 
8051.pdf
8051.pdf8051.pdf
8051.pdf
 

Recently uploaded

Final DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualFinal DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manual
BalamuruganV28
 
electrical installation and maintenance.
electrical installation and maintenance.electrical installation and maintenance.
electrical installation and maintenance.
benjamincojr
 
Artificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdfArtificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdf
Kira Dess
 

Recently uploaded (20)

Final DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualFinal DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manual
 
electrical installation and maintenance.
electrical installation and maintenance.electrical installation and maintenance.
electrical installation and maintenance.
 
engineering chemistry power point presentation
engineering chemistry  power point presentationengineering chemistry  power point presentation
engineering chemistry power point presentation
 
Filters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility ApplicationsFilters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility Applications
 
Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...
 
Insurance management system project report.pdf
Insurance management system project report.pdfInsurance management system project report.pdf
Insurance management system project report.pdf
 
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
 
Software Engineering Practical File Front Pages.pdf
Software Engineering Practical File Front Pages.pdfSoftware Engineering Practical File Front Pages.pdf
Software Engineering Practical File Front Pages.pdf
 
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdfInstruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
 
The Entity-Relationship Model(ER Diagram).pptx
The Entity-Relationship Model(ER Diagram).pptxThe Entity-Relationship Model(ER Diagram).pptx
The Entity-Relationship Model(ER Diagram).pptx
 
Artificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdfArtificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdf
 
Independent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging StationIndependent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging Station
 
UNIT-2 image enhancement.pdf Image Processing Unit 2 AKTU
UNIT-2 image enhancement.pdf Image Processing Unit 2 AKTUUNIT-2 image enhancement.pdf Image Processing Unit 2 AKTU
UNIT-2 image enhancement.pdf Image Processing Unit 2 AKTU
 
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxSLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
 
UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptx
 
Autodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptxAutodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptx
 
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas SachpazisSeismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
 
Worksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxWorksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptx
 
Diploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdfDiploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdf
 
History of Indian Railways - the story of Growth & Modernization
History of Indian Railways - the story of Growth & ModernizationHistory of Indian Railways - the story of Growth & Modernization
History of Indian Railways - the story of Growth & Modernization
 

8051

  • 2. 8051 ALP move locations from 10h-19h to 30h- 39h ● org 0h mov 31h,11h mov 32h,12h mov 33h,13h mov 34h,14h mov 35h,15h mov 36h,16h mov 37h,17h mov 38h,18h mov 39h,19h end
  • 3. 8051 ALP to move from internal to external ● org 0h mov r0,#20h mov a,@r0 mov dptr,#100h movx @dptr,a mov r1,#21h mov a,@r1 mov dptr,#101h movx @dptr,a end
  • 4. 8051 ALP to add 2 8 bit numbers and use all addressing modes ● IMMEDIATE MODE: org 0h add,#20h add a,#30h end
  • 5. ● REGISTER MODE: org 0h mov a,#20h mov r0,#50h add a,r0 end
  • 6. ● DIRECT MODE: org 0h mov a,#20h add a,20h end
  • 7. ● INDIRECT MODE: org 0h mov a,#20h mov r0,#20h add a,r0 end
  • 8. 8051 ALP to add 2 16 bit number ● org 0h mov r0,#0a0h mov r1,#0c0h mov r2,#0d0h mov r3,#0a0h mov a,r0 add a,r2 mov r4,a mov a,r1 add a,r3 mov r5,a end
  • 9. ALP to substract lower number from higher no and vice versa ● org 0h mov a,#50h mov r0,#20h subb a,r0 end
  • 10. ALP TO multiply 2 8 bit numbers ● org 0h mov a,#02h movb,#04h mul ab end
  • 11. 8051 ALP to divide 2 numbers ● org 0h mov a,#07h mov a,#08h div ab end
  • 12. 8051 ALP to square a given number ● org 0h mov a,#02h mov b,#02h mul ab end
  • 13. 8051 ALP to cube a given number ● org 0h mov a,#02h mov b,#02h mul ab mov b,#02h mul ab end
  • 14. 8051 ALP to increment a number ● org 0h mov r0,#10h mov a,#50h inc a inc r0 end
  • 15. ALP 8051 to rotate left ● org 0h mov r0,#11h mov a,r0 rl a end
  • 16. 8051 ALP to rotate left with carry ● org 0h mov r0,#95 mov a,ro rlc a end
  • 17. 8051 ALP to rotate right ● org 0h mov r0,#11h mov a,r0 rr a end
  • 18. 8051 ALP to rotate right with carry ● org 0h mov r0,#11h mov a,r0 rrc a end
  • 19. 8051 ALP to use djnz condition ● org 0h mov r2,#05h mov r5,#00h up:inc r5 djnz r2,up mov a,r5 end
  • 20. 8051 ALP to use cjne condition ● org 0h mov r2,#05h mov r5,#00h up:inc r5 dec r2 cjne r2,#00,up mov a,r5 end