SlideShare une entreprise Scribd logo
1  sur  5
Dr. C. Saritha 
1 
8051 data types and directives 
The 8051 microcontroller has only one data type. It is 8 bits, and the size of each 
register is also 8 bits. It is the job of the programmer to break down data larger than 8 
bits (00 to FFH, or 0 to 255 in decimal) to be processed by the CPU. The data types 
used by the 8051 can be positive or negative. 
DB (define byte) 
The DB directive is the most widely used data directive in the assembler. It is used to 
define the 8-bit data. When DB is used to define data, the numbers can be in decimal, 
binary, hex, or ASCII formats. For decimal, the “D” after the decimal number is optional, 
but using “B” (binary) and “H” (hexadecimal) for the others is required. Regardless of 
which is used, the assembler will convert the numbers into hex. To indicate ASCII, 
simply place the characters in quotation marks (‘like this’). The assembler will assign the 
ASCII code for the numbers or characters automatically. The DB directive is the only 
directive that can be used to define ASCII strings larger than two characters; therefore, 
it should be used for all ASCII data definitions. Following are some DB examples: 
Either single or double quotes can be used around ASCII strings. This can be useful for 
strings, which contain a single quote such as “O’Leary”. DB is also used to allocate 
memory in byte-sized chunks. 
Assembler directives 
The following are some more widely used directives of the 8051.
Dr. C. Saritha 
2 
ORG (origin) 
The ORG directive is used to indicate the beginning of the address. The number that 
comes after ORG can be either in hex or in decimal. If the number is not followed by H, 
it is decimal and the assembler will convert it to hex. Some assemblers use “. ORG” 
(notice the dot) instead of “ORG” for the origin directive. 
EQU (equate) 
This is used to define a constant without occupying a memory location. The EQU 
directive does not set aside storage for a data item but associates a constant value with 
a data label so that when the label appears in the program, its constant value will be 
substituted for the label. The following uses EQU for the counter constant and then the 
constant is used to load the R3 register. 
When executing the instruction “MOV R3, #COUNT”, the register R3 will be loaded with 
the value 25 (notice the # sign). Assume that there is a constant (a fixed value) used in 
many different places in the program, and the programmer wants to change its value 
throughout. By the use of EQU, the programmer can change it once and the assembler 
will change all of its occurrences, rather than search the entire program trying to find 
every occurrence. 
END directive 
Another important pseudocode is the END directive. This indicates to the assembler the 
end of the source (asm) file. The END directive is the last line of an 8051 program, 
meaning that in the source code anything after the END directive is ignored by the 
assembler. Some assemblers use “. END” (notice the dot) instead of “END”.
Dr. C. Saritha 
I/O PROGRAMMING AND BIT MANIPULATION 
Different ways of accessing entire 8-bits of the I/O port 
In the following code the entire 8 bits of Port 1 are accessed. 
The above code toggles every bit of P1 continuously. Now we can rewrite the above 
code in a more efficient manner by accessing the port directly without going through the 
accumulator. 
We can write another variation the above code by using a technique called read-modify-write 
3 
feature. 
Read-Modify-Write feature : 
The ports in the 8051 can be accessed by the read-modify-write technique. This feature 
saves many lines of code by combining in a single instruction all three actions of 
(1) reading the port, (2) modifying its value, and (3) writing to the port. The following 
code first places 01010101 (binary) into port 1. Next, the instruction “XLR P1, #0FFH” 
performs an XOR logic operation on P1 with 1111 1111 (binary), and then writes the 
result back into P1.
Dr. C. Saritha 
4 
Single bit-addressability of I/O Ports 
Sometimes we need to access only 1 or 2 bits of the port instead of the entire 8 bits. A 
powerful feature of 8051 I/O ports is their capability to access individual bits of the port 
without altering the rest of the bits in that port. Of the four 8051 ports, we can access 
either the entire 8 bits or any single bit without altering the rest. When accessing a port 
in single-bit manner, we use the syntax “SETB X. Y” where X is the port number 0, 1, 2, 
or 3, and Y is the desired bit number from 0 to 7 for data bits D0 to D7. For example, 
“SETB P1. 5 sets high, bit 5 of port 1. Remember that D0 is the LSB and D7 is the MSB. 
For example, the following code toggles bit P1 .2 continuously. 
Notice that P1.2 is the third bit of P1, since the first bit is P1.0, the second bit is P1.1, 
and so on. Table 1 shows the bits of the 8051 I/O ports. This single-bit addressability of 
I/O ports is one of most powerful features of the 8051 microcontroller and is among the 
reasons that many designers choose the 8051 over other microcontrollers. 
Table 1: Single bit addressability of ports
Dr. C. Saritha 
5 
Checking an input bit 
The JNB (jump if no bit) and JB (jump if bit = 1) instructions are also widely used single-bit 
operations. They allow you to monitor a bit and make a decision depending on 
whether it is 0 or 1. Instructions JNB and JB can be used for any bits of I/O ports 0, 1,2, 
and 3, since all ports are bit-addressable. However, most of port 3 is used for interrupts 
and serial communication signals, and typically is not used for any I/O, either single-bit 
or byte-wise. 
Table 2 : Single bit instructions 
Instructions for reading an input port

Contenu connexe

Tendances

Addressing modes of 8051
Addressing modes of 8051Addressing modes of 8051
Addressing modes of 8051SARITHA REDDY
 
Assembly Language Programming Of 8085
Assembly Language Programming Of 8085Assembly Language Programming Of 8085
Assembly Language Programming Of 8085techbed
 
Microprocessor instructions
Microprocessor instructionsMicroprocessor instructions
Microprocessor instructionshepzijustin
 
Microprocessorlabmanual ee0310
Microprocessorlabmanual ee0310Microprocessorlabmanual ee0310
Microprocessorlabmanual ee0310DHEERAJ DHAKAR
 
Unit 5 assembly language programming
Unit 5   assembly language programmingUnit 5   assembly language programming
Unit 5 assembly language programmingKartik Sharma
 
Addressing modes 8085
Addressing modes 8085Addressing modes 8085
Addressing modes 8085ShivamSood22
 
Microprocessor lab
Microprocessor labMicroprocessor lab
Microprocessor labkpaulraj
 
4. Instruction Set Of MP 8085.pptx
4. Instruction Set Of MP 8085.pptx4. Instruction Set Of MP 8085.pptx
4. Instruction Set Of MP 8085.pptxISMT College
 
Logical instruction of 8085
Logical instruction of 8085Logical instruction of 8085
Logical instruction of 8085vishalgohel12195
 
Addresing mode and timing diagram
Addresing mode and timing diagramAddresing mode and timing diagram
Addresing mode and timing diagramtrivediau1
 
Addressing mode & data transfer instruction of 8085
Addressing mode & data transfer instruction of 8085Addressing mode & data transfer instruction of 8085
Addressing mode & data transfer instruction of 8085Chinmayee samal
 
8051 addressing modes
8051 addressing modes8051 addressing modes
8051 addressing modesVima Mali
 
8051 addressing modes & instruction set
8051 addressing modes & instruction set8051 addressing modes & instruction set
8051 addressing modes & instruction setManoj Babar
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutineAshim Saha
 
Stacks & subroutines 1
Stacks & subroutines 1Stacks & subroutines 1
Stacks & subroutines 1deval patel
 

Tendances (19)

Addressing modes of 8051
Addressing modes of 8051Addressing modes of 8051
Addressing modes of 8051
 
Assembly Language Programming Of 8085
Assembly Language Programming Of 8085Assembly Language Programming Of 8085
Assembly Language Programming Of 8085
 
Microprocessor instructions
Microprocessor instructionsMicroprocessor instructions
Microprocessor instructions
 
Microprocessorlabmanual ee0310
Microprocessorlabmanual ee0310Microprocessorlabmanual ee0310
Microprocessorlabmanual ee0310
 
Some advanced instructions of the 8085 microprocessors
Some advanced instructions of the 8085 microprocessorsSome advanced instructions of the 8085 microprocessors
Some advanced instructions of the 8085 microprocessors
 
Unit 5 assembly language programming
Unit 5   assembly language programmingUnit 5   assembly language programming
Unit 5 assembly language programming
 
Addressing modes 8085
Addressing modes 8085Addressing modes 8085
Addressing modes 8085
 
Microprocessor lab
Microprocessor labMicroprocessor lab
Microprocessor lab
 
4. Instruction Set Of MP 8085.pptx
4. Instruction Set Of MP 8085.pptx4. Instruction Set Of MP 8085.pptx
4. Instruction Set Of MP 8085.pptx
 
Uc 2(vii)
Uc 2(vii)Uc 2(vii)
Uc 2(vii)
 
Logical instruction of 8085
Logical instruction of 8085Logical instruction of 8085
Logical instruction of 8085
 
Addresing mode and timing diagram
Addresing mode and timing diagramAddresing mode and timing diagram
Addresing mode and timing diagram
 
Addressing mode & data transfer instruction of 8085
Addressing mode & data transfer instruction of 8085Addressing mode & data transfer instruction of 8085
Addressing mode & data transfer instruction of 8085
 
8051 addressing modes
8051 addressing modes8051 addressing modes
8051 addressing modes
 
8051d
8051d8051d
8051d
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
 
8051 addressing modes & instruction set
8051 addressing modes & instruction set8051 addressing modes & instruction set
8051 addressing modes & instruction set
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutine
 
Stacks & subroutines 1
Stacks & subroutines 1Stacks & subroutines 1
Stacks & subroutines 1
 

En vedette

Features of ReSharper
Features of ReSharperFeatures of ReSharper
Features of ReSharperPratik Patel
 
Newyear
NewyearNewyear
NewyearEHSS
 
1920 Antwerp Olympics.
1920 Antwerp Olympics.1920 Antwerp Olympics.
1920 Antwerp Olympics.SilviaaWay
 
1920 Antwerp Olympics.
1920 Antwerp Olympics.1920 Antwerp Olympics.
1920 Antwerp Olympics.SilviaaWay
 
Graphs in c language
Graphs in c languageGraphs in c language
Graphs in c languageSARITHA REDDY
 
BSc I year practicals
BSc I year practicalsBSc I year practicals
BSc I year practicalsSARITHA REDDY
 
Mos and cmos technology
Mos and cmos technologyMos and cmos technology
Mos and cmos technologySARITHA REDDY
 

En vedette (8)

Features of ReSharper
Features of ReSharperFeatures of ReSharper
Features of ReSharper
 
Newyear
NewyearNewyear
Newyear
 
1920 Antwerp Olympics.
1920 Antwerp Olympics.1920 Antwerp Olympics.
1920 Antwerp Olympics.
 
Schoolsport
SchoolsportSchoolsport
Schoolsport
 
1920 Antwerp Olympics.
1920 Antwerp Olympics.1920 Antwerp Olympics.
1920 Antwerp Olympics.
 
Graphs in c language
Graphs in c languageGraphs in c language
Graphs in c language
 
BSc I year practicals
BSc I year practicalsBSc I year practicals
BSc I year practicals
 
Mos and cmos technology
Mos and cmos technologyMos and cmos technology
Mos and cmos technology
 

Similaire à 8051 data type and directives

Microprocessor 8086
Microprocessor 8086Microprocessor 8086
Microprocessor 8086Waleed Khan
 
8051 microcontroller
8051 microcontroller 8051 microcontroller
8051 microcontroller nitugatkal
 
Pin Diagram and block diagram 8085 .pptx
Pin Diagram and block diagram 8085 .pptxPin Diagram and block diagram 8085 .pptx
Pin Diagram and block diagram 8085 .pptxYashArya40
 
Programming with 8085.pptx
Programming with 8085.pptxProgramming with 8085.pptx
Programming with 8085.pptxSachinKupade
 
Addressing Modes
Addressing ModesAddressing Modes
Addressing ModesMayank Garg
 
Unit -2 and 3 mekirirygiygyuguiguihiiqio
Unit -2 and 3 mekirirygiygyuguiguihiiqioUnit -2 and 3 mekirirygiygyuguiguihiiqio
Unit -2 and 3 mekirirygiygyuguiguihiiqioManikanta Reddy Sakam
 
Embedded Application : An Autonomous Robot or Line Follower Bot
Embedded Application : An Autonomous Robot or Line Follower BotEmbedded Application : An Autonomous Robot or Line Follower Bot
Embedded Application : An Autonomous Robot or Line Follower BotEr. Raju Bhardwaj
 
Lecture 4 (8051 instruction set) rv01
Lecture 4 (8051 instruction set) rv01Lecture 4 (8051 instruction set) rv01
Lecture 4 (8051 instruction set) rv01cairo university
 
Unit 2 Instruction set.pdf
Unit 2 Instruction set.pdfUnit 2 Instruction set.pdf
Unit 2 Instruction set.pdfHimanshuPant41
 
8085 microprocessor Architecture and Pin description
8085 microprocessor Architecture and Pin description 8085 microprocessor Architecture and Pin description
8085 microprocessor Architecture and Pin description Vijay Kumar
 
Intel® 80386 microprocessor registers
Intel® 80386 microprocessor registersIntel® 80386 microprocessor registers
Intel® 80386 microprocessor registersNeel Shah
 
Microprocessors and microcontrollers
Microprocessors and microcontrollersMicroprocessors and microcontrollers
Microprocessors and microcontrollersgomathy S
 
N_Asm Assembly registers (sol)
N_Asm Assembly registers (sol)N_Asm Assembly registers (sol)
N_Asm Assembly registers (sol)Selomon birhane
 
8085 microprocessor Architecture and pin description
8085 microprocessor Architecture and pin description 8085 microprocessor Architecture and pin description
8085 microprocessor Architecture and pin description Vijay Kumar
 

Similaire à 8051 data type and directives (20)

Microprocessor 8086
Microprocessor 8086Microprocessor 8086
Microprocessor 8086
 
8051 microcontroller
8051 microcontroller 8051 microcontroller
8051 microcontroller
 
12 mt06ped008
12 mt06ped008 12 mt06ped008
12 mt06ped008
 
Pin Diagram and block diagram 8085 .pptx
Pin Diagram and block diagram 8085 .pptxPin Diagram and block diagram 8085 .pptx
Pin Diagram and block diagram 8085 .pptx
 
Pdemodule 4
Pdemodule 4Pdemodule 4
Pdemodule 4
 
Programming with 8085.pptx
Programming with 8085.pptxProgramming with 8085.pptx
Programming with 8085.pptx
 
Addressing Modes
Addressing ModesAddressing Modes
Addressing Modes
 
Unit -2 and 3 mekirirygiygyuguiguihiiqio
Unit -2 and 3 mekirirygiygyuguiguihiiqioUnit -2 and 3 mekirirygiygyuguiguihiiqio
Unit -2 and 3 mekirirygiygyuguiguihiiqio
 
Embedded Application : An Autonomous Robot or Line Follower Bot
Embedded Application : An Autonomous Robot or Line Follower BotEmbedded Application : An Autonomous Robot or Line Follower Bot
Embedded Application : An Autonomous Robot or Line Follower Bot
 
Micro controller
Micro controllerMicro controller
Micro controller
 
8085 alp programs
8085 alp programs8085 alp programs
8085 alp programs
 
Lecture 4 (8051 instruction set) rv01
Lecture 4 (8051 instruction set) rv01Lecture 4 (8051 instruction set) rv01
Lecture 4 (8051 instruction set) rv01
 
Unit 2 Instruction set.pdf
Unit 2 Instruction set.pdfUnit 2 Instruction set.pdf
Unit 2 Instruction set.pdf
 
Mpmc
MpmcMpmc
Mpmc
 
8085 microprocessor Architecture and Pin description
8085 microprocessor Architecture and Pin description 8085 microprocessor Architecture and Pin description
8085 microprocessor Architecture and Pin description
 
Intel® 80386 microprocessor registers
Intel® 80386 microprocessor registersIntel® 80386 microprocessor registers
Intel® 80386 microprocessor registers
 
Microprocessors and microcontrollers
Microprocessors and microcontrollersMicroprocessors and microcontrollers
Microprocessors and microcontrollers
 
Blockdiagramof8085.ppt
Blockdiagramof8085.pptBlockdiagramof8085.ppt
Blockdiagramof8085.ppt
 
N_Asm Assembly registers (sol)
N_Asm Assembly registers (sol)N_Asm Assembly registers (sol)
N_Asm Assembly registers (sol)
 
8085 microprocessor Architecture and pin description
8085 microprocessor Architecture and pin description 8085 microprocessor Architecture and pin description
8085 microprocessor Architecture and pin description
 

Plus de SARITHA REDDY

Introduction to microprocessors notes
Introduction to microprocessors notesIntroduction to microprocessors notes
Introduction to microprocessors notesSARITHA REDDY
 
8051 data types and directives
8051 data types and directives8051 data types and directives
8051 data types and directivesSARITHA REDDY
 
Introduction to microprocessor notes
Introduction to microprocessor notesIntroduction to microprocessor notes
Introduction to microprocessor notesSARITHA REDDY
 
Decimation in time and frequency
Decimation in time and frequencyDecimation in time and frequency
Decimation in time and frequencySARITHA REDDY
 
I o ports and timers of 8051
I o ports and timers of 8051I o ports and timers of 8051
I o ports and timers of 8051SARITHA REDDY
 
Clampers and clippers
Clampers and clippersClampers and clippers
Clampers and clippersSARITHA REDDY
 
Electro Magnetic Wave Propagation
Electro Magnetic Wave PropagationElectro Magnetic Wave Propagation
Electro Magnetic Wave PropagationSARITHA REDDY
 
Satellite communications
Satellite communicationsSatellite communications
Satellite communicationsSARITHA REDDY
 
Electronics in daily life
Electronics in daily lifeElectronics in daily life
Electronics in daily lifeSARITHA REDDY
 
Combinational circuits
Combinational circuitsCombinational circuits
Combinational circuitsSARITHA REDDY
 
Applications of op amps
Applications of op ampsApplications of op amps
Applications of op ampsSARITHA REDDY
 
Digital logic gates and Boolean algebra
Digital logic gates and Boolean algebraDigital logic gates and Boolean algebra
Digital logic gates and Boolean algebraSARITHA REDDY
 
Embedded systems notes
Embedded systems notesEmbedded systems notes
Embedded systems notesSARITHA REDDY
 

Plus de SARITHA REDDY (18)

Introduction to microprocessors notes
Introduction to microprocessors notesIntroduction to microprocessors notes
Introduction to microprocessors notes
 
8051 data types and directives
8051 data types and directives8051 data types and directives
8051 data types and directives
 
Introduction to microprocessor notes
Introduction to microprocessor notesIntroduction to microprocessor notes
Introduction to microprocessor notes
 
Decimation in time and frequency
Decimation in time and frequencyDecimation in time and frequency
Decimation in time and frequency
 
RT linux
RT linuxRT linux
RT linux
 
I o ports and timers of 8051
I o ports and timers of 8051I o ports and timers of 8051
I o ports and timers of 8051
 
Logic families
Logic familiesLogic families
Logic families
 
Clampers and clippers
Clampers and clippersClampers and clippers
Clampers and clippers
 
Linked lists
Linked listsLinked lists
Linked lists
 
Arrays
ArraysArrays
Arrays
 
Electro Magnetic Wave Propagation
Electro Magnetic Wave PropagationElectro Magnetic Wave Propagation
Electro Magnetic Wave Propagation
 
Satellite communications
Satellite communicationsSatellite communications
Satellite communications
 
Electronics in daily life
Electronics in daily lifeElectronics in daily life
Electronics in daily life
 
Combinational circuits
Combinational circuitsCombinational circuits
Combinational circuits
 
Applications of op amps
Applications of op ampsApplications of op amps
Applications of op amps
 
Digital logic gates and Boolean algebra
Digital logic gates and Boolean algebraDigital logic gates and Boolean algebra
Digital logic gates and Boolean algebra
 
Question bank
Question bankQuestion bank
Question bank
 
Embedded systems notes
Embedded systems notesEmbedded systems notes
Embedded systems notes
 

Dernier

ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 

Dernier (20)

ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 

8051 data type and directives

  • 1. Dr. C. Saritha 1 8051 data types and directives The 8051 microcontroller has only one data type. It is 8 bits, and the size of each register is also 8 bits. It is the job of the programmer to break down data larger than 8 bits (00 to FFH, or 0 to 255 in decimal) to be processed by the CPU. The data types used by the 8051 can be positive or negative. DB (define byte) The DB directive is the most widely used data directive in the assembler. It is used to define the 8-bit data. When DB is used to define data, the numbers can be in decimal, binary, hex, or ASCII formats. For decimal, the “D” after the decimal number is optional, but using “B” (binary) and “H” (hexadecimal) for the others is required. Regardless of which is used, the assembler will convert the numbers into hex. To indicate ASCII, simply place the characters in quotation marks (‘like this’). The assembler will assign the ASCII code for the numbers or characters automatically. The DB directive is the only directive that can be used to define ASCII strings larger than two characters; therefore, it should be used for all ASCII data definitions. Following are some DB examples: Either single or double quotes can be used around ASCII strings. This can be useful for strings, which contain a single quote such as “O’Leary”. DB is also used to allocate memory in byte-sized chunks. Assembler directives The following are some more widely used directives of the 8051.
  • 2. Dr. C. Saritha 2 ORG (origin) The ORG directive is used to indicate the beginning of the address. The number that comes after ORG can be either in hex or in decimal. If the number is not followed by H, it is decimal and the assembler will convert it to hex. Some assemblers use “. ORG” (notice the dot) instead of “ORG” for the origin directive. EQU (equate) This is used to define a constant without occupying a memory location. The EQU directive does not set aside storage for a data item but associates a constant value with a data label so that when the label appears in the program, its constant value will be substituted for the label. The following uses EQU for the counter constant and then the constant is used to load the R3 register. When executing the instruction “MOV R3, #COUNT”, the register R3 will be loaded with the value 25 (notice the # sign). Assume that there is a constant (a fixed value) used in many different places in the program, and the programmer wants to change its value throughout. By the use of EQU, the programmer can change it once and the assembler will change all of its occurrences, rather than search the entire program trying to find every occurrence. END directive Another important pseudocode is the END directive. This indicates to the assembler the end of the source (asm) file. The END directive is the last line of an 8051 program, meaning that in the source code anything after the END directive is ignored by the assembler. Some assemblers use “. END” (notice the dot) instead of “END”.
  • 3. Dr. C. Saritha I/O PROGRAMMING AND BIT MANIPULATION Different ways of accessing entire 8-bits of the I/O port In the following code the entire 8 bits of Port 1 are accessed. The above code toggles every bit of P1 continuously. Now we can rewrite the above code in a more efficient manner by accessing the port directly without going through the accumulator. We can write another variation the above code by using a technique called read-modify-write 3 feature. Read-Modify-Write feature : The ports in the 8051 can be accessed by the read-modify-write technique. This feature saves many lines of code by combining in a single instruction all three actions of (1) reading the port, (2) modifying its value, and (3) writing to the port. The following code first places 01010101 (binary) into port 1. Next, the instruction “XLR P1, #0FFH” performs an XOR logic operation on P1 with 1111 1111 (binary), and then writes the result back into P1.
  • 4. Dr. C. Saritha 4 Single bit-addressability of I/O Ports Sometimes we need to access only 1 or 2 bits of the port instead of the entire 8 bits. A powerful feature of 8051 I/O ports is their capability to access individual bits of the port without altering the rest of the bits in that port. Of the four 8051 ports, we can access either the entire 8 bits or any single bit without altering the rest. When accessing a port in single-bit manner, we use the syntax “SETB X. Y” where X is the port number 0, 1, 2, or 3, and Y is the desired bit number from 0 to 7 for data bits D0 to D7. For example, “SETB P1. 5 sets high, bit 5 of port 1. Remember that D0 is the LSB and D7 is the MSB. For example, the following code toggles bit P1 .2 continuously. Notice that P1.2 is the third bit of P1, since the first bit is P1.0, the second bit is P1.1, and so on. Table 1 shows the bits of the 8051 I/O ports. This single-bit addressability of I/O ports is one of most powerful features of the 8051 microcontroller and is among the reasons that many designers choose the 8051 over other microcontrollers. Table 1: Single bit addressability of ports
  • 5. Dr. C. Saritha 5 Checking an input bit The JNB (jump if no bit) and JB (jump if bit = 1) instructions are also widely used single-bit operations. They allow you to monitor a bit and make a decision depending on whether it is 0 or 1. Instructions JNB and JB can be used for any bits of I/O ports 0, 1,2, and 3, since all ports are bit-addressable. However, most of port 3 is used for interrupts and serial communication signals, and typically is not used for any I/O, either single-bit or byte-wise. Table 2 : Single bit instructions Instructions for reading an input port