SlideShare a Scribd company logo
1 of 26
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
 
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
 
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 KeypadAbrar Amin
 
Registers and its type DLD
Registers and its type DLDRegisters and its type DLD
Registers and its type DLDAzeemaj101
 
COUNTERS(Synchronous & Asynchronous)
COUNTERS(Synchronous & Asynchronous)COUNTERS(Synchronous & Asynchronous)
COUNTERS(Synchronous & Asynchronous)SUBHA SHREE
 
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 1Sarah Sue Calbio
 
Describe the register
Describe the registerDescribe the register
Describe the registerBrenda 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 SlidesSid Rehmani
 
Sequential circuit
Sequential circuitSequential circuit
Sequential circuitBrenda Debra
 

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 pptsSreenivas Hanumandla
 
Instruction set of 8051.ppt
Instruction set of 8051.pptInstruction set of 8051.ppt
Instruction set of 8051.pptChandiniChinni2
 
microcontroller_instruction_set for ENGINEERING STUDENTS
microcontroller_instruction_set for  ENGINEERING STUDENTSmicrocontroller_instruction_set for  ENGINEERING STUDENTS
microcontroller_instruction_set for ENGINEERING STUDENTSssuser2b759d
 
8051 Programming Instruction Set
 8051 Programming Instruction Set 8051 Programming Instruction Set
8051 Programming Instruction SetShreyans Pathak
 
Microprocessor system - summarize
Microprocessor system - summarizeMicroprocessor system - summarize
Microprocessor system - summarizeHisham Mat Hussin
 
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.pptsteffydean
 
8085 paper-presentation
8085 paper-presentation8085 paper-presentation
8085 paper-presentationJiMs ChAcko
 
Chapter3 presentation2
Chapter3 presentation2Chapter3 presentation2
Chapter3 presentation2surendar88
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontrollerjokersclown57
 
Section 1 8051 microcontroller instruction set
Section 1 8051 microcontroller instruction setSection 1 8051 microcontroller instruction set
Section 1 8051 microcontroller instruction setnueng-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 OnlineTechnogroovy
 
MICROPROCESSORS AND MICROCONTROLLERS
MICROPROCESSORS AND MICROCONTROLLERSMICROPROCESSORS AND MICROCONTROLLERS
MICROPROCESSORS AND MICROCONTROLLERSselvakumar948
 
UNIT II MICROPROCESSOR AND MICROCONTROLLER
UNIT II MICROPROCESSOR AND MICROCONTROLLER UNIT II MICROPROCESSOR AND MICROCONTROLLER
UNIT II MICROPROCESSOR AND MICROCONTROLLER ravis205084
 
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 8051logesh 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
 
MICROPROCESSORS AND MICROCONTROLLERS
MICROPROCESSORS AND MICROCONTROLLERSMICROPROCESSORS AND MICROCONTROLLERS
MICROPROCESSORS AND MICROCONTROLLERS
 
UNIT II MICROPROCESSOR AND MICROCONTROLLER
UNIT II MICROPROCESSOR AND MICROCONTROLLER UNIT II MICROPROCESSOR AND MICROCONTROLLER
UNIT II MICROPROCESSOR AND MICROCONTROLLER
 
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

Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
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
 
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
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
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
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
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
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 

Recently uploaded (20)

Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
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
 
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
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
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...
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
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
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
🔝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...
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 

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