SlideShare a Scribd company logo
Friday, October 28, 2022
Addressing Modes
• Immediate
• Register
• Direct
• Register Indirect
• Indexed
The way in which the instruction is specified.
Friday, October 28, 2022
1. Immediate Addressing Mode
• Immediate Data is specified in the instruction itself
• The source operand is a constant number
• Values can be loaded directly into A, B, R0-R7
• To show it is an immediate value precede with a # sign
• Egs:
MOV A,#65H
MOV R3,#65H
MOV DPTR,#2343H
2. Register Addressing Mode
• It involves the use of registers to hold the data to be manipulated
• Register to register moves occurs between A and R0-R7
• One of the operand is accumulator
• Eg: MOV R0,A // copy the contents of A to R0
• MOV R1,A
• INVALID MOV R1,R2 - MOV A,R2
MOV R1,A
Friday, October 28, 2022
3. Direct Addressing Mode
In this addressing mode, data is in the RAM location whose address is
known and this address is directly given as part of the instruction
MOV R0, 40H // copy data from RAM location 40h to register R0
MOV 56H, A // copy value in A to RAM location 56h
MOV A,12H // copy data from RAM location 12h to A
Friday, October 28, 2022
4. Register Indirect Addressing Mode
• It uses a register to hold the actual address that will be used in the
data move
• Register itself is not the address but the content in the register
• Uses register R0 and R1 (called as data pointers)
• It holds the address of RAM locations from 00h to 7Fh
• For indirect addressing @ is used
eg: MOV A,@R0
copy the contents of the address specified in R0 to Accumulator
MOV@R1,A -----copy A to the address in R1
MOV @R0,80H ---Copy the contents of RAM location 80h to the
address in R0
Friday, October 28, 2022
Indexed Addressing Mode And On-Chip ROM Access
• This mode is widely used in accessing data elements of look-up table
entries located in the program (code) space ROM at the 8051
MOVC A,@A+DPTR
A= content of address A +DPTR from ROM
Note:
Because the data elements are stored in the program (code ) space
ROM of the 8051, it uses the instruction MOVC instead of MOV. The
“C” means code.
INSTRUCTION SET OF 8051
MARY CATHERINE
DEPT OF ECE
SSET
TYPES OF INSTRUCTIONS
DATA TRNSFER INSTRUCTIONS
ARITHMETIC INSTRUCTIONS
LOGICAL INSTRUCTIONL(S
JUMP AND CALL INSTRUCTIONS
BIT LEVEL (BOOLEAN) INSTRUCTIONS
DATA TRANSFER INSTRUCTIONS
 MOV A, Rn  register
 MOV A, direct <- content of direct address
 MOV A,@Ri <- content of address in Ri
 MOV A,#data <- immediate data
DATA TRANSFER INSTRUCTIONS
 MOV Rn,A  Accumulator
 MOV Rn, direct <- content of direct address
 MOV direct,A <- accumulator
 MOV Rn,#data <- immediate data
 MOV direct,Rn <- contents of register
 MOV direct,direct <- contents of direct address
DATA TRANSFER INSTRUCTIONS
MOV direct ,@Ri <- contents of address in Ri
MOV drect, #data <- immediate data to direct
MOV @Ri ,A <- acc to address in Ri
MOV @Ri, direct <- contents of direct address
to address in Ri
MOV @Ri,#data <- immediate data to
address in Ri
DATA TRANSFER INSTRUCTIONS
MOV DPTR,#16 bit data <- load data pointer with 16 bit
constant
MOVC A,@A+DPTR <- code byte at ROM address
formed by(A+DPTR)
MOVC A,@A+PC <- code byte at (A+PC)
It is an indirect addressing mode where the number in register A
is added to the pointing register to form address in ROM where
the desired data is to be found
DATA TRANSFER INSTRUCTIONS
MOVX A,@Ri <- contents of ext. address
Ri to accumulator
MOVX A,@DPTR <- contents of ext. address in
DPTR to accumulator
MOVX @Ri, A <- accumulator to ext. add
in Ri
MOVX @DPTR,A <- accumulator to
ext.address in DPTR
Data exchanges
Exchange instructions actually move data from Source to Data /
data to source
XCH A, Rn <exchange data bytes between A and Rn
XCH A, direct <exchange data bytes between A and address
XCH A, @Rn <exchange data bytes between A& content of address in Rn
XCHD A, @Rp <exchange lower nibbles between A and address in Rp
ARITHMETIC INSTRUCTIONS
ADD A, Rn <- add register to acc
ADD A,direct <- add contents of address to A
ADD A,@Ri <- add contents of address in Ri
to A
ADD A, #data <- add immediate data to A
ARITHMETIC INSTRUCTIONS
ADDC A, Rn <- add register to acc with
carry
ADDC A,direct <- add contents of address to
A with carry
ADDC A,@Ri <- add contents of address in
Ri to A with carry
ADDC A, #data <- add immediate data to A
with carry
ARITHMETIC INSTRUCTIONS
SUBB A, Rn <- subtract register from acc with
borrow
SUBB A,direct <-subtract contents of address
from A with borrow
SUBB A,@Ri <-subtract contents of address
in Ri from A with borrow
SUBB A, #data <- subtract immediate data
from A with borrow
ARITHMETIC INSTRUCTIONS
MUL AB <- multiply A & B; B:A
DIV AB <- divide A by B; quo in A,Rem: B
DAA <-decimal adjust after addition
for BCD Addition
ARITHMETIC INSTRUCTIONS
INC A <- increment accumulator
INC Rn <- increment register by 1
INC direct <- increment contents of address
INC @Ri <- increment contents of address in Ri
INC DPTR <- increment Data pointer
ARITHMETIC INSTRUCTIONS
DEC A <- decrement accumulator
DEC Rn <- decrement register by 1
DEC direct <- decrement contents of address
DEC @Ri <- decrement contents of address in
Ri
LOGICAL INSTRUCTIONS
 ANL A,Rn <- AND register to accumulator
 ANL A, direct <- AND contents of address to A
 ANL A,@Ri <- AND contents of address in Ri
to accumulator
 ANL A,#data <- AND immediate data to
accumulator
 ANL direct,A <- AND accumulator to direct
byte
 ANL direct,#data <-AND immediate data to direct byte
LOGICAL INSTRUCTIONS
 ORL A,Rn <- OR register to accumulator
 ORL A, direct <- OR contents of address to A
 ORL A,@Ri <- OR contents of address in Ri to
accumulator
 ORL A,#data <- OR immediate data to accumulator
 ORL direct,A <- OR accumulator to direct byte
 ORL direct,#data <-AND immediate data to direct byte
LOGICAL INSTRUCTIONS
 XRL A,Rn <- XOR register to accumulator
 XRL A, direct <- XOR contents of address to A
 XRL A,@Ri <- XOR contents of address in Ri to
accumulator
 XRL A,#data <- XOR immediate data to accumulator
 XRL direct,A <- XOR accumulator to direct byte
 XRL direct,#data <- XOR immediate data to direct byte
LOGICAL INSTRUCTIONS
CLR A <- clear accumulator
CPL A <- complement accumulator
RLA <- rotate accumulator left
RLC A <- rotate acc. left through carry
RRA <- rotate accumulator right
RRC A <- rotate acc. Right through carry
SWAP A <- swap nibbles within accumulator
ROTATE INSTRUCTIONS
BOOLEAN INSTRUCTIONS(BIT LEVEL)
CLR C <- clear carry
CLR Bit <- clear direct bit
SETB C <- set carry
SETB Bit <- set direct bit
CPL C <- complement carry
CPL bit <- complement direct bit
BOOLEAN INSTRUCTIONS(BIT LEVEL)
ANL C,bit <- AND carry to direct bit
ANL C,/Bit <- AND carry to complement of bit
ORL C,Bit <- OR carry to direct bit
ORL C,/Bit <- OR carry to complement of bit
MOV C,Bit <- move direct bit to carry
MOV Bit,C <- move carry to direct bit
BOOLEAN INSTRUCTIONS(BIT LEVEL)
JC label <- jump if carry set to label
JNC label <- jump if carry=0 to label
JB bit , label <- jump if bit is set to label
JNB Bit, label <- jump if bit not set to label
JBC Bit, label <-jump if bit set to label and clear bit
PROGRAM BRANCHING ISTRUCTIONS
JUMP AND CALL INSTRUCTIONS
JUMPS ARE OF 3 TYPES
1. SHORT JUMP (SJMP)
2. LONG JUMP(LJMP)
3. ABSOLUTE JUMP(AJMP)
TYPES OF JUMPS
SHORT JUMP(SJMP)
TRANSFERS CONTROL WITHIN 256 BYTES
-128 TO +127 BYTES
EG: SJMP Label
TYPES OF JUMPS
ABSOLUTE JUMP(AJMP)
TRANSFERS CONTROL WITHIN 2KB
EG: AJMP 11 Bit address
TYPES OF JUMPS
LONG JUMP(LJMP)
TRANSFERS CONTROL WITHIN 64KB
EG: LJMP 16 Bit address
CALL INSTRUCTIONS
TYPES OF CALL
ABSOLUTE CALL(ACALL)
LONG CALL(LCALL)
CALL INSTRUCTIONS
ACALL 11 BIT ADDRESS
CALLING A SUBROUTINE WITHIN 2KB OF PROGRAM MEMORY
CALL INSTRUCTIONS
LCALL 16 BIT ADDRESS
CALLING A SUBROUTINE WITHIN 64KB OF PROGRAM MEMORY
CONDITIONAL JUMPS
JZ LABEL ; JUMP IF ACCUMULATOR IS ZERO
JNZ LABEL ;JUMP IF ACCUMULATOR IS NON
ZERO
DJNZ Rn , label ; decrement the register and jump
to label if non zero
DJNZ direct, label ; decrement direct byte and jump
to label if non zero
CJNE INSTRUCTION
CJNE INSTRUCTION COMPARES THE FIRST OPERAND WITH 2ND
OPERAND AND PERFORMS BRANCH OPERATION IF NOT
EQUAL
CJNE INSTRUCTION
CJNE A, direct , label ; compare direct byte to acc &
jump if not equal
CJNE A, #data , label ; compare immediate data to acc
& jump if not equal
 CJNE Rn, #data , label ;compare Rn with immediate data
 CJNE @Ri , #data, label; compare imm data with indirect
byte and jump if not equal
RETURN INSTRUCTIONS
RET - RETURN FROM SUBROUTINE
RETI – RETURN FROM INTERRUPT
NOP – NO OPERATION
PUSH & POP instructions
 PUSH & POP opcodes specifies the direct address of the data
 It is a data move instruction from stack to the specified address
 Register associated is Stack pointer – contains the internal RAM address where the data will be
pushed
PUSH & POP instructions
PUSH address :
Increment SP by 1 ; SP = SP+1
Copy the address specified in the instruction to the internal
RAM address in SP register
By default SP is set to 07 H (R7 of bank 0)
Eg: PUSH 40H
It would push the data to the address 08H
POP instruction
POP address :
Copy the data from internal RAM address contained in SP to
address specified in the instruction
decrement SP by 1 ; SP = SP-1
E.g.: POP 40H
It would pop the data from the address 08H to the address 40H
PUSH & POP
SP reaches FF it rolls over to 00H
RAM ends at address 7F H , PUSH es above 7F H result in errors
PROGRAMS – ADDITION WITH CARRY
ORG 00H // origin
MOV R3, #00H // carry register initialised to 0
MOV A,40H // copy 1ST number from 40H to A
ADD A,41H // add a and content of 41H
JNC L1 // jump if no carry to label L1
INC R3 // Increment carry register by 1
L1: MOV 60H, A // copy result (sum) to address 60H
MOV 61H,R3 //copy result (carry) to address 61H
END // program ends
PROGRAMS – SUBTRACTION WITH BORROW
ORG 00H // origin
MOV R3, #00H // carry register initialised to 0
MOV A,40H // copy 1ST number from 40H to A
SUBB A,41H // Subtract a and content of 41H
JNC L1 // jump if no carry to label L1
INC R3 // Increment carry register by 1
CPL A // take 2’s Complement of the no
ADD A, #01H (1’s complement +1)
L1: MOV 60H, A // copy result to address 60H
MOV 61H,R3 //copy result (borrow) to address 61H
END // program ends
PROGRAMS – MULTIPLICATION OF TWO 8 BIT
NOS
ORG 00H // origin
MOV A,40H // copy 1ST number from 40H to A
MOV B,41H // Copy content of 41H to B
MUL AB // multiply A and B
MOV 60H, A // copy result(LSB) to address 60H
MOV 61H,B //copy result (MSB) to address 61H
END // program ends
PROGRAMS – DIVISION OF TWO 8 BIT NOS
ORG 00H // origin
MOV A,40H // copy 1ST number from 40H to A
MOV B,41H // Copy content of 41H to B
DIV AB // divide A by B
MOV 60H, A // copy result(quotient) to address 60H
MOV 61H,B //copy result (remainder) to address 61H
END // program ends
PROGRAMS – ADDITION OF N NOS WITH
CARRY
ORG 00H // origin
MOV R3, #00H // carry register initialised to 0
MOV R2, 40H // R2 is the count register, copy contents of 40h TO R2
MOV R0,#41H // pointing array location to 41H
MOV A,@R0 //copy contents of address in R0 to A
INC R0 // increment R0
L2: ADD A, @R0 // add a and content of address specified in R0
JNC L1 // jump if no carry to label L1
INC R3 // Increment carry register by 1
L1: INC R0 //increment R0 by 1
DJNZ R2,L2 // decrement and jump if nonzero R2, to label L2
MOV 60H, A // copy result (sum) to address 60H
MOV 61H,R3 //copy result (carry) to address 61H

More Related Content

Similar to 8051 instruction_set.ppt

Addressing modes
Addressing modesAddressing modes
Addressing modes
karthiga selvaraju
 
Microcontroller 8051 addressing modes
Microcontroller 8051 addressing modes Microcontroller 8051 addressing modes
Microcontroller 8051 addressing modes
UshaRani289
 
Unit ii microcontrollers final
Unit ii microcontrollers finalUnit ii microcontrollers final
Unit ii microcontrollers final
SARITHA REDDY
 
Microcontroller instruction set
Microcontroller instruction setMicrocontroller instruction set
Microcontroller instruction set
Shail Modi
 
UNIT 2 ERTS.ppt
UNIT 2 ERTS.pptUNIT 2 ERTS.ppt
UNIT 2 ERTS.ppt
CHENAGANIMEGHANA
 
Section 1 8051 microcontroller instruction set
Section 1 8051 microcontroller instruction setSection 1 8051 microcontroller instruction set
Section 1 8051 microcontroller instruction set
nueng-kk
 
8051 addressing modes &amp; instruction set
8051 addressing modes &amp; instruction set8051 addressing modes &amp; instruction set
8051 addressing modes &amp; instruction set
Manoj Babar
 
The 8051 microcontroller
The 8051 microcontrollerThe 8051 microcontroller
The 8051 microcontroller
PallaviHailkar
 
addressing-mode-of-8051.pdf
addressing-mode-of-8051.pdfaddressing-mode-of-8051.pdf
addressing-mode-of-8051.pdf
DhilibanSwaminathan
 
8051 addressing modes
8051 addressing modes8051 addressing modes
8051 addressing modes
sb108ec
 
Instruction types
Instruction typesInstruction types
Instruction types
JyotiprakashMishra18
 
instructions set of 8051.pdf
instructions set of 8051.pdfinstructions set of 8051.pdf
instructions set of 8051.pdf
DhilibanSwaminathan
 
microprocessor and microcontroller notes ppt
microprocessor and microcontroller notes pptmicroprocessor and microcontroller notes ppt
microprocessor and microcontroller notes ppt
mananjain543
 
8051 addressing modes
8051 addressing modes8051 addressing modes
8051 addressing modes
Vima Mali
 
8051 instruction set
8051 instruction set8051 instruction set
8051 instruction set
prakash y
 
13229286.ppt
13229286.ppt13229286.ppt
13229286.ppt
DrRajalakshmiM
 
addressingmodes8051.ppt
addressingmodes8051.pptaddressingmodes8051.ppt
addressingmodes8051.ppt
DhilibanSwaminathan
 
8051 microcontroller notes continuous
8051 microcontroller notes continuous 8051 microcontroller notes continuous
8051 microcontroller notes continuous
THANDAIAH PRABU
 
Addressing modes of 8051
Addressing modes of 8051Addressing modes of 8051
Addressing modes of 8051
SARITHA REDDY
 
Microcontroller 8051- soft.ppt
Microcontroller 8051- soft.pptMicrocontroller 8051- soft.ppt
Microcontroller 8051- soft.ppt
steffydean
 

Similar to 8051 instruction_set.ppt (20)

Addressing modes
Addressing modesAddressing modes
Addressing modes
 
Microcontroller 8051 addressing modes
Microcontroller 8051 addressing modes Microcontroller 8051 addressing modes
Microcontroller 8051 addressing modes
 
Unit ii microcontrollers final
Unit ii microcontrollers finalUnit ii microcontrollers final
Unit ii microcontrollers final
 
Microcontroller instruction set
Microcontroller instruction setMicrocontroller instruction set
Microcontroller instruction set
 
UNIT 2 ERTS.ppt
UNIT 2 ERTS.pptUNIT 2 ERTS.ppt
UNIT 2 ERTS.ppt
 
Section 1 8051 microcontroller instruction set
Section 1 8051 microcontroller instruction setSection 1 8051 microcontroller instruction set
Section 1 8051 microcontroller instruction set
 
8051 addressing modes &amp; instruction set
8051 addressing modes &amp; instruction set8051 addressing modes &amp; instruction set
8051 addressing modes &amp; instruction set
 
The 8051 microcontroller
The 8051 microcontrollerThe 8051 microcontroller
The 8051 microcontroller
 
addressing-mode-of-8051.pdf
addressing-mode-of-8051.pdfaddressing-mode-of-8051.pdf
addressing-mode-of-8051.pdf
 
8051 addressing modes
8051 addressing modes8051 addressing modes
8051 addressing modes
 
Instruction types
Instruction typesInstruction types
Instruction types
 
instructions set of 8051.pdf
instructions set of 8051.pdfinstructions set of 8051.pdf
instructions set of 8051.pdf
 
microprocessor and microcontroller notes ppt
microprocessor and microcontroller notes pptmicroprocessor and microcontroller notes ppt
microprocessor and microcontroller notes ppt
 
8051 addressing modes
8051 addressing modes8051 addressing modes
8051 addressing modes
 
8051 instruction set
8051 instruction set8051 instruction set
8051 instruction set
 
13229286.ppt
13229286.ppt13229286.ppt
13229286.ppt
 
addressingmodes8051.ppt
addressingmodes8051.pptaddressingmodes8051.ppt
addressingmodes8051.ppt
 
8051 microcontroller notes continuous
8051 microcontroller notes continuous 8051 microcontroller notes continuous
8051 microcontroller notes continuous
 
Addressing modes of 8051
Addressing modes of 8051Addressing modes of 8051
Addressing modes of 8051
 
Microcontroller 8051- soft.ppt
Microcontroller 8051- soft.pptMicrocontroller 8051- soft.ppt
Microcontroller 8051- soft.ppt
 

Recently uploaded

Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
KrishnaveniKrishnara1
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
mamunhossenbd75
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
171ticu
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
sachin chaurasia
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
Rahul
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
IJNSA Journal
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
jpsjournal1
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
wisnuprabawa3
 
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEMTIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
HODECEDSIET
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
VICTOR MAESTRE RAMIREZ
 
Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
mahammadsalmanmech
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
Casting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdfCasting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdf
zubairahmad848137
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
kandramariana6
 

Recently uploaded (20)

Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
 
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEMTIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
 
Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
Casting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdfCasting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdf
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
 

8051 instruction_set.ppt

  • 1. Friday, October 28, 2022 Addressing Modes • Immediate • Register • Direct • Register Indirect • Indexed The way in which the instruction is specified.
  • 2. Friday, October 28, 2022 1. Immediate Addressing Mode • Immediate Data is specified in the instruction itself • The source operand is a constant number • Values can be loaded directly into A, B, R0-R7 • To show it is an immediate value precede with a # sign • Egs: MOV A,#65H MOV R3,#65H MOV DPTR,#2343H
  • 3. 2. Register Addressing Mode • It involves the use of registers to hold the data to be manipulated • Register to register moves occurs between A and R0-R7 • One of the operand is accumulator • Eg: MOV R0,A // copy the contents of A to R0 • MOV R1,A • INVALID MOV R1,R2 - MOV A,R2 MOV R1,A
  • 4. Friday, October 28, 2022 3. Direct Addressing Mode In this addressing mode, data is in the RAM location whose address is known and this address is directly given as part of the instruction MOV R0, 40H // copy data from RAM location 40h to register R0 MOV 56H, A // copy value in A to RAM location 56h MOV A,12H // copy data from RAM location 12h to A
  • 5. Friday, October 28, 2022 4. Register Indirect Addressing Mode • It uses a register to hold the actual address that will be used in the data move • Register itself is not the address but the content in the register • Uses register R0 and R1 (called as data pointers) • It holds the address of RAM locations from 00h to 7Fh • For indirect addressing @ is used eg: MOV A,@R0 copy the contents of the address specified in R0 to Accumulator MOV@R1,A -----copy A to the address in R1 MOV @R0,80H ---Copy the contents of RAM location 80h to the address in R0
  • 6. Friday, October 28, 2022 Indexed Addressing Mode And On-Chip ROM Access • This mode is widely used in accessing data elements of look-up table entries located in the program (code) space ROM at the 8051 MOVC A,@A+DPTR A= content of address A +DPTR from ROM Note: Because the data elements are stored in the program (code ) space ROM of the 8051, it uses the instruction MOVC instead of MOV. The “C” means code.
  • 7. INSTRUCTION SET OF 8051 MARY CATHERINE DEPT OF ECE SSET
  • 8. TYPES OF INSTRUCTIONS DATA TRNSFER INSTRUCTIONS ARITHMETIC INSTRUCTIONS LOGICAL INSTRUCTIONL(S JUMP AND CALL INSTRUCTIONS BIT LEVEL (BOOLEAN) INSTRUCTIONS
  • 9. DATA TRANSFER INSTRUCTIONS  MOV A, Rn  register  MOV A, direct <- content of direct address  MOV A,@Ri <- content of address in Ri  MOV A,#data <- immediate data
  • 10. DATA TRANSFER INSTRUCTIONS  MOV Rn,A  Accumulator  MOV Rn, direct <- content of direct address  MOV direct,A <- accumulator  MOV Rn,#data <- immediate data  MOV direct,Rn <- contents of register  MOV direct,direct <- contents of direct address
  • 11. DATA TRANSFER INSTRUCTIONS MOV direct ,@Ri <- contents of address in Ri MOV drect, #data <- immediate data to direct MOV @Ri ,A <- acc to address in Ri MOV @Ri, direct <- contents of direct address to address in Ri MOV @Ri,#data <- immediate data to address in Ri
  • 12. DATA TRANSFER INSTRUCTIONS MOV DPTR,#16 bit data <- load data pointer with 16 bit constant MOVC A,@A+DPTR <- code byte at ROM address formed by(A+DPTR) MOVC A,@A+PC <- code byte at (A+PC) It is an indirect addressing mode where the number in register A is added to the pointing register to form address in ROM where the desired data is to be found
  • 13. DATA TRANSFER INSTRUCTIONS MOVX A,@Ri <- contents of ext. address Ri to accumulator MOVX A,@DPTR <- contents of ext. address in DPTR to accumulator MOVX @Ri, A <- accumulator to ext. add in Ri MOVX @DPTR,A <- accumulator to ext.address in DPTR
  • 14. Data exchanges Exchange instructions actually move data from Source to Data / data to source XCH A, Rn <exchange data bytes between A and Rn XCH A, direct <exchange data bytes between A and address XCH A, @Rn <exchange data bytes between A& content of address in Rn XCHD A, @Rp <exchange lower nibbles between A and address in Rp
  • 15. ARITHMETIC INSTRUCTIONS ADD A, Rn <- add register to acc ADD A,direct <- add contents of address to A ADD A,@Ri <- add contents of address in Ri to A ADD A, #data <- add immediate data to A
  • 16. ARITHMETIC INSTRUCTIONS ADDC A, Rn <- add register to acc with carry ADDC A,direct <- add contents of address to A with carry ADDC A,@Ri <- add contents of address in Ri to A with carry ADDC A, #data <- add immediate data to A with carry
  • 17. ARITHMETIC INSTRUCTIONS SUBB A, Rn <- subtract register from acc with borrow SUBB A,direct <-subtract contents of address from A with borrow SUBB A,@Ri <-subtract contents of address in Ri from A with borrow SUBB A, #data <- subtract immediate data from A with borrow
  • 18. ARITHMETIC INSTRUCTIONS MUL AB <- multiply A & B; B:A DIV AB <- divide A by B; quo in A,Rem: B DAA <-decimal adjust after addition for BCD Addition
  • 19. ARITHMETIC INSTRUCTIONS INC A <- increment accumulator INC Rn <- increment register by 1 INC direct <- increment contents of address INC @Ri <- increment contents of address in Ri INC DPTR <- increment Data pointer
  • 20. ARITHMETIC INSTRUCTIONS DEC A <- decrement accumulator DEC Rn <- decrement register by 1 DEC direct <- decrement contents of address DEC @Ri <- decrement contents of address in Ri
  • 21. LOGICAL INSTRUCTIONS  ANL A,Rn <- AND register to accumulator  ANL A, direct <- AND contents of address to A  ANL A,@Ri <- AND contents of address in Ri to accumulator  ANL A,#data <- AND immediate data to accumulator  ANL direct,A <- AND accumulator to direct byte  ANL direct,#data <-AND immediate data to direct byte
  • 22. LOGICAL INSTRUCTIONS  ORL A,Rn <- OR register to accumulator  ORL A, direct <- OR contents of address to A  ORL A,@Ri <- OR contents of address in Ri to accumulator  ORL A,#data <- OR immediate data to accumulator  ORL direct,A <- OR accumulator to direct byte  ORL direct,#data <-AND immediate data to direct byte
  • 23. LOGICAL INSTRUCTIONS  XRL A,Rn <- XOR register to accumulator  XRL A, direct <- XOR contents of address to A  XRL A,@Ri <- XOR contents of address in Ri to accumulator  XRL A,#data <- XOR immediate data to accumulator  XRL direct,A <- XOR accumulator to direct byte  XRL direct,#data <- XOR immediate data to direct byte
  • 24. LOGICAL INSTRUCTIONS CLR A <- clear accumulator CPL A <- complement accumulator RLA <- rotate accumulator left RLC A <- rotate acc. left through carry RRA <- rotate accumulator right RRC A <- rotate acc. Right through carry SWAP A <- swap nibbles within accumulator
  • 26. BOOLEAN INSTRUCTIONS(BIT LEVEL) CLR C <- clear carry CLR Bit <- clear direct bit SETB C <- set carry SETB Bit <- set direct bit CPL C <- complement carry CPL bit <- complement direct bit
  • 27. BOOLEAN INSTRUCTIONS(BIT LEVEL) ANL C,bit <- AND carry to direct bit ANL C,/Bit <- AND carry to complement of bit ORL C,Bit <- OR carry to direct bit ORL C,/Bit <- OR carry to complement of bit MOV C,Bit <- move direct bit to carry MOV Bit,C <- move carry to direct bit
  • 28. BOOLEAN INSTRUCTIONS(BIT LEVEL) JC label <- jump if carry set to label JNC label <- jump if carry=0 to label JB bit , label <- jump if bit is set to label JNB Bit, label <- jump if bit not set to label JBC Bit, label <-jump if bit set to label and clear bit
  • 29. PROGRAM BRANCHING ISTRUCTIONS JUMP AND CALL INSTRUCTIONS JUMPS ARE OF 3 TYPES 1. SHORT JUMP (SJMP) 2. LONG JUMP(LJMP) 3. ABSOLUTE JUMP(AJMP)
  • 30. TYPES OF JUMPS SHORT JUMP(SJMP) TRANSFERS CONTROL WITHIN 256 BYTES -128 TO +127 BYTES EG: SJMP Label
  • 31. TYPES OF JUMPS ABSOLUTE JUMP(AJMP) TRANSFERS CONTROL WITHIN 2KB EG: AJMP 11 Bit address
  • 32. TYPES OF JUMPS LONG JUMP(LJMP) TRANSFERS CONTROL WITHIN 64KB EG: LJMP 16 Bit address
  • 33. CALL INSTRUCTIONS TYPES OF CALL ABSOLUTE CALL(ACALL) LONG CALL(LCALL)
  • 34. CALL INSTRUCTIONS ACALL 11 BIT ADDRESS CALLING A SUBROUTINE WITHIN 2KB OF PROGRAM MEMORY
  • 35. CALL INSTRUCTIONS LCALL 16 BIT ADDRESS CALLING A SUBROUTINE WITHIN 64KB OF PROGRAM MEMORY
  • 36. CONDITIONAL JUMPS JZ LABEL ; JUMP IF ACCUMULATOR IS ZERO JNZ LABEL ;JUMP IF ACCUMULATOR IS NON ZERO DJNZ Rn , label ; decrement the register and jump to label if non zero DJNZ direct, label ; decrement direct byte and jump to label if non zero
  • 37. CJNE INSTRUCTION CJNE INSTRUCTION COMPARES THE FIRST OPERAND WITH 2ND OPERAND AND PERFORMS BRANCH OPERATION IF NOT EQUAL
  • 38. CJNE INSTRUCTION CJNE A, direct , label ; compare direct byte to acc & jump if not equal CJNE A, #data , label ; compare immediate data to acc & jump if not equal  CJNE Rn, #data , label ;compare Rn with immediate data  CJNE @Ri , #data, label; compare imm data with indirect byte and jump if not equal
  • 39. RETURN INSTRUCTIONS RET - RETURN FROM SUBROUTINE RETI – RETURN FROM INTERRUPT NOP – NO OPERATION
  • 40. PUSH & POP instructions  PUSH & POP opcodes specifies the direct address of the data  It is a data move instruction from stack to the specified address  Register associated is Stack pointer – contains the internal RAM address where the data will be pushed
  • 41. PUSH & POP instructions PUSH address : Increment SP by 1 ; SP = SP+1 Copy the address specified in the instruction to the internal RAM address in SP register By default SP is set to 07 H (R7 of bank 0) Eg: PUSH 40H It would push the data to the address 08H
  • 42. POP instruction POP address : Copy the data from internal RAM address contained in SP to address specified in the instruction decrement SP by 1 ; SP = SP-1 E.g.: POP 40H It would pop the data from the address 08H to the address 40H
  • 43. PUSH & POP SP reaches FF it rolls over to 00H RAM ends at address 7F H , PUSH es above 7F H result in errors
  • 44. PROGRAMS – ADDITION WITH CARRY ORG 00H // origin MOV R3, #00H // carry register initialised to 0 MOV A,40H // copy 1ST number from 40H to A ADD A,41H // add a and content of 41H JNC L1 // jump if no carry to label L1 INC R3 // Increment carry register by 1 L1: MOV 60H, A // copy result (sum) to address 60H MOV 61H,R3 //copy result (carry) to address 61H END // program ends
  • 45. PROGRAMS – SUBTRACTION WITH BORROW ORG 00H // origin MOV R3, #00H // carry register initialised to 0 MOV A,40H // copy 1ST number from 40H to A SUBB A,41H // Subtract a and content of 41H JNC L1 // jump if no carry to label L1 INC R3 // Increment carry register by 1 CPL A // take 2’s Complement of the no ADD A, #01H (1’s complement +1) L1: MOV 60H, A // copy result to address 60H MOV 61H,R3 //copy result (borrow) to address 61H END // program ends
  • 46. PROGRAMS – MULTIPLICATION OF TWO 8 BIT NOS ORG 00H // origin MOV A,40H // copy 1ST number from 40H to A MOV B,41H // Copy content of 41H to B MUL AB // multiply A and B MOV 60H, A // copy result(LSB) to address 60H MOV 61H,B //copy result (MSB) to address 61H END // program ends
  • 47. PROGRAMS – DIVISION OF TWO 8 BIT NOS ORG 00H // origin MOV A,40H // copy 1ST number from 40H to A MOV B,41H // Copy content of 41H to B DIV AB // divide A by B MOV 60H, A // copy result(quotient) to address 60H MOV 61H,B //copy result (remainder) to address 61H END // program ends
  • 48. PROGRAMS – ADDITION OF N NOS WITH CARRY ORG 00H // origin MOV R3, #00H // carry register initialised to 0 MOV R2, 40H // R2 is the count register, copy contents of 40h TO R2 MOV R0,#41H // pointing array location to 41H MOV A,@R0 //copy contents of address in R0 to A INC R0 // increment R0 L2: ADD A, @R0 // add a and content of address specified in R0 JNC L1 // jump if no carry to label L1 INC R3 // Increment carry register by 1 L1: INC R0 //increment R0 by 1 DJNZ R2,L2 // decrement and jump if nonzero R2, to label L2 MOV 60H, A // copy result (sum) to address 60H MOV 61H,R3 //copy result (carry) to address 61H