SlideShare a Scribd company logo
1 of 29
8051 ASSEMBLY
LANGUAGE
PROGRAMMING

BY
AVINASH KUMAR MISHRA
INTRODUCTION

TO PROGRAMMING:

CPU CAN ONLY WORK IN BINARY,IT CAN DO
SO AT VERY FAST SPEED.FOR HUMAN IT IS
QUITE TEDIOUS AND SLOW TO DEAL WITH
0’S & 1’S IN ORDER TO PROGRAM THE
COMPUTER .A PROGRAM THAT CONSISTS OF
0s AND 1s IS CALLED MACHINE LANGUAGE.
ASSEMBLY LANGUAGE WERE DEVELOPED
THAT
PROVIDED MNEUMONICS FOR THE MACHINE
CODE INSTRUCTION ,PLUS OTHER FEATURES
THAT MADE PROGRAMMING FASTER AND
.
LESS
PRONE TO ERROR. ASSEMBLY LANGUAGE
PROGRAMS MUST BE TRANSLATED INTO MACHINE
CODE BY A PROGRAM CALLED ASSEMBLER. TO
PROGRAM IN ASSEMBLY LANGUAGE , THE PROGRAMMER MUST KNOW ALL THE REGISTERS
OF THE CPU AND THE SIZE OF EACH ,AS WELL
AS OTHER DETAILS.
STRUCTURE

OF ASSEMBLY LANGUAGE

AN ASSEMBLY LANGUAGE CONSISTS OF
FOUR
FIELDS.
“ [LABEL:] MNEUMONICS [OPERAND]
[;COMMENT] ”
HERE BRACKETS INDICATE THAT A FIELD IS
OPTIONAL .
EXAMPLE
ORG OOH
;START AT LOCATION 0
MOV R5,#25H ;LOAD 25H INTO R5
MOV R6,#20H ; LOAD 20H INTO R6
MOV A ,#00H ; LOAD 00H INTO A
ADD A ,R5
; ADD CONTENTS OF R5 TO A
ADD A ,R6 ; ADD CONTENTS OF R6 TO A
ADD A ,#12H ; NOW A=A+ 12H
HERE: SJMP HERE ; STAY IN THIS LOOP
END
STEPS TO CREATE A

PROGRAM :

EDITOR PROGRAM
ASSEMBLER PROGRAM
LINKER PROGRAM
OH PROGRAM
PROGRAM COUNTER:
IT IS SPECIAL FUNCTION REGISTER
WHICH GENERALLY TELL OUR CONTROLLER OR PROCESSOR ABOUT NEXT
EXECUTING PROCESS.
STACK

POINTER:

IT IS THE SPECIAL FUNCTION REGISTER
WHICH IS USED TO STORE THE
EXECUTED
PROGRAM INSIDE YOUR STACK
MEMORY.
IT GENERALLY WORK ON THE
PHENOMENA
LIFO( LAST IN FIRST OUT).
ASSEMBLER

DIRECTIVES:

 ORG(ORIGIN):USED TO INDICATE THE

BEGINNING OF THE ADDERESS .
 EQU(EQUATE): USED TO DEFINE A
CONSTANT WITHOUT COPYING A
MEMORY LOCATION.
 END: IT INDICATES TO THE ASSEMBLER
THE
END OF SOURCE(ASM ) FILE.
PROGRAM

STATUS

WORD(PSW):
DEFINITION OF PSW REGISTER:
THE PROGRAM STATUS WORD (PSW) REGISTER IS AN 8 - BIT REGISTER. IT IS ALSO
REFFERED TO AS FLAG REGISTER.ALTHOUGH
PSW REGISTER IS 8-BITS WIDE, OLY 6-BITS
ARE USED BY 8051 . THE OTHER TWO ARE
USER DEFINABLE FLAGS. FOUR OF FLAGS
ARE CALLED CONDITIONAL FLAGS ,MEANS
THAT THEY INDICATE SOME CONDITION
CONTINUE
THAT RESULT AFTER A INSTRUCTION IS
EXECUTED . THESE FOUR ARE CY (CARRY)
,AC(AUXILIARY CARRY) , P ( PARITY) AND
OV(OVERFLOW) .RS0 AND RS1 ARE USED
TO CHANGE BANK REGISTORS . THE PSW
.1 AND PSW.5 ARE GENERAL PURPOSE
STATUS FLAG BITS AND CAN BE USED BY
PROGRAMMER FOR ANY PURPOSE.
8051 REGISTER BANKS & STACK:
THERE ARE 32 BYTES OF RAM ARE SET
ASIDE FOR THE REGISTER BANKS AND
STACK. THERE ARE 128 BYTES OF RAM
ARE USED IN 8051 . THE 128 BYTES ARE
ASSIGNED ADDRESSES 00 TO 7FH. FROM
THESE 32 BYTES ARE USED FOR STACK
AND REGISTER BANK .
THERE ARE 4 REGISTER BANKS. THESE ARE
[1] BANK(0) : ADDRESS FROM 00H TO 07H.
[2] BANK(1) : ADDRESS FROM 08H TO 0FH.
[3] BANK(1) : ADDRESS FROM 10H TO 17 H.
[4] BANK(1) : ADDRESS FROM 18H TO 1FH.
FROM 20H TO 2FH ARE ASSIGNED FOR BITADDERESSABLE RAM AND FROM 30H TO 7F
H ARE FOR SCRATCH PAD RAM.
RAM ALLOCATION
8051 REGISTER BANKS & THEIR
RAM ADDERESSES
STACK IN THE 8051:
STACK SI THE SECTION OF RAM USED BY
CPU TO STORE INFORMATION TEMPORA –
RILY . THIS INFORMATION COULD BE DATA
OR ADDERESS . THE CPU NEEDS THIS AREA
FOR STORAGE SINCE THERE ARE ONLY A
LIMITED NUMBER OF REGISTERS.
PUSHING ONTO STACK:
WE PUSH DATA ONTO STACK,THE STACK
POINTER (SP) IS INCREMENTED BY ONE.
• EXAMPLE:
MOV R6,#25H
MOV R1,#12H
MOV R4,#0F3H
PUSH 6
PUSH 1
PUSH 4
SOLUTION:
AFTER
PUSH6
0B
0A
09
08 25

AFTER
PUSH1
0B
0A
09 12
08 25

START
SP=07 SP=08

SP=09

0B
0A
09
08

AFTER
PUSH 4
0B
0A
F3
09
12
08 25

SP=0A
POPPING FROM STACK:
PROGRAMMING 8051 TIMERS:
• THE 8051 HAS TWO TIMERS : TIMER0

TIMER1.
• TIMER0 AND TIMER1 ARE 16-BITS WIDE.
• THE 8051 HAS 8-BIT ARCHITECTURE ,
EACH IS ACCESSED BY TWO SEPARATE
REGISTERS OF LOW BYTE AND HIGH
BYTE.
• TIMER0 REGISTERS: THE 16-BIT REGISTER

OF TIMER0 IS ACCESSED AS LOW BYTE
AND HIGH BYTE i.e TL0 & TH0.
• TIMER1 REGISTERS: THE 16-BIT REGISTER
OF TIMER0 IS ACCESSED AS LOW BYTE
AND HIGH BYTE i.e TL1 & TH1.
• TMOD (TIMER MODE) REGISTER: BOTH
TIMERS 0 &1 USE SAME REGISTER TMOD.
FIGURE OF TIMER0 AND TIMER1
TMOD REGISTER
STEPS TO PROGRAM FOR MODE1
a) LOAD TMOD
b) LOAD TH & TL

c) START TIMER (SBIT TR)
d) SET TI MER FLAG

H:JNB TF,H
e) CLR TR
f) CLR TF
g) RET
STEPS TO PROGRAM FOR MODE2
a) LOAD TMOD REGISTER
b) LOAD TIMER TYPE

c) SET TIMER/START TI MER
d) SET FLAG
e) CLR FLAG

f) RET
COUNTERS
TIMER / COUNTERS ARE USED TO
GENERATE TIME DELAYS . THESE
TIMERS CAN BE USED AS COUNTERS
COUNTING EVENTS HAPPENING OUTSIDE THE 8051 . WHEN THE TIMER /
COUNTER IS USED AS A TIMER, THE
8051’S CRYSTAL IS USED AS THE SOURCE
OF FREQUENCY.
.

END
.

THANK YOU

More Related Content

What's hot

Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutineAshim Saha
 
Data transfer instruction set of 8085 micro processor
Data transfer instruction set of 8085 micro processorData transfer instruction set of 8085 micro processor
Data transfer instruction set of 8085 micro processorvishalgohel12195
 
Microprocessor Part 3
Microprocessor    Part  3Microprocessor    Part  3
Microprocessor Part 3Sajan Agrawal
 
Stack in 8085 microprocessor
Stack in 8085 microprocessorStack in 8085 microprocessor
Stack in 8085 microprocessorhepzijustin
 
8051 instruction set
8051 instruction set8051 instruction set
8051 instruction setStefan Oprea
 
8051 assembly programming
8051 assembly programming8051 assembly programming
8051 assembly programmingsergeiseq
 
Chp5 pic microcontroller instruction set copy
Chp5 pic microcontroller instruction set   copyChp5 pic microcontroller instruction set   copy
Chp5 pic microcontroller instruction set copymkazree
 
Microprocessor and Microcontroller Lab Manual!
Microprocessor and Microcontroller Lab Manual!Microprocessor and Microcontroller Lab Manual!
Microprocessor and Microcontroller Lab Manual!PRABHAHARAN429
 
Microcontroller instruction set
Microcontroller instruction setMicrocontroller instruction set
Microcontroller instruction setShail Modi
 
Subroutine in 8051 microcontroller
Subroutine in 8051 microcontrollerSubroutine in 8051 microcontroller
Subroutine in 8051 microcontrollerbhadresh savani
 
Microprocessor instructions
Microprocessor instructionsMicroprocessor instructions
Microprocessor instructionshepzijustin
 
Microprocessor Week 8: Subroutine
Microprocessor Week 8: Subroutine Microprocessor Week 8: Subroutine
Microprocessor Week 8: Subroutine Arkhom Jodtang
 

What's hot (20)

Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutine
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutine
 
Micro task1
Micro task1Micro task1
Micro task1
 
Data transfer instruction set of 8085 micro processor
Data transfer instruction set of 8085 micro processorData transfer instruction set of 8085 micro processor
Data transfer instruction set of 8085 micro processor
 
8051 programming in c
8051 programming in c8051 programming in c
8051 programming in c
 
Microprocessor Part 3
Microprocessor    Part  3Microprocessor    Part  3
Microprocessor Part 3
 
Stack in 8085 microprocessor
Stack in 8085 microprocessorStack in 8085 microprocessor
Stack in 8085 microprocessor
 
8051 instruction set
8051 instruction set8051 instruction set
8051 instruction set
 
8051 assembly programming
8051 assembly programming8051 assembly programming
8051 assembly programming
 
Chp5 pic microcontroller instruction set copy
Chp5 pic microcontroller instruction set   copyChp5 pic microcontroller instruction set   copy
Chp5 pic microcontroller instruction set copy
 
Microprocessor and Microcontroller Lab Manual!
Microprocessor and Microcontroller Lab Manual!Microprocessor and Microcontroller Lab Manual!
Microprocessor and Microcontroller Lab Manual!
 
Microcontroller instruction set
Microcontroller instruction setMicrocontroller instruction set
Microcontroller instruction set
 
Subroutine in 8051 microcontroller
Subroutine in 8051 microcontrollerSubroutine in 8051 microcontroller
Subroutine in 8051 microcontroller
 
Class2
Class2Class2
Class2
 
mup
mupmup
mup
 
Microprocessor instructions
Microprocessor instructionsMicroprocessor instructions
Microprocessor instructions
 
Uc 2(vii)
Uc 2(vii)Uc 2(vii)
Uc 2(vii)
 
Microprocessor Week 8: Subroutine
Microprocessor Week 8: Subroutine Microprocessor Week 8: Subroutine
Microprocessor Week 8: Subroutine
 
Chapter 8
Chapter 8Chapter 8
Chapter 8
 
8085 instruction set
8085 instruction set8085 instruction set
8085 instruction set
 

Viewers also liked

8051 microcontroller notes continuous
8051 microcontroller notes continuous 8051 microcontroller notes continuous
8051 microcontroller notes continuous THANDAIAH PRABU
 
8051 Assembly Language Programming
8051 Assembly Language Programming8051 Assembly Language Programming
8051 Assembly Language ProgrammingRavikumar Tiwari
 
Chapter 7 8051 programming in c
Chapter 7  8051 programming in cChapter 7  8051 programming in c
Chapter 7 8051 programming in cAbdelrahman Elewah
 
Unit ii microcontrollers final
Unit ii microcontrollers finalUnit ii microcontrollers final
Unit ii microcontrollers finalSARITHA REDDY
 
8051 Programming Instruction Set
 8051 Programming Instruction Set 8051 Programming Instruction Set
8051 Programming Instruction SetShreyans Pathak
 
Unit iv microcontrollers final
Unit iv microcontrollers finalUnit iv microcontrollers final
Unit iv microcontrollers finalSARITHA REDDY
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontrollerJhemi22
 
Embedded systems ppt iv part b
Embedded systems ppt iv   part bEmbedded systems ppt iv   part b
Embedded systems ppt iv part banishgoel
 
Embedded systems ppt iv part a
Embedded systems ppt iv   part aEmbedded systems ppt iv   part a
Embedded systems ppt iv part aanishgoel
 
C language programming
C language programmingC language programming
C language programmingpullarao29
 
8051 microcontroller by K. Vijay Kumar
8051 microcontroller by K. Vijay Kumar8051 microcontroller by K. Vijay Kumar
8051 microcontroller by K. Vijay KumarVijay Kumar
 
Interrupt programming with 8051 microcontroller
Interrupt programming with 8051  microcontrollerInterrupt programming with 8051  microcontroller
Interrupt programming with 8051 microcontrollerAnkit Bhatnagar
 
MICROCONTROLLER 8051- Architecture & Pin Configuration
MICROCONTROLLER 8051- Architecture & Pin Configuration MICROCONTROLLER 8051- Architecture & Pin Configuration
MICROCONTROLLER 8051- Architecture & Pin Configuration AKHIL MADANKAR
 
INTRODUCTION TO MICROCONTROLLER
INTRODUCTION TO MICROCONTROLLERINTRODUCTION TO MICROCONTROLLER
INTRODUCTION TO MICROCONTROLLERAnkita Jaiswal
 
8051 programming skills using EMBEDDED C
8051 programming skills using EMBEDDED C8051 programming skills using EMBEDDED C
8051 programming skills using EMBEDDED CAman Sharma
 

Viewers also liked (20)

8051 microcontroller notes continuous
8051 microcontroller notes continuous 8051 microcontroller notes continuous
8051 microcontroller notes continuous
 
8051 Assembly Language Programming
8051 Assembly Language Programming8051 Assembly Language Programming
8051 Assembly Language Programming
 
Chapter 7 8051 programming in c
Chapter 7  8051 programming in cChapter 7  8051 programming in c
Chapter 7 8051 programming in c
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
 
Unit ii microcontrollers final
Unit ii microcontrollers finalUnit ii microcontrollers final
Unit ii microcontrollers final
 
8051 ch9-950217
8051 ch9-9502178051 ch9-950217
8051 ch9-950217
 
8051 Programming Instruction Set
 8051 Programming Instruction Set 8051 Programming Instruction Set
8051 Programming Instruction Set
 
Unit iv microcontrollers final
Unit iv microcontrollers finalUnit iv microcontrollers final
Unit iv microcontrollers final
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
 
Embedded systems ppt iv part b
Embedded systems ppt iv   part bEmbedded systems ppt iv   part b
Embedded systems ppt iv part b
 
Embedded systems ppt iv part a
Embedded systems ppt iv   part aEmbedded systems ppt iv   part a
Embedded systems ppt iv part a
 
C language programming
C language programmingC language programming
C language programming
 
Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051
 
8051 ch9
8051 ch98051 ch9
8051 ch9
 
8051 microcontroller by K. Vijay Kumar
8051 microcontroller by K. Vijay Kumar8051 microcontroller by K. Vijay Kumar
8051 microcontroller by K. Vijay Kumar
 
Interrupt programming with 8051 microcontroller
Interrupt programming with 8051  microcontrollerInterrupt programming with 8051  microcontroller
Interrupt programming with 8051 microcontroller
 
MICROCONTROLLER 8051- Architecture & Pin Configuration
MICROCONTROLLER 8051- Architecture & Pin Configuration MICROCONTROLLER 8051- Architecture & Pin Configuration
MICROCONTROLLER 8051- Architecture & Pin Configuration
 
Interrupt
InterruptInterrupt
Interrupt
 
INTRODUCTION TO MICROCONTROLLER
INTRODUCTION TO MICROCONTROLLERINTRODUCTION TO MICROCONTROLLER
INTRODUCTION TO MICROCONTROLLER
 
8051 programming skills using EMBEDDED C
8051 programming skills using EMBEDDED C8051 programming skills using EMBEDDED C
8051 programming skills using EMBEDDED C
 

Similar to The 8051 microcontroller

Similar to The 8051 microcontroller (20)

module-2.pptx
module-2.pptxmodule-2.pptx
module-2.pptx
 
Emb day2 8051
Emb day2 8051Emb day2 8051
Emb day2 8051
 
12 mt06ped008
12 mt06ped008 12 mt06ped008
12 mt06ped008
 
8085 alp programs
8085 alp programs8085 alp programs
8085 alp programs
 
8051 Microcontroller_module_4.1.pptx
8051 Microcontroller_module_4.1.pptx8051 Microcontroller_module_4.1.pptx
8051 Microcontroller_module_4.1.pptx
 
Unit 4.pptx
Unit 4.pptxUnit 4.pptx
Unit 4.pptx
 
Architecture of the Intel 8051 Microcontroller
Architecture of the Intel 8051 MicrocontrollerArchitecture of the Intel 8051 Microcontroller
Architecture of the Intel 8051 Microcontroller
 
intro to 8051 II.pptx
intro to 8051 II.pptxintro to 8051 II.pptx
intro to 8051 II.pptx
 
Question Bank microcontroller 8051
Question Bank microcontroller 8051Question Bank microcontroller 8051
Question Bank microcontroller 8051
 
8051 microcontroller
8051 microcontroller 8051 microcontroller
8051 microcontroller
 
Lec04
Lec04Lec04
Lec04
 
Lec04
Lec04Lec04
Lec04
 
Ashish microcontroller 8051
Ashish microcontroller 8051Ashish microcontroller 8051
Ashish microcontroller 8051
 
Microprocessors and microcontrollers
Microprocessors and microcontrollersMicroprocessors and microcontrollers
Microprocessors and microcontrollers
 
Unit 5
Unit 5Unit 5
Unit 5
 
B sc e5.2 mp unit 4 mc-8051
B sc e5.2 mp unit 4 mc-8051B sc e5.2 mp unit 4 mc-8051
B sc e5.2 mp unit 4 mc-8051
 
Microcontroller .pptx
Microcontroller .pptxMicrocontroller .pptx
Microcontroller .pptx
 
Micro controller(pratheesh)
Micro controller(pratheesh)Micro controller(pratheesh)
Micro controller(pratheesh)
 
Addressing Modes
Addressing ModesAddressing Modes
Addressing Modes
 
8051.pptx
8051.pptx8051.pptx
8051.pptx
 

Recently uploaded

Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsManeerUddin
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationRosabel UA
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 

Recently uploaded (20)

Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture hons
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translation
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 

The 8051 microcontroller

  • 2. INTRODUCTION TO PROGRAMMING: CPU CAN ONLY WORK IN BINARY,IT CAN DO SO AT VERY FAST SPEED.FOR HUMAN IT IS QUITE TEDIOUS AND SLOW TO DEAL WITH 0’S & 1’S IN ORDER TO PROGRAM THE COMPUTER .A PROGRAM THAT CONSISTS OF 0s AND 1s IS CALLED MACHINE LANGUAGE. ASSEMBLY LANGUAGE WERE DEVELOPED THAT PROVIDED MNEUMONICS FOR THE MACHINE CODE INSTRUCTION ,PLUS OTHER FEATURES
  • 3. THAT MADE PROGRAMMING FASTER AND . LESS PRONE TO ERROR. ASSEMBLY LANGUAGE PROGRAMS MUST BE TRANSLATED INTO MACHINE CODE BY A PROGRAM CALLED ASSEMBLER. TO PROGRAM IN ASSEMBLY LANGUAGE , THE PROGRAMMER MUST KNOW ALL THE REGISTERS OF THE CPU AND THE SIZE OF EACH ,AS WELL AS OTHER DETAILS.
  • 4. STRUCTURE OF ASSEMBLY LANGUAGE AN ASSEMBLY LANGUAGE CONSISTS OF FOUR FIELDS. “ [LABEL:] MNEUMONICS [OPERAND] [;COMMENT] ” HERE BRACKETS INDICATE THAT A FIELD IS OPTIONAL .
  • 5. EXAMPLE ORG OOH ;START AT LOCATION 0 MOV R5,#25H ;LOAD 25H INTO R5 MOV R6,#20H ; LOAD 20H INTO R6 MOV A ,#00H ; LOAD 00H INTO A ADD A ,R5 ; ADD CONTENTS OF R5 TO A ADD A ,R6 ; ADD CONTENTS OF R6 TO A ADD A ,#12H ; NOW A=A+ 12H HERE: SJMP HERE ; STAY IN THIS LOOP END
  • 6. STEPS TO CREATE A PROGRAM : EDITOR PROGRAM ASSEMBLER PROGRAM LINKER PROGRAM OH PROGRAM
  • 7. PROGRAM COUNTER: IT IS SPECIAL FUNCTION REGISTER WHICH GENERALLY TELL OUR CONTROLLER OR PROCESSOR ABOUT NEXT EXECUTING PROCESS.
  • 8. STACK POINTER: IT IS THE SPECIAL FUNCTION REGISTER WHICH IS USED TO STORE THE EXECUTED PROGRAM INSIDE YOUR STACK MEMORY. IT GENERALLY WORK ON THE PHENOMENA LIFO( LAST IN FIRST OUT).
  • 9. ASSEMBLER DIRECTIVES:  ORG(ORIGIN):USED TO INDICATE THE BEGINNING OF THE ADDERESS .  EQU(EQUATE): USED TO DEFINE A CONSTANT WITHOUT COPYING A MEMORY LOCATION.  END: IT INDICATES TO THE ASSEMBLER THE END OF SOURCE(ASM ) FILE.
  • 11. DEFINITION OF PSW REGISTER: THE PROGRAM STATUS WORD (PSW) REGISTER IS AN 8 - BIT REGISTER. IT IS ALSO REFFERED TO AS FLAG REGISTER.ALTHOUGH PSW REGISTER IS 8-BITS WIDE, OLY 6-BITS ARE USED BY 8051 . THE OTHER TWO ARE USER DEFINABLE FLAGS. FOUR OF FLAGS ARE CALLED CONDITIONAL FLAGS ,MEANS THAT THEY INDICATE SOME CONDITION
  • 12. CONTINUE THAT RESULT AFTER A INSTRUCTION IS EXECUTED . THESE FOUR ARE CY (CARRY) ,AC(AUXILIARY CARRY) , P ( PARITY) AND OV(OVERFLOW) .RS0 AND RS1 ARE USED TO CHANGE BANK REGISTORS . THE PSW .1 AND PSW.5 ARE GENERAL PURPOSE STATUS FLAG BITS AND CAN BE USED BY PROGRAMMER FOR ANY PURPOSE.
  • 13. 8051 REGISTER BANKS & STACK: THERE ARE 32 BYTES OF RAM ARE SET ASIDE FOR THE REGISTER BANKS AND STACK. THERE ARE 128 BYTES OF RAM ARE USED IN 8051 . THE 128 BYTES ARE ASSIGNED ADDRESSES 00 TO 7FH. FROM THESE 32 BYTES ARE USED FOR STACK AND REGISTER BANK .
  • 14. THERE ARE 4 REGISTER BANKS. THESE ARE [1] BANK(0) : ADDRESS FROM 00H TO 07H. [2] BANK(1) : ADDRESS FROM 08H TO 0FH. [3] BANK(1) : ADDRESS FROM 10H TO 17 H. [4] BANK(1) : ADDRESS FROM 18H TO 1FH. FROM 20H TO 2FH ARE ASSIGNED FOR BITADDERESSABLE RAM AND FROM 30H TO 7F H ARE FOR SCRATCH PAD RAM.
  • 16. 8051 REGISTER BANKS & THEIR RAM ADDERESSES
  • 17. STACK IN THE 8051: STACK SI THE SECTION OF RAM USED BY CPU TO STORE INFORMATION TEMPORA – RILY . THIS INFORMATION COULD BE DATA OR ADDERESS . THE CPU NEEDS THIS AREA FOR STORAGE SINCE THERE ARE ONLY A LIMITED NUMBER OF REGISTERS.
  • 18. PUSHING ONTO STACK: WE PUSH DATA ONTO STACK,THE STACK POINTER (SP) IS INCREMENTED BY ONE. • EXAMPLE: MOV R6,#25H MOV R1,#12H MOV R4,#0F3H PUSH 6 PUSH 1 PUSH 4
  • 19. SOLUTION: AFTER PUSH6 0B 0A 09 08 25 AFTER PUSH1 0B 0A 09 12 08 25 START SP=07 SP=08 SP=09 0B 0A 09 08 AFTER PUSH 4 0B 0A F3 09 12 08 25 SP=0A
  • 21. PROGRAMMING 8051 TIMERS: • THE 8051 HAS TWO TIMERS : TIMER0 TIMER1. • TIMER0 AND TIMER1 ARE 16-BITS WIDE. • THE 8051 HAS 8-BIT ARCHITECTURE , EACH IS ACCESSED BY TWO SEPARATE REGISTERS OF LOW BYTE AND HIGH BYTE.
  • 22. • TIMER0 REGISTERS: THE 16-BIT REGISTER OF TIMER0 IS ACCESSED AS LOW BYTE AND HIGH BYTE i.e TL0 & TH0. • TIMER1 REGISTERS: THE 16-BIT REGISTER OF TIMER0 IS ACCESSED AS LOW BYTE AND HIGH BYTE i.e TL1 & TH1. • TMOD (TIMER MODE) REGISTER: BOTH TIMERS 0 &1 USE SAME REGISTER TMOD.
  • 23. FIGURE OF TIMER0 AND TIMER1
  • 25. STEPS TO PROGRAM FOR MODE1 a) LOAD TMOD b) LOAD TH & TL c) START TIMER (SBIT TR) d) SET TI MER FLAG H:JNB TF,H e) CLR TR f) CLR TF g) RET
  • 26. STEPS TO PROGRAM FOR MODE2 a) LOAD TMOD REGISTER b) LOAD TIMER TYPE c) SET TIMER/START TI MER d) SET FLAG e) CLR FLAG f) RET
  • 27. COUNTERS TIMER / COUNTERS ARE USED TO GENERATE TIME DELAYS . THESE TIMERS CAN BE USED AS COUNTERS COUNTING EVENTS HAPPENING OUTSIDE THE 8051 . WHEN THE TIMER / COUNTER IS USED AS A TIMER, THE 8051’S CRYSTAL IS USED AS THE SOURCE OF FREQUENCY.
  • 28. . END