SlideShare a Scribd company logo
1 of 28
Classification of Instruction Set of
8051
• An instruction is a single operation of a processor defined by an instruction set
architecture.
• According to type of operations, the instruction set of 8051 is classified as follows
1) Data Transfer Instructions
2) Byte Level Logical Instructions
3) Arithmetic Instructions
4) Bit Level Instructions
5) Rotate and Swap instructions
6) Jump and CALL Instructions
Data Transfer Instructions
1) Instructions to Access External Data Memory.
2) Instructions to Access External ROM / Program Memory.
3) Data Transfer with Stack (PUSH and POP) instructions.
4) Data Exchange Instructions.
Data Transfer Instructions
• An immediate, direct, register and indirect addressing modes are used in different
MOVE instructions.
Ex:
MOV A, Rn
MOV A, direct
MOV A, @Ri
Instructions to Access External Data
Memory
Ex:
MOV X A, @Ri
Copy the contents of external address in Ri to A.
This copies the data from the 8-bit address in R0 to A.
MOVX A, @DPTR
This instruction copies data from the 16-bit address in DPTR to A.
MOVX @DPTR, A
This instruction copies data from A to the 16-bit address in DPTR.
Important Points to be remembered
in accessing external data memory
• All external data moves with external RAM involve the A register.
• While accessing external RAM, Rp can address 256 bytes and DPTR can
address 64Kbytes.
• MOVX instruction is used to access external RAM or I/O addresses.
Instructions to Access External
ROM/Program Memory
MOVC A, @A + DPTR
This copy the contents of the external ROM address formed by adding A and the
DPTR, to A.
MOVC A, @A + PC
This copy the contents of the external ROM address formed by adding A and the
PC, to A.
Important Points to be remembered
in accessing external Read only
Memory
• When PC is used to access external ROM, it is incremented by 1 before it is
added to A to form the physical address of external ROM.
• All external data moves with external ROM involve the A register.
• MOVC is used with internal or external ROM and can address 4K of internal
code or 64K of external code.
• The DPTR and the PC are not changed.
Data transfer with Stack (PUSH and
POP) Instruction
PUSH direct : Push onto stack
Ex:
PUSH B
This instruction increments the stack pointer by one and stores the contents of
register B to the internal RAM location addressed by the stack pointer (SP).
POP ACC
This instruction copies the contents of the internal RAM location addressed by
the stack pointer to the accumulator. Then the stack pointer is decrements by
one.
Important points to remember during
PUSH and POP
• When the SP contents become FFH, for the next PUSH, the SP rolls over to
00H.
• The top of the internal RAM, i,e. its end address is 7FH. So next PUSHes after
&FH result in errors.
• Generally the SP is set at address above the register banks.
• The PUSH and POP operations are used for the registers from the register
banks (bank 0 – bank 3), specify direct addresses within the instructions. Do not
use register name from register bank since the register name does not specify the
bank in use.
Data Exchange Instructions
• The Exchange instruction move data from source address to destination
address and vice versa.
Ex:
XCH A,Rn
XCH, direct
XCH A, @Ri
XCHD A, @Ri
Important points to remember in
Exchange Instructions
• All exchanges involve the A register.
•All exchanges take place internally within 8051.
• When XCHD A, @Ri instruction is executed, the upper nibble of A and the
upper nibble of the address in Ri do not change.
• Immediate addressing mode cannot be used in the exchange instructions.
Byte Level Logical Instructions
• The instructions ANL, ORL, and XRL perform the logical functions AND, OR,
and/or Exclusive – OR on the two byte variables indicated, leaving the result in
the first. No flags are affected.
• The byte – level logical operations use all four addressing modes for the source
of a data byte.
• Here, directly addressed bytes may be used as the destination with either the
accumulator or a constant as the source. These instructions are useful for
clearing (ANL), setting (ORL) or complementing (XRL) one or more bits in a
RAM, output ports, or control registers.
• ANL <dest-byte>, <src-byte>
ANL performs the bitwise logical-AND operation between the variables
indicated and stores the result in the destination variable. No flags are affected.
• ORL <dest-byte>, <src-byte>
ORL performs the bitwise logical-OR operation between the indicated
variables, storing the results in the destination byte. No flags are affected.
• XRL <dest-byte>, <src-byte>
XRL performs the bitwise logical Exclusive-OR operation between the indicated
variables, string the results in the destination. No flags are affected.
• CLR A : Clear Accumulator
The accumulator is cleared (all bits set on zero). No flags are affected.
• CPL A : Complement Accumulator
Each bit of the accumulator is logically complemented (one’s complement). Bit
which previously contained one are changed to a zero and vice – versa. No flags
affected.
Arithmetic Instructions
1) Incrementing and Decrementing
2) Addition
3) Subtraction
4) Multiplication and Division
5) Decimal Arithmetic
Incrementing and Decrementing
• Incrementing and Decrementing instructions allow additions and subtraction of
from a given number.
•These instructions not affect C, AC and OV flags.
EX:
INC A Increment Accumulator by 1
INC Rn Increment register
INC direct Increment direct byte
INC @Ri Increment Indirect RAM
INC DPTR Increment Data Pinter by 1
EX:
DEC A Decrement Accumulator by 1
DEC Rn Decrement register
DEC direct Decrement direct byte
DEC @Ri Decrement Indirect RAM
Addition
EX:
ADD A, Rn
ADD A, direct
ADD A, @Ri
ADD A, #data
ADDC A, Rn
ADDC A, direct
ADDC A, @ri
ADDC A, #data
Subtraction
SUBB A,<src-byte> : Subtract with borrow
SUBB subtract the indicated variable and the carry flag together from the
Accumulator, leaving the result in the Accumulator.
SUBB A, Rn
Subtract register from A with borrow
SUBB A, direct
Subtract direct byte from A with borrow
SUBB A, @Ri
Subtract indirect RAM from A with borrow
SUBB A, #data
Subtract immediate data from A with borrow
Multiplication and Division
MUL AB: Multiply
DIV AB : Divide
Decimal Arithmetic
DAA : Decimal – adjust Accumulator for addition
It adjust the eight-bit value in the accumulator resulting from the earlier addition
of two variables, to produce packed-BCD result.
Bit Level Logical Instructions
• Bit level manipulations are very convenient when it is necessary
to set or reset a particular bit in the internal RAM or SFRs [Special
Function Resister] .
• The internal RAM of 8051 from address 20H through 2FH is
both byte addressable and bit addressable.
• However, byte and bit address are different.
Byte Address in
HEX
Bit Address in
HEX
Byte Address in
HEX
Bit Address in
HEX
20 00-07 28 40-47
21 08-0F 29 48-4F
22 10-17 2A 50-57
23 18-1F 2B 58-5F
24 20-27 2C 60-67
25 28-2F 2D 68-6F
26 30-37 2E 70-77
27 38-3F 2F 78-7F
Bit and Byte Addresses of RAM
• Addresses of bit 0 and bit 7 of internal RAM byte address 20H
are 00H and 07H respectively.
• Using of the above mentioned table we can easily interpolate
addresses of bit 1 and bit 6 of internal RAM byte address 26H as
31H and 36H, respectively.
SFR Direct Address
in HEX
Bit Address in
HEX
A E0 E0-E7
B F0 F0-F7
IE A8 A8-AF
IP B8 B8-BF
P0 80 80-87
P1 90 90-97
P2 A0 A0-A7
P3 B0 B0-B7
PSW D0 D0-D7
TCON 88 88-8F
SCON 98 98-9F
Bit and Byte Addresses of SFR
Bit Level Operations
• CLR C : Clear Carry Flag
• CLR bit : Clear direct bit
• SETB C : Set Carry Flag
• SETB bit: Set direct bit
• CPL C : Complement Carry Flag
• CPL bit : Complement direct bit
• ANL C, <src-bit> : Logical AND for bit variables.
• ANL C, bit : AND direct bit to carry flag
• ANL C, /bit : AND complement of direct bit to Carry
• ORL C, <src-bit> : Logical – OR for bit variables.
• ORL C, bit : OR direct bit to Carry flag
•ORL C, /bit : OR complement of direct bit to Carry
• MOV <dest-bit>, <src-bit>
• MOV C, bit : Move direct bit to Carry flag
• Mover carry flag to direct bit
Rotate and Swap Instructions
• RL A : Rotate Accumulator Left.
The eight bits in the Accumulator are rotated one bit to the left. Bit 7 is rotated
into the bit 0 position. No flags are affected.
• RLC A : Rotate A Left through the Carry flag.
The eight bits in the Accumulator and the carry flag are together rotated one bit
to the left. Bit 7 moves into the carry flag; the original state of the carry flag
moves into the bit 0 position . No other flags are affected.
•RR A : Rotate Accumulator Right
The eight bits in the Accumulator are rotated one bit to the right. Bit 0 is rotated
into the bit 7 position. No flags are affected.
• RRC A : Rotate A right through Carry flag
The eight bits in the Accumulator and the carry flag are together rotated one bit
to the right. Bit 0 moves into the carry flag; the original value of the carry flag
moves into the bit 7 position. No other flags are affected.
• Swap A : Swap nibbles within the Accumulator
Swap A interchanges the low and high-order nibbles of the Accumulator. The
operation can also be thought of as a four – bit rotate instruction. No flags are
affected.

More Related Content

What's hot

8051 micro controllers Instruction set
8051 micro controllers Instruction set 8051 micro controllers Instruction set
8051 micro controllers Instruction set Nitin Ahire
 
Architecture of 8051
Architecture of 8051Architecture of 8051
Architecture of 8051hello_priti
 
Architecture of 16C6X
Architecture of 16C6XArchitecture of 16C6X
Architecture of 16C6Xv Kalairajan
 
Programmable Peripheral Interface 8255
 Programmable Peripheral Interface   8255 Programmable Peripheral Interface   8255
Programmable Peripheral Interface 8255Dr.P.Parandaman
 
8051 microcontroller features
8051 microcontroller features8051 microcontroller features
8051 microcontroller featuresTech_MX
 
8085 addressing modes
8085 addressing modes8085 addressing modes
8085 addressing modesVijay Kumar
 
Addressing modes of 8051
Addressing modes of 8051Addressing modes of 8051
Addressing modes of 8051SARITHA REDDY
 
PPT on 8085 Microprocessor
PPT on 8085 Microprocessor  PPT on 8085 Microprocessor
PPT on 8085 Microprocessor DebrajJana4
 
Interfacing 8255
Interfacing 8255Interfacing 8255
Interfacing 8255Anuja Bhakuni
 
PIC 16F877A by PARTHIBAN. S.
PIC 16F877A   by PARTHIBAN. S.PIC 16F877A   by PARTHIBAN. S.
PIC 16F877A by PARTHIBAN. S.parthi_arjun
 
Evolution Of Microprocessors
Evolution Of MicroprocessorsEvolution Of Microprocessors
Evolution Of Microprocessorsharinder
 
Introducion to MSP430 Microcontroller.pptx
Introducion to MSP430 Microcontroller.pptxIntroducion to MSP430 Microcontroller.pptx
Introducion to MSP430 Microcontroller.pptxDr.YNM
 
8051 Timers and Counters
8051 Timers and Counters8051 Timers and Counters
8051 Timers and CountersShreyans Pathak
 
8051 Microcontroller PPT's By Er. Swapnil Kaware
8051 Microcontroller PPT's By Er. Swapnil Kaware8051 Microcontroller PPT's By Er. Swapnil Kaware
8051 Microcontroller PPT's By Er. Swapnil KawareProf. Swapnil V. Kaware
 
Adc interfacing
Adc interfacingAdc interfacing
Adc interfacingMonica Gunjal
 
8051 Assembly Language Programming
8051 Assembly Language Programming8051 Assembly Language Programming
8051 Assembly Language ProgrammingRavikumar Tiwari
 

What's hot (20)

8255 PPI
8255 PPI8255 PPI
8255 PPI
 
8051 micro controllers Instruction set
8051 micro controllers Instruction set 8051 micro controllers Instruction set
8051 micro controllers Instruction set
 
Architecture of 8051
Architecture of 8051Architecture of 8051
Architecture of 8051
 
Architecture of 16C6X
Architecture of 16C6XArchitecture of 16C6X
Architecture of 16C6X
 
Programmable Peripheral Interface 8255
 Programmable Peripheral Interface   8255 Programmable Peripheral Interface   8255
Programmable Peripheral Interface 8255
 
8051 microcontroller features
8051 microcontroller features8051 microcontroller features
8051 microcontroller features
 
8085 addressing modes
8085 addressing modes8085 addressing modes
8085 addressing modes
 
8051 interrupts
8051 interrupts8051 interrupts
8051 interrupts
 
Addressing modes of 8051
Addressing modes of 8051Addressing modes of 8051
Addressing modes of 8051
 
PPT on 8085 Microprocessor
PPT on 8085 Microprocessor  PPT on 8085 Microprocessor
PPT on 8085 Microprocessor
 
Important questions
Important questionsImportant questions
Important questions
 
Interfacing 8255
Interfacing 8255Interfacing 8255
Interfacing 8255
 
PIC 16F877A by PARTHIBAN. S.
PIC 16F877A   by PARTHIBAN. S.PIC 16F877A   by PARTHIBAN. S.
PIC 16F877A by PARTHIBAN. S.
 
Evolution Of Microprocessors
Evolution Of MicroprocessorsEvolution Of Microprocessors
Evolution Of Microprocessors
 
Pin diagram 8085
Pin diagram 8085 Pin diagram 8085
Pin diagram 8085
 
Introducion to MSP430 Microcontroller.pptx
Introducion to MSP430 Microcontroller.pptxIntroducion to MSP430 Microcontroller.pptx
Introducion to MSP430 Microcontroller.pptx
 
8051 Timers and Counters
8051 Timers and Counters8051 Timers and Counters
8051 Timers and Counters
 
8051 Microcontroller PPT's By Er. Swapnil Kaware
8051 Microcontroller PPT's By Er. Swapnil Kaware8051 Microcontroller PPT's By Er. Swapnil Kaware
8051 Microcontroller PPT's By Er. Swapnil Kaware
 
Adc interfacing
Adc interfacingAdc interfacing
Adc interfacing
 
8051 Assembly Language Programming
8051 Assembly Language Programming8051 Assembly Language Programming
8051 Assembly Language Programming
 

Similar to 8051 instruction set

8051 microcontroller
8051 microcontroller 8051 microcontroller
8051 microcontroller nitugatkal
 
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 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 pptsSreenivas Hanumandla
 
lec3-8051microcontrollerarchitecture-230130044236-5c11a082.pptx
lec3-8051microcontrollerarchitecture-230130044236-5c11a082.pptxlec3-8051microcontrollerarchitecture-230130044236-5c11a082.pptx
lec3-8051microcontrollerarchitecture-230130044236-5c11a082.pptxMadavanR1
 
8085 Instructions.pdf
8085 Instructions.pdf8085 Instructions.pdf
8085 Instructions.pdfSaurabhPorwal14
 
module-2.pptx
module-2.pptxmodule-2.pptx
module-2.pptxAmbika Naik
 
Microprocessor system - summarize
Microprocessor system - summarizeMicroprocessor system - summarize
Microprocessor system - summarizeHisham Mat Hussin
 
5th unit Microprocessor 8085
5th unit Microprocessor 80855th unit Microprocessor 8085
5th unit Microprocessor 8085Mani Afranzio
 
8085 instructions and addressing modes
8085 instructions and addressing modes8085 instructions and addressing modes
8085 instructions and addressing modesSuchismita Paul
 
itft-Instruction set-of-8085
itft-Instruction set-of-8085itft-Instruction set-of-8085
itft-Instruction set-of-8085Shifali Sharma
 
Unit ii microcontrollers final
Unit ii microcontrollers finalUnit ii microcontrollers final
Unit ii microcontrollers finalSARITHA REDDY
 
Chapter 6 - Introduction to 8085 Instructions
Chapter 6 - Introduction to 8085 InstructionsChapter 6 - Introduction to 8085 Instructions
Chapter 6 - Introduction to 8085 Instructionscmkandemir
 
8085-instruction.ppt
8085-instruction.ppt8085-instruction.ppt
8085-instruction.pptSudeshnaDey22
 
MICROCONTROLLERS-module2 (7).pptx
MICROCONTROLLERS-module2 (7).pptxMICROCONTROLLERS-module2 (7).pptx
MICROCONTROLLERS-module2 (7).pptxAmoghR3
 
8085_Microprocessor(simar).ppt
8085_Microprocessor(simar).ppt8085_Microprocessor(simar).ppt
8085_Microprocessor(simar).pptKanikaJindal9
 
8051 MICROCONTROLLER ARCHITECTURE.pptx
 8051 MICROCONTROLLER ARCHITECTURE.pptx 8051 MICROCONTROLLER ARCHITECTURE.pptx
8051 MICROCONTROLLER ARCHITECTURE.pptxMemonaMemon1
 
Microcontroller 8051- soft.ppt
Microcontroller 8051- soft.pptMicrocontroller 8051- soft.ppt
Microcontroller 8051- soft.pptsteffydean
 

Similar to 8051 instruction set (20)

Addressing modes
Addressing modesAddressing modes
Addressing modes
 
8051 microcontroller
8051 microcontroller 8051 microcontroller
8051 microcontroller
 
Uc 2(vii)
Uc 2(vii)Uc 2(vii)
Uc 2(vii)
 
8051d
8051d8051d
8051d
 
Lecture 4 (8051 instruction set) rv01
Lecture 4 (8051 instruction set) rv01Lecture 4 (8051 instruction set) rv01
Lecture 4 (8051 instruction set) rv01
 
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
 
lec3-8051microcontrollerarchitecture-230130044236-5c11a082.pptx
lec3-8051microcontrollerarchitecture-230130044236-5c11a082.pptxlec3-8051microcontrollerarchitecture-230130044236-5c11a082.pptx
lec3-8051microcontrollerarchitecture-230130044236-5c11a082.pptx
 
8085 Instructions.pdf
8085 Instructions.pdf8085 Instructions.pdf
8085 Instructions.pdf
 
module-2.pptx
module-2.pptxmodule-2.pptx
module-2.pptx
 
Microprocessor system - summarize
Microprocessor system - summarizeMicroprocessor system - summarize
Microprocessor system - summarize
 
5th unit Microprocessor 8085
5th unit Microprocessor 80855th unit Microprocessor 8085
5th unit Microprocessor 8085
 
8085 instructions and addressing modes
8085 instructions and addressing modes8085 instructions and addressing modes
8085 instructions and addressing modes
 
itft-Instruction set-of-8085
itft-Instruction set-of-8085itft-Instruction set-of-8085
itft-Instruction set-of-8085
 
Unit ii microcontrollers final
Unit ii microcontrollers finalUnit ii microcontrollers final
Unit ii microcontrollers final
 
Chapter 6 - Introduction to 8085 Instructions
Chapter 6 - Introduction to 8085 InstructionsChapter 6 - Introduction to 8085 Instructions
Chapter 6 - Introduction to 8085 Instructions
 
8085-instruction.ppt
8085-instruction.ppt8085-instruction.ppt
8085-instruction.ppt
 
MICROCONTROLLERS-module2 (7).pptx
MICROCONTROLLERS-module2 (7).pptxMICROCONTROLLERS-module2 (7).pptx
MICROCONTROLLERS-module2 (7).pptx
 
8085_Microprocessor(simar).ppt
8085_Microprocessor(simar).ppt8085_Microprocessor(simar).ppt
8085_Microprocessor(simar).ppt
 
8051 MICROCONTROLLER ARCHITECTURE.pptx
 8051 MICROCONTROLLER ARCHITECTURE.pptx 8051 MICROCONTROLLER ARCHITECTURE.pptx
8051 MICROCONTROLLER ARCHITECTURE.pptx
 
Microcontroller 8051- soft.ppt
Microcontroller 8051- soft.pptMicrocontroller 8051- soft.ppt
Microcontroller 8051- soft.ppt
 

Recently uploaded

Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction managementMariconPadriquez1
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniquesugginaramesh
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 

Recently uploaded (20)

Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction management
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniques
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 

8051 instruction set

  • 1. Classification of Instruction Set of 8051 • An instruction is a single operation of a processor defined by an instruction set architecture. • According to type of operations, the instruction set of 8051 is classified as follows 1) Data Transfer Instructions 2) Byte Level Logical Instructions 3) Arithmetic Instructions 4) Bit Level Instructions 5) Rotate and Swap instructions 6) Jump and CALL Instructions
  • 2. Data Transfer Instructions 1) Instructions to Access External Data Memory. 2) Instructions to Access External ROM / Program Memory. 3) Data Transfer with Stack (PUSH and POP) instructions. 4) Data Exchange Instructions.
  • 3. Data Transfer Instructions • An immediate, direct, register and indirect addressing modes are used in different MOVE instructions. Ex: MOV A, Rn MOV A, direct MOV A, @Ri
  • 4. Instructions to Access External Data Memory Ex: MOV X A, @Ri Copy the contents of external address in Ri to A. This copies the data from the 8-bit address in R0 to A. MOVX A, @DPTR This instruction copies data from the 16-bit address in DPTR to A. MOVX @DPTR, A This instruction copies data from A to the 16-bit address in DPTR.
  • 5. Important Points to be remembered in accessing external data memory • All external data moves with external RAM involve the A register. • While accessing external RAM, Rp can address 256 bytes and DPTR can address 64Kbytes. • MOVX instruction is used to access external RAM or I/O addresses.
  • 6. Instructions to Access External ROM/Program Memory MOVC A, @A + DPTR This copy the contents of the external ROM address formed by adding A and the DPTR, to A. MOVC A, @A + PC This copy the contents of the external ROM address formed by adding A and the PC, to A.
  • 7. Important Points to be remembered in accessing external Read only Memory • When PC is used to access external ROM, it is incremented by 1 before it is added to A to form the physical address of external ROM. • All external data moves with external ROM involve the A register. • MOVC is used with internal or external ROM and can address 4K of internal code or 64K of external code. • The DPTR and the PC are not changed.
  • 8. Data transfer with Stack (PUSH and POP) Instruction PUSH direct : Push onto stack Ex: PUSH B This instruction increments the stack pointer by one and stores the contents of register B to the internal RAM location addressed by the stack pointer (SP). POP ACC This instruction copies the contents of the internal RAM location addressed by the stack pointer to the accumulator. Then the stack pointer is decrements by one.
  • 9.
  • 10. Important points to remember during PUSH and POP • When the SP contents become FFH, for the next PUSH, the SP rolls over to 00H. • The top of the internal RAM, i,e. its end address is 7FH. So next PUSHes after &FH result in errors. • Generally the SP is set at address above the register banks. • The PUSH and POP operations are used for the registers from the register banks (bank 0 – bank 3), specify direct addresses within the instructions. Do not use register name from register bank since the register name does not specify the bank in use.
  • 11. Data Exchange Instructions • The Exchange instruction move data from source address to destination address and vice versa. Ex: XCH A,Rn XCH, direct XCH A, @Ri XCHD A, @Ri
  • 12. Important points to remember in Exchange Instructions • All exchanges involve the A register. •All exchanges take place internally within 8051. • When XCHD A, @Ri instruction is executed, the upper nibble of A and the upper nibble of the address in Ri do not change. • Immediate addressing mode cannot be used in the exchange instructions.
  • 13. Byte Level Logical Instructions • The instructions ANL, ORL, and XRL perform the logical functions AND, OR, and/or Exclusive – OR on the two byte variables indicated, leaving the result in the first. No flags are affected. • The byte – level logical operations use all four addressing modes for the source of a data byte. • Here, directly addressed bytes may be used as the destination with either the accumulator or a constant as the source. These instructions are useful for clearing (ANL), setting (ORL) or complementing (XRL) one or more bits in a RAM, output ports, or control registers.
  • 14. • ANL <dest-byte>, <src-byte> ANL performs the bitwise logical-AND operation between the variables indicated and stores the result in the destination variable. No flags are affected. • ORL <dest-byte>, <src-byte> ORL performs the bitwise logical-OR operation between the indicated variables, storing the results in the destination byte. No flags are affected. • XRL <dest-byte>, <src-byte> XRL performs the bitwise logical Exclusive-OR operation between the indicated variables, string the results in the destination. No flags are affected. • CLR A : Clear Accumulator The accumulator is cleared (all bits set on zero). No flags are affected. • CPL A : Complement Accumulator Each bit of the accumulator is logically complemented (one’s complement). Bit which previously contained one are changed to a zero and vice – versa. No flags affected.
  • 15. Arithmetic Instructions 1) Incrementing and Decrementing 2) Addition 3) Subtraction 4) Multiplication and Division 5) Decimal Arithmetic
  • 16. Incrementing and Decrementing • Incrementing and Decrementing instructions allow additions and subtraction of from a given number. •These instructions not affect C, AC and OV flags. EX: INC A Increment Accumulator by 1 INC Rn Increment register INC direct Increment direct byte INC @Ri Increment Indirect RAM INC DPTR Increment Data Pinter by 1
  • 17. EX: DEC A Decrement Accumulator by 1 DEC Rn Decrement register DEC direct Decrement direct byte DEC @Ri Decrement Indirect RAM
  • 18. Addition EX: ADD A, Rn ADD A, direct ADD A, @Ri ADD A, #data ADDC A, Rn ADDC A, direct ADDC A, @ri ADDC A, #data
  • 19. Subtraction SUBB A,<src-byte> : Subtract with borrow SUBB subtract the indicated variable and the carry flag together from the Accumulator, leaving the result in the Accumulator. SUBB A, Rn Subtract register from A with borrow SUBB A, direct Subtract direct byte from A with borrow SUBB A, @Ri Subtract indirect RAM from A with borrow SUBB A, #data Subtract immediate data from A with borrow
  • 20. Multiplication and Division MUL AB: Multiply DIV AB : Divide Decimal Arithmetic DAA : Decimal – adjust Accumulator for addition It adjust the eight-bit value in the accumulator resulting from the earlier addition of two variables, to produce packed-BCD result.
  • 21. Bit Level Logical Instructions • Bit level manipulations are very convenient when it is necessary to set or reset a particular bit in the internal RAM or SFRs [Special Function Resister] . • The internal RAM of 8051 from address 20H through 2FH is both byte addressable and bit addressable. • However, byte and bit address are different.
  • 22. Byte Address in HEX Bit Address in HEX Byte Address in HEX Bit Address in HEX 20 00-07 28 40-47 21 08-0F 29 48-4F 22 10-17 2A 50-57 23 18-1F 2B 58-5F 24 20-27 2C 60-67 25 28-2F 2D 68-6F 26 30-37 2E 70-77 27 38-3F 2F 78-7F Bit and Byte Addresses of RAM
  • 23. • Addresses of bit 0 and bit 7 of internal RAM byte address 20H are 00H and 07H respectively. • Using of the above mentioned table we can easily interpolate addresses of bit 1 and bit 6 of internal RAM byte address 26H as 31H and 36H, respectively.
  • 24. SFR Direct Address in HEX Bit Address in HEX A E0 E0-E7 B F0 F0-F7 IE A8 A8-AF IP B8 B8-BF P0 80 80-87 P1 90 90-97 P2 A0 A0-A7 P3 B0 B0-B7 PSW D0 D0-D7 TCON 88 88-8F SCON 98 98-9F Bit and Byte Addresses of SFR
  • 25. Bit Level Operations • CLR C : Clear Carry Flag • CLR bit : Clear direct bit • SETB C : Set Carry Flag • SETB bit: Set direct bit • CPL C : Complement Carry Flag • CPL bit : Complement direct bit • ANL C, <src-bit> : Logical AND for bit variables. • ANL C, bit : AND direct bit to carry flag • ANL C, /bit : AND complement of direct bit to Carry
  • 26. • ORL C, <src-bit> : Logical – OR for bit variables. • ORL C, bit : OR direct bit to Carry flag •ORL C, /bit : OR complement of direct bit to Carry • MOV <dest-bit>, <src-bit> • MOV C, bit : Move direct bit to Carry flag • Mover carry flag to direct bit
  • 27. Rotate and Swap Instructions • RL A : Rotate Accumulator Left. The eight bits in the Accumulator are rotated one bit to the left. Bit 7 is rotated into the bit 0 position. No flags are affected. • RLC A : Rotate A Left through the Carry flag. The eight bits in the Accumulator and the carry flag are together rotated one bit to the left. Bit 7 moves into the carry flag; the original state of the carry flag moves into the bit 0 position . No other flags are affected.
  • 28. •RR A : Rotate Accumulator Right The eight bits in the Accumulator are rotated one bit to the right. Bit 0 is rotated into the bit 7 position. No flags are affected. • RRC A : Rotate A right through Carry flag The eight bits in the Accumulator and the carry flag are together rotated one bit to the right. Bit 0 moves into the carry flag; the original value of the carry flag moves into the bit 7 position. No other flags are affected. • Swap A : Swap nibbles within the Accumulator Swap A interchanges the low and high-order nibbles of the Accumulator. The operation can also be thought of as a four – bit rotate instruction. No flags are affected.