SlideShare a Scribd company logo
8051 Assembly Language
Dr. Noorullah Shariff
Outline
• 8051 Programmer’s Model
• Addressing Modes
• Data Movement Instructions
• Arithmetic Instructions
• Logical Instructions
• Shift Instructions
• Bit Manipulation
• Program Control Instructions
Dr. Noorullah Shariff
8051 Introduction
• 8 bit Data bus, 16 bit Address bus
• Many Special Function Registers (SFRs) for
control and I/O
Dr. Noorullah Shariff
8051 Programmer’s Model (1)
Program Memory
OR
FFFF
0000
FFFF
0000
1000
0FFF
if EA = 1 if EA = 0
• All instructions
• Constant Data
(Using MOVC)
64 K
External
60 K
External
4 K
Internal
0
7
7
0
Data Memory
SFRs
RAM
80
FF
00
7F
AND
Direct
Direct , Register,
Reg. Indirect
FFFF
0000
64 K
External
(Using MOVX)
@R
@DPTR
Internal
Dr. Noorullah Shariff
8051 Programmer’s Model (2)
Port 0
Stack pointer
Data pointer DPTR
Power Control
timer/counter control
timer/counter Mode
timer 0 Low
timer 1 Low
timer 0 High
timer 1 High
Port 1
Serial Control
Serial Data Buffer
Port 2
Interrupt Enable Ctr 1* IE
* P2
SBUF
* SCON
* P1
* TH1
* TH0
* TL1
* TL0
TMOD
* TCEN
PCON
DPH
DPL
SP
* P080
81
82
83
87
88
89
8A
8B
8C
8D
90
98
A0
99
A8
* P3
* IP
* PSW
* ACC
* BF0
FF
E0
D0
B8
B0
SFRs
SFRs 7F
00
08
10
18
20
30
Scratch Pad Area
RAM
Bit Addressable RAM
Bank 3
Bank 2
Bank 1
Bank 0
R0
R7
R0
R7
R0
R7
R0
R7
Select Bank
with
PSW.4 , .3 =
RS1, RS0
Bit #00 7F OR
20.0 2F.7
* = Bit Addressable
Dr. Noorullah Shariff
8051 Addressing Modes (1)
• Immediate - # Label or Number
MOV R6,#14 ; R6 14 10
MOV A,#0CAh ; Acc CA 16
MOV DPTR,#loc ; DPTR value of symbol “loc”
• Direct - Label or Number
MOV PSW,R5 ; M(PSW) R5
MOV A,045h ; Acc M(45 10)
• Register - Rn
MOV R1,A ; R1 Acc
MOV B,R3 ; B R3
Dr. Noorullah Shariff
8051 Addressing Modes (2)
• Register Indirect - @R0, @R1, @DPTR
MOV @R0,#250 ; M(R0) 250 10
MOV A,@R1 ; A M(R1)
MOVX @DPTR,A ; External data M(DPTR) A
• Register Indirect Indexed - @A+DPTR, @A+PC
MOVC A,@A+DPTR ; A ROM(A+DPTR)
MOVC A,@A+PC ; A ROM(A+PC)
JMP @A+DPTR ; PC (A+DPTR)
• Bit - bit number or label.bit or bit label
MOV C,IE.0 ; CY bit 0 of IE reg (EX0)
MOV C,EX0 ; same
SETB 07Fh ; Bit 7F 1
SETB 2F.7 ; same
Dr. Noorullah Shariff
8051 Instructions
• Instruction Classes
– Data Movement
– Arithmetic
– Logical
– Shift
– Bit Manipulation
– Program Control
Dr. Noorullah Shariff
8051 Data Movement - 1
MOV R, # Rn
D
A
MOVE
MOV A, # A Immediate
D A Direct
R A Register
@R A Register Indirect
MOV D, # Direct
D
R
@R
A
MOV @R, # Register Indirect
D
ADr. Noorullah Shariff
8051 Data Movement - 2
• Move External Data RAM
MOVX A, @R
A, @DPTR
MOVX @R, A
@DPTR, A
Move From Program Memory
MOVC A, @A+DPTR Acc Rom(A+DPTR)
A, @A+PC Acc Rom(A+PC)
Others
PUSH D SP SP+1, m(SP) D
POP D D m(SP), SP SP - 1
XCH A, R SWAP Acc Rn
D
@R
Dr. Noorullah Shariff
8051 Arithmetic - 1
ADDC A, # Acc A+Immediate+Carry
D
R
@R
Add/Subtract
ADD A, # Acc A+Immediate
D
R
@R
SUBB A, # Acc Acc-Immediate-Carry
D
R
@R
Dr. Noorullah Shariff
8051 Arithmetic - 2
Inc/Dec
INC A Acc Acc+1
D
R
@R
DEC A Acc Acc-1
D
R
@R
Mul/Div
MUL AB B:A Acc * B (unsigned)
DIV AB A Quo ( A/B ) (unsigned)
B Rem( A/B )
Dr. Noorullah Shariff
8051 Logical
• Other
CLR A Acc 0
CPL A Acc Acc
SWAP A Acc(7-4) Acc(3-0)
AND,OR,XOR
AND A, #
ORL D
XRL R
@R
D, A
D, #
Dr. Noorullah Shariff
8051 Shift
Rotates
RL A
RLC A
RR A
RRC A
Acc
7 0
Acc
7 0
C
Acc
7 0
Acc
7 0
C
Dr. Noorullah Shariff
8051 Bit Manipulation - 1
Clear/Set/Complement
CLR C Carry 0
bit bit 0
SETB C
bit
CPL C
bit
And, Or, Move
ANL C, bit Carry Carry AND bit
C, /bit Carry Carry AND bit
ORL C, bit
C, /bit
MOV C, bit
bit, C
Dr. Noorullah Shariff
8051 Bit Manipulation - 2
Jump
JC label Jump if Carry set
JNC label Jump if Carry clear
JB bit, label Jump if bit set
JNB bit, label Jump if bit clear
JBC bit, label Jump if bit set, then clear bit
label = PC relative (+ 127)
Dr. Noorullah Shariff
8051 Program Control - 1
Jump
AJMP label-A Absolute Jump- 11 bits(2K)
LJMP label-L Long Jump - 16 bits (64K)
SJMP label Short Jump
JMP @A+DPTR Jump Indirect PC (A+DPTR)
JZ label Jump if zero
JNZ label Jump if not zero
Compare and Jump
CJNE A, #, label Compare 1st
op to 2nd
op and
A, D, label jump to label if not Equal
R, #, label
@R,#, label
Dr. Noorullah Shariff
8051 Program Control - 2
Decrement and Jump
DJNZ R, label Rn = Rn-1 , Jump if not zero
D, label
Subroutines
ACALL label-A Absolute Call - 11 bits (2K)
LCALL label-L Long Call - 16 bits (64K)
RET Return from Subroutine
RETI Return from ISR
PC m(SP), SP SP-2
Dr. Noorullah Shariff
example of delay
mov a,#0aah
Back1:mov p0,a
lcall delay1
cpl a
sjmp back1
Delay1:mov r0,#0ffh;1cycle
Here: djnz r0,here ;2cycle
ret ;2cycle
end
Delay=1+255*2+2=513 cycle
Delay2:
mov r6,#0ffh
back1: mov r7,#0ffh ;1cycle
Here: djnz r7,here ;2cycle
djnz r6,back1;2cycle
ret ;2cycle
end
Delay=1+(1+255*2+2)*255+2
=130818 machine cycle
Long delay Example
GREEN_LED: equ P1.6
org ooh
ljmp Main
org 100h
Main: clr GREEN_LED
Again: acall Delay
cpl GREEN_LED
sjmp Again
Delay: mov R7, #02
Loop1: mov R6, #00h
Loop0: mov R5, #00h
djnz R5, $
djnz R6, Loop0
djnz R7, Loop1
reset service
main program
subroutine
Example Programs: 1
Example Programs: 2
Example Programs: 2
Example Programs: 3
Method 2 : Since the number is the same for each register, put the number in A
and MOV A to each register.
Example Programs: 4
Example Programs: 4 Continued

More Related Content

What's hot

Micro Controller lab basic experiments (1)
Micro Controller lab basic experiments (1)Micro Controller lab basic experiments (1)
Micro Controller lab basic experiments (1)
Noor Tahasildar
 
Logic Design - Chapter 2: Logic Gates
Logic Design - Chapter 2: Logic GatesLogic Design - Chapter 2: Logic Gates
Logic Design - Chapter 2: Logic GatesGouda Mando
 
8051assembly language
8051assembly language8051assembly language
8051assembly language
Hisham Mat Hussin
 
Applications of microcontroller(8051)
Applications of microcontroller(8051) Applications of microcontroller(8051)
Applications of microcontroller(8051) vijaydeepakg
 
Keypad and dc motor
Keypad and dc motor Keypad and dc motor
Keypad and dc motor vijaydeepakg
 
Listing prog
Listing progListing prog
Listing prog
Fachrizal Nasution
 
Steppert Motor Interfacing With Specific Angle Entered Through Keypad
Steppert Motor Interfacing With Specific Angle Entered Through KeypadSteppert Motor Interfacing With Specific Angle Entered Through Keypad
Steppert Motor Interfacing With Specific Angle Entered Through Keypad
Abrar Amin
 
Registers and its type DLD
Registers and its type DLDRegisters and its type DLD
Registers and its type DLD
Azeemaj101
 
COUNTERS(Synchronous & Asynchronous)
COUNTERS(Synchronous & Asynchronous)COUNTERS(Synchronous & Asynchronous)
COUNTERS(Synchronous & Asynchronous)
SUBHA SHREE
 
Flip flop
Flip flopFlip flop
Flip flop
JAGMIT Jamkhandi
 
Sequential logic circuits flip-flop pt 1
Sequential logic circuits   flip-flop pt 1Sequential logic circuits   flip-flop pt 1
Sequential logic circuits flip-flop pt 1
Sarah Sue Calbio
 
flip flops
flip flops flip flops
flip flops
Unsa Shakir
 
Describe the register
Describe the registerDescribe the register
Describe the register
Brenda Debra
 
Flipflops JK T SR D All FlipFlop Slides
Flipflops JK T SR D All FlipFlop SlidesFlipflops JK T SR D All FlipFlop Slides
Flipflops JK T SR D All FlipFlop Slides
Sid Rehmani
 
Sequential circuit
Sequential circuitSequential circuit
Sequential circuit
Brenda Debra
 
5 it awt week 6
5 it awt week 65 it awt week 6
5 it awt week 6
jainam bhavsar
 

What's hot (19)

Micro Controller lab basic experiments (1)
Micro Controller lab basic experiments (1)Micro Controller lab basic experiments (1)
Micro Controller lab basic experiments (1)
 
Logic Design - Chapter 2: Logic Gates
Logic Design - Chapter 2: Logic GatesLogic Design - Chapter 2: Logic Gates
Logic Design - Chapter 2: Logic Gates
 
8051assembly language
8051assembly language8051assembly language
8051assembly language
 
Applications of microcontroller(8051)
Applications of microcontroller(8051) Applications of microcontroller(8051)
Applications of microcontroller(8051)
 
Keypad and dc motor
Keypad and dc motor Keypad and dc motor
Keypad and dc motor
 
Listing prog
Listing progListing prog
Listing prog
 
Steppert Motor Interfacing With Specific Angle Entered Through Keypad
Steppert Motor Interfacing With Specific Angle Entered Through KeypadSteppert Motor Interfacing With Specific Angle Entered Through Keypad
Steppert Motor Interfacing With Specific Angle Entered Through Keypad
 
Registers and its type DLD
Registers and its type DLDRegisters and its type DLD
Registers and its type DLD
 
COUNTERS(Synchronous & Asynchronous)
COUNTERS(Synchronous & Asynchronous)COUNTERS(Synchronous & Asynchronous)
COUNTERS(Synchronous & Asynchronous)
 
Trts d flip flop1
Trts d flip flop1Trts d flip flop1
Trts d flip flop1
 
Flip flop
Flip flopFlip flop
Flip flop
 
Sequential logic circuits flip-flop pt 1
Sequential logic circuits   flip-flop pt 1Sequential logic circuits   flip-flop pt 1
Sequential logic circuits flip-flop pt 1
 
flip flops
flip flops flip flops
flip flops
 
Describe the register
Describe the registerDescribe the register
Describe the register
 
Sequential circuits
Sequential circuitsSequential circuits
Sequential circuits
 
Horizons Sheets
Horizons SheetsHorizons Sheets
Horizons Sheets
 
Flipflops JK T SR D All FlipFlop Slides
Flipflops JK T SR D All FlipFlop SlidesFlipflops JK T SR D All FlipFlop Slides
Flipflops JK T SR D All FlipFlop Slides
 
Sequential circuit
Sequential circuitSequential circuit
Sequential circuit
 
5 it awt week 6
5 it awt week 65 it awt week 6
5 it awt week 6
 

Similar to Alp 8051

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
Sreenivas Hanumandla
 
Instruction types
Instruction typesInstruction types
Instruction types
JyotiprakashMishra18
 
Instruction set of 8051.ppt
Instruction set of 8051.pptInstruction set of 8051.ppt
Instruction set of 8051.ppt
ChandiniChinni2
 
microcontroller_instruction_set for ENGINEERING STUDENTS
microcontroller_instruction_set for  ENGINEERING STUDENTSmicrocontroller_instruction_set for  ENGINEERING STUDENTS
microcontroller_instruction_set for ENGINEERING STUDENTS
ssuser2b759d
 
8051 Programming Instruction Set
 8051 Programming Instruction Set 8051 Programming Instruction Set
8051 Programming Instruction Set
Shreyans Pathak
 
Microprocessor system - summarize
Microprocessor system - summarizeMicroprocessor system - summarize
Microprocessor system - summarize
Hisham Mat Hussin
 
Emb day2 8051
Emb day2 8051Emb day2 8051
Emb day2 8051
shivamarya55
 
Dsp Datapath
Dsp DatapathDsp Datapath
Dsp Datapath
Abhishek Tiwari
 
Flag registers, addressing modes, instruction set
Flag registers, addressing modes, instruction setFlag registers, addressing modes, instruction set
Flag registers, addressing modes, instruction setaviban
 
Microcontroller 8051- soft.ppt
Microcontroller 8051- soft.pptMicrocontroller 8051- soft.ppt
Microcontroller 8051- soft.ppt
steffydean
 
8085 paper-presentation
8085 paper-presentation8085 paper-presentation
8085 paper-presentation
JiMs ChAcko
 
Chapter3 presentation2
Chapter3 presentation2Chapter3 presentation2
Chapter3 presentation2surendar88
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
jokersclown57
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
karthiga selvaraju
 
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
 
Buy Embedded Systems Projects Online,Buy B tech Projects Online
Buy Embedded Systems Projects Online,Buy B tech Projects OnlineBuy Embedded Systems Projects Online,Buy B tech Projects Online
Buy Embedded Systems Projects Online,Buy B tech Projects Online
Technogroovy
 
UNIT II MICROPROCESSOR AND MICROCONTROLLER
UNIT II MICROPROCESSOR AND MICROCONTROLLER UNIT II MICROPROCESSOR AND MICROCONTROLLER
UNIT II MICROPROCESSOR AND MICROCONTROLLER
ravis205084
 
MICROPROCESSORS AND MICROCONTROLLERS
MICROPROCESSORS AND MICROCONTROLLERSMICROPROCESSORS AND MICROCONTROLLERS
MICROPROCESSORS AND MICROCONTROLLERS
selvakumar948
 
Micro controller(pratheesh)
Micro controller(pratheesh)Micro controller(pratheesh)
Micro controller(pratheesh)Pratheesh Pala
 
Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051
logesh waran
 

Similar to Alp 8051 (20)

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
 
Instruction types
Instruction typesInstruction types
Instruction types
 
Instruction set of 8051.ppt
Instruction set of 8051.pptInstruction set of 8051.ppt
Instruction set of 8051.ppt
 
microcontroller_instruction_set for ENGINEERING STUDENTS
microcontroller_instruction_set for  ENGINEERING STUDENTSmicrocontroller_instruction_set for  ENGINEERING STUDENTS
microcontroller_instruction_set for ENGINEERING STUDENTS
 
8051 Programming Instruction Set
 8051 Programming Instruction Set 8051 Programming Instruction Set
8051 Programming Instruction Set
 
Microprocessor system - summarize
Microprocessor system - summarizeMicroprocessor system - summarize
Microprocessor system - summarize
 
Emb day2 8051
Emb day2 8051Emb day2 8051
Emb day2 8051
 
Dsp Datapath
Dsp DatapathDsp Datapath
Dsp Datapath
 
Flag registers, addressing modes, instruction set
Flag registers, addressing modes, instruction setFlag registers, addressing modes, instruction set
Flag registers, addressing modes, instruction set
 
Microcontroller 8051- soft.ppt
Microcontroller 8051- soft.pptMicrocontroller 8051- soft.ppt
Microcontroller 8051- soft.ppt
 
8085 paper-presentation
8085 paper-presentation8085 paper-presentation
8085 paper-presentation
 
Chapter3 presentation2
Chapter3 presentation2Chapter3 presentation2
Chapter3 presentation2
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
 
Section 1 8051 microcontroller instruction set
Section 1 8051 microcontroller instruction setSection 1 8051 microcontroller instruction set
Section 1 8051 microcontroller instruction set
 
Buy Embedded Systems Projects Online,Buy B tech Projects Online
Buy Embedded Systems Projects Online,Buy B tech Projects OnlineBuy Embedded Systems Projects Online,Buy B tech Projects Online
Buy Embedded Systems Projects Online,Buy B tech Projects Online
 
UNIT II MICROPROCESSOR AND MICROCONTROLLER
UNIT II MICROPROCESSOR AND MICROCONTROLLER UNIT II MICROPROCESSOR AND MICROCONTROLLER
UNIT II MICROPROCESSOR AND MICROCONTROLLER
 
MICROPROCESSORS AND MICROCONTROLLERS
MICROPROCESSORS AND MICROCONTROLLERSMICROPROCESSORS AND MICROCONTROLLERS
MICROPROCESSORS AND MICROCONTROLLERS
 
Micro controller(pratheesh)
Micro controller(pratheesh)Micro controller(pratheesh)
Micro controller(pratheesh)
 
Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051
 

Recently uploaded

Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
ClaraZara1
 
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
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
nooriasukmaningtyas
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
awadeshbabu
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
Dr Ramhari Poudyal
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
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
 
AIR POLLUTION lecture EnE203 updated.pdf
AIR POLLUTION lecture EnE203 updated.pdfAIR POLLUTION lecture EnE203 updated.pdf
AIR POLLUTION lecture EnE203 updated.pdf
RicletoEspinosa1
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
anoopmanoharan2
 
Fundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptxFundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptx
manasideore6
 
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
dxobcob
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
NidhalKahouli2
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
Kamal Acharya
 
TOP 10 B TECH COLLEGES IN JAIPUR 2024.pptx
TOP 10 B TECH COLLEGES IN JAIPUR 2024.pptxTOP 10 B TECH COLLEGES IN JAIPUR 2024.pptx
TOP 10 B TECH COLLEGES IN JAIPUR 2024.pptx
nikitacareer3
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
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
 

Recently uploaded (20)

Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
 
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
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
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
 
AIR POLLUTION lecture EnE203 updated.pdf
AIR POLLUTION lecture EnE203 updated.pdfAIR POLLUTION lecture EnE203 updated.pdf
AIR POLLUTION lecture EnE203 updated.pdf
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
 
Fundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptxFundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptx
 
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
 
TOP 10 B TECH COLLEGES IN JAIPUR 2024.pptx
TOP 10 B TECH COLLEGES IN JAIPUR 2024.pptxTOP 10 B TECH COLLEGES IN JAIPUR 2024.pptx
TOP 10 B TECH COLLEGES IN JAIPUR 2024.pptx
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
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
 

Alp 8051

  • 1. 8051 Assembly Language Dr. Noorullah Shariff
  • 2. Outline • 8051 Programmer’s Model • Addressing Modes • Data Movement Instructions • Arithmetic Instructions • Logical Instructions • Shift Instructions • Bit Manipulation • Program Control Instructions Dr. Noorullah Shariff
  • 3. 8051 Introduction • 8 bit Data bus, 16 bit Address bus • Many Special Function Registers (SFRs) for control and I/O Dr. Noorullah Shariff
  • 4. 8051 Programmer’s Model (1) Program Memory OR FFFF 0000 FFFF 0000 1000 0FFF if EA = 1 if EA = 0 • All instructions • Constant Data (Using MOVC) 64 K External 60 K External 4 K Internal 0 7 7 0 Data Memory SFRs RAM 80 FF 00 7F AND Direct Direct , Register, Reg. Indirect FFFF 0000 64 K External (Using MOVX) @R @DPTR Internal Dr. Noorullah Shariff
  • 5. 8051 Programmer’s Model (2) Port 0 Stack pointer Data pointer DPTR Power Control timer/counter control timer/counter Mode timer 0 Low timer 1 Low timer 0 High timer 1 High Port 1 Serial Control Serial Data Buffer Port 2 Interrupt Enable Ctr 1* IE * P2 SBUF * SCON * P1 * TH1 * TH0 * TL1 * TL0 TMOD * TCEN PCON DPH DPL SP * P080 81 82 83 87 88 89 8A 8B 8C 8D 90 98 A0 99 A8 * P3 * IP * PSW * ACC * BF0 FF E0 D0 B8 B0 SFRs SFRs 7F 00 08 10 18 20 30 Scratch Pad Area RAM Bit Addressable RAM Bank 3 Bank 2 Bank 1 Bank 0 R0 R7 R0 R7 R0 R7 R0 R7 Select Bank with PSW.4 , .3 = RS1, RS0 Bit #00 7F OR 20.0 2F.7 * = Bit Addressable Dr. Noorullah Shariff
  • 6. 8051 Addressing Modes (1) • Immediate - # Label or Number MOV R6,#14 ; R6 14 10 MOV A,#0CAh ; Acc CA 16 MOV DPTR,#loc ; DPTR value of symbol “loc” • Direct - Label or Number MOV PSW,R5 ; M(PSW) R5 MOV A,045h ; Acc M(45 10) • Register - Rn MOV R1,A ; R1 Acc MOV B,R3 ; B R3 Dr. Noorullah Shariff
  • 7. 8051 Addressing Modes (2) • Register Indirect - @R0, @R1, @DPTR MOV @R0,#250 ; M(R0) 250 10 MOV A,@R1 ; A M(R1) MOVX @DPTR,A ; External data M(DPTR) A • Register Indirect Indexed - @A+DPTR, @A+PC MOVC A,@A+DPTR ; A ROM(A+DPTR) MOVC A,@A+PC ; A ROM(A+PC) JMP @A+DPTR ; PC (A+DPTR) • Bit - bit number or label.bit or bit label MOV C,IE.0 ; CY bit 0 of IE reg (EX0) MOV C,EX0 ; same SETB 07Fh ; Bit 7F 1 SETB 2F.7 ; same Dr. Noorullah Shariff
  • 8. 8051 Instructions • Instruction Classes – Data Movement – Arithmetic – Logical – Shift – Bit Manipulation – Program Control Dr. Noorullah Shariff
  • 9. 8051 Data Movement - 1 MOV R, # Rn D A MOVE MOV A, # A Immediate D A Direct R A Register @R A Register Indirect MOV D, # Direct D R @R A MOV @R, # Register Indirect D ADr. Noorullah Shariff
  • 10. 8051 Data Movement - 2 • Move External Data RAM MOVX A, @R A, @DPTR MOVX @R, A @DPTR, A Move From Program Memory MOVC A, @A+DPTR Acc Rom(A+DPTR) A, @A+PC Acc Rom(A+PC) Others PUSH D SP SP+1, m(SP) D POP D D m(SP), SP SP - 1 XCH A, R SWAP Acc Rn D @R Dr. Noorullah Shariff
  • 11. 8051 Arithmetic - 1 ADDC A, # Acc A+Immediate+Carry D R @R Add/Subtract ADD A, # Acc A+Immediate D R @R SUBB A, # Acc Acc-Immediate-Carry D R @R Dr. Noorullah Shariff
  • 12. 8051 Arithmetic - 2 Inc/Dec INC A Acc Acc+1 D R @R DEC A Acc Acc-1 D R @R Mul/Div MUL AB B:A Acc * B (unsigned) DIV AB A Quo ( A/B ) (unsigned) B Rem( A/B ) Dr. Noorullah Shariff
  • 13. 8051 Logical • Other CLR A Acc 0 CPL A Acc Acc SWAP A Acc(7-4) Acc(3-0) AND,OR,XOR AND A, # ORL D XRL R @R D, A D, # Dr. Noorullah Shariff
  • 14. 8051 Shift Rotates RL A RLC A RR A RRC A Acc 7 0 Acc 7 0 C Acc 7 0 Acc 7 0 C Dr. Noorullah Shariff
  • 15. 8051 Bit Manipulation - 1 Clear/Set/Complement CLR C Carry 0 bit bit 0 SETB C bit CPL C bit And, Or, Move ANL C, bit Carry Carry AND bit C, /bit Carry Carry AND bit ORL C, bit C, /bit MOV C, bit bit, C Dr. Noorullah Shariff
  • 16. 8051 Bit Manipulation - 2 Jump JC label Jump if Carry set JNC label Jump if Carry clear JB bit, label Jump if bit set JNB bit, label Jump if bit clear JBC bit, label Jump if bit set, then clear bit label = PC relative (+ 127) Dr. Noorullah Shariff
  • 17. 8051 Program Control - 1 Jump AJMP label-A Absolute Jump- 11 bits(2K) LJMP label-L Long Jump - 16 bits (64K) SJMP label Short Jump JMP @A+DPTR Jump Indirect PC (A+DPTR) JZ label Jump if zero JNZ label Jump if not zero Compare and Jump CJNE A, #, label Compare 1st op to 2nd op and A, D, label jump to label if not Equal R, #, label @R,#, label Dr. Noorullah Shariff
  • 18. 8051 Program Control - 2 Decrement and Jump DJNZ R, label Rn = Rn-1 , Jump if not zero D, label Subroutines ACALL label-A Absolute Call - 11 bits (2K) LCALL label-L Long Call - 16 bits (64K) RET Return from Subroutine RETI Return from ISR PC m(SP), SP SP-2 Dr. Noorullah Shariff
  • 19. example of delay mov a,#0aah Back1:mov p0,a lcall delay1 cpl a sjmp back1 Delay1:mov r0,#0ffh;1cycle Here: djnz r0,here ;2cycle ret ;2cycle end Delay=1+255*2+2=513 cycle Delay2: mov r6,#0ffh back1: mov r7,#0ffh ;1cycle Here: djnz r7,here ;2cycle djnz r6,back1;2cycle ret ;2cycle end Delay=1+(1+255*2+2)*255+2 =130818 machine cycle
  • 20. Long delay Example GREEN_LED: equ P1.6 org ooh ljmp Main org 100h Main: clr GREEN_LED Again: acall Delay cpl GREEN_LED sjmp Again Delay: mov R7, #02 Loop1: mov R6, #00h Loop0: mov R5, #00h djnz R5, $ djnz R6, Loop0 djnz R7, Loop1 reset service main program subroutine
  • 24. Example Programs: 3 Method 2 : Since the number is the same for each register, put the number in A and MOV A to each register.
  • 26. Example Programs: 4 Continued