SlideShare a Scribd company logo
04/25/14 DPD 1
8051 Addressing Modes
04/25/14 DPD 2
Introduction
• Immediate Addressing
• Register Addressing
• Direct Addressing
• Register Indirect Addressing
• Indexed Addressing
04/25/14 DPD 3
Immediate Addressing
• MOV A, #25H
• MOV R4, #62
• MOV B, #40H
• MOV DTPR, #2550H
Same as
– MOV DPL, #50H
– MOV DPH, #25H
04/25/14 DPD 4
Register Addressing
• MOV A, R0
• MOV R2, A
• ADD A, R5
• ADD A, R7
• MOV R6, A
• MOV R4, R7 – invalid
• MOV DTPR, A – error
• MOV R7, DPL – valid
• MOV R6, DPH – valid
04/25/14 DPD 5
Direct Addressing
• MOV R0, 40H
• MOV 56H, A
• MOV R4, 7FH
• MOV R2, #5
• MOV A, 2
• MOV B, 2
• MOV 7, 2
• MOV A, 4
• MOV A, R4
• MOV A, 7
• MOV A, R7
04/25/14 DPD 6
SFR registers and their
addressing
• SFR – special function
register
• A, B, PSW, DPTR can
be addresses by
– Names
– Addresses
• A – E0H
• B – F0H
• MOV 0E0H, #55H
• MOV A, #55H
• MOV 0F0H, #25H
• MOV B, #25H
• MOV P1, A
• MOV 90H, A
04/25/14 DPD 7
SFR …contd.
• SFR have addresses
between 80H and FFH
• 00 to 7FH are addresses of
RAM memory inside 8051
• Not all address spaces of
80 to FF is used by the
SFR.
• Unused locations are
reserved and must not be
used by the 8051
programmer.
FFH
F0 – B register
E0 – Accumulator
D0 – PSW
B0 – Port 3
A0 – Port 2
90 – Port 1
83 – DPH
82 – DPL
81 – SP
80H 80 – Port 0
04/25/14 DPD 8
Stack and direct addressing
• PUSH A – invalid
• PUSH 0E0H – valid
• PUSH 05
• PUSH 06
• PUSH 0E0H
• PUSH 0F0H
• POP 02
• POP 03
04/25/14 DPD 9
Register Indirect Addressing
• A register is used as a
pointer to the data
• Only R0 and R1 are
used for this purpose
• Must be preceded by
‘@’ sign
• MOV A, @R0
– Move contents of
RAM location whose
address is held by R0
into A
• MOV @R1, B
– Move contents of B
into RAM location
whose address is held
by R1
04/25/14 DPD 10
Advantage of register indirect
addressing• Make accessing data
dynamic rather than static
MOV A, #55H
MOV 40H, A
MOV 41H, A
MOV 42H, A
MOV 43H, A
MOV 44H, A
MOV A, #55H
MOV R0, #40H
MOV @R0, A
INC R0
MOV @R0, A
INC R0
MOV @R0, A
INC R0
MOV @R0, A
INC R0
MOV @R0, A
MOV A, #55H
MOV R0, #40H
MOV R2, #05
AGAIN: MOV @R0, A
INC R0
DJNZ R2, AGAIN
• Looping is not possible in
direct addressing
04/25/14 DPD 11
Limitation of register indirect
addressing
• Only R0 and R1 can be used for this
purpose
• They 8 bit wide
• Use is limited to internal RAM (30H –
7FH)
• To access external RAM or on-chip ROM
we need 16-bit pointer
– DPTR is used in this case
04/25/14 DPD 12
Indexed addressing mode and
On-chip ROM access
• Used in accessing data elements of LUT
entries located in the program ROM space
of the 8051
• MOVC A, @A+DPTR
– C means code
• Contents of A is added to the 16-bit register
DPTR to form the 16-bit address of the
needed data
04/25/14 DPD 13
Example
• Assume that the word ‘USA’ is burned into
ROM location stating 200H, and that the
program is burned into location stating at 0.
• Analyze how the program works and state
where ‘USA’ is stored after this program is
run.
04/25/14 DPD 14
Solution
ORG 0000H
MOV DPTR, #200H
CLR A
MOVC A, @A+DPTR
MOV R0, A
INC DPTR
CLR A
MOVC A, @A+DPTR
MOV R1, A
INC DPTR
CLR A
MOVC A, @A+DPTR
MOV R2, A
HERE: SJMP HERE
ORG 200H
MYDATA: DB “USA”
END
04/25/14 DPD 15
Analysis
• ROM location 200H – 202H have the following
content
– 200 = (‘U’)
– 201 = (‘S’)
– 202 = (‘A’)
• Start with DPTR = 200H, and A = 0
• MOVC A, @A+DPTR → moves the content of
ROM location 200H (200H + 0 = 200H) to
register A
• Register A contains 55H, the ASCII value for ‘U’
• This is moved to R0
• Next DPTR is incremented to make DPTR = 201H
04/25/14 DPD 16
Example
• Assuming that ROM space starting at 250H
contains ‘India’
• Write a program to transfer the bytes into
RAM locations stating at 40H
04/25/14 DPD 17
Solution
ORG 0000
MOV DPTR, #MYDATA
MOV R0, #40H
MOV R2, #5
BACK: CLR A
MOVC A, @A+DPTR
MOV @R0, A
INC DPTR
INC R0
DJNZ R2, BACK
HERE: SJMP HERE
ORG 250H
MYDATA: DB “India”
END
04/25/14 DPD 18
Look-up table and MOVC
ORG 0
MOV DPTR, #300H
MOV A, #0FFH
MOV P1, A
BACK: MOV A, P1
MOVC A, @A+DPTR
MOV P2, A
SJMP BACK
• Write a program to the x
value from P1 and send x2
to P2 continuously
ORG 300H
XSQR_TABLE:
DB 0, 1, 4, 9, 16, 25, 36,
49, 64, 81
END
300 = 00H 303 = 09H
301 = 01H 304 = 10H
302 = 04H 305 = 19H
04/25/14 DPD 19
Accessing RAM locations 30 –
7FH as scratch pad
• Write a program to
toggle P1 a total of
200 times
• Use RAM location
32H to hold your
counter value instead
of registers R0 – R7
MOV P1, #55H
MOV 32H, #200
LOOP: CPL P1
ACALL DELAY
DJNZ 32H, LOOP
04/25/14 DPD 20
Bit-addressable RAM
• 16 bytes are bit-
addressable
• 20H – 2FH
• Provides 16 x 8 = 128 bits
• Addressed as 0 to 127 or
00H to 7FH
• 20H – 2FH RAM location
– Bit addressable
– Byte addressable
SETB 42H ;set bit 42H to 1
CLR 67H ;clear bit 67
CLR 0FH ;clear bit 0F
SETB 05
04/25/14 DPD 21
Single bit instruction
SETB bit bit =1
CLR bit bit = 0
CPL bit bit = NOT bit
JB bit, target Jump to target if bit = 1
JNB bit, target Jump to target if bit = 0
JBC bit, target Jump to target if bit = 1, clear bit
04/25/14 DPD 22
I/O port bit addresses
SETB 86H ;set bit P0.6
CLR 87H ;clear bit P0.7
04/25/14 DPD 23
Example
• Write a program to save Acc in R7 of Bank 2
CLR PSW.3
SETB PSW.4
MOV R7, A
• How to check overflow?
JB PSW.2, TARGET
• Check if RAM location 37H contains an even
value. If so, send it to P2, else make it even and
send it to P2.
MOV A, 37H
JNB ACC.0, YES
INC A
YES: MOV P2, A
04/25/14 DPD 24
Bit Directive
LED BIT P1.7
HERE: CPL LED
LCALL DELAY
SJMP HERE
SW BIT P1.7
LED BIT P2.0
HERE: MOV C, SW
MOV LED, C
SJMP HERE
04/25/14 DPD 25
Using EQU directive
• A switch is connected
to pin P1.7
• Write a program to
check that status of the
switch and make the
following decision
– If SW = 0, send “No”
to P2
– If SW = 1, send “Yes”
to P2
SW EQU P1.7
MYDATA EQU P2
HERE: MOV C, SW
JC OVER
MOV MYDATA, #’N’
MOV MYDATA, #’O’
SJMP HERE
OVER: MOV MYDATA, #’Y’
MOV MYDATA, #’Y’
MOV MYDATA, #’Y’
SJMP HERE
END

More Related Content

What's hot

Instruction Set of 8051 Microcontroller
Instruction Set of 8051 MicrocontrollerInstruction Set of 8051 Microcontroller
Instruction Set of 8051 Microcontroller
Multisoft Virtual Academy
 
06. thumb instructions
06. thumb instructions06. thumb instructions
06. thumb instructions
balaji raja rajan Venkatachalam
 
8051 timer counter
8051 timer counter8051 timer counter
8051 timer counter
vishalgohel12195
 
Serial Communication in 8051
Serial Communication in 8051Serial Communication in 8051
Serial Communication in 8051
Sudhanshu Janwadkar
 
Short Channel Effect In MOSFET
Short Channel Effect In MOSFETShort Channel Effect In MOSFET
Short Channel Effect In MOSFET
Sudhanshu Srivastava
 
Lightly Doped Drain
Lightly Doped DrainLightly Doped Drain
Lightly Doped Drain
Sudhanshu Janwadkar
 
Universal synchronous asynchronous receiver transmitter(usart) and AtoD Coverter
Universal synchronous asynchronous receiver transmitter(usart) and AtoD CoverterUniversal synchronous asynchronous receiver transmitter(usart) and AtoD Coverter
Universal synchronous asynchronous receiver transmitter(usart) and AtoD Coverter
Tejas Shetye
 
UART
UARTUART
Keypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 MicrocontrollerKeypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 Microcontroller
Sudhanshu Janwadkar
 
Lambda design rule
Lambda design ruleLambda design rule
Lambda design rule
Gowri Kishore
 
Vlsi stick daigram (JCE)
Vlsi stick daigram (JCE)Vlsi stick daigram (JCE)
Vlsi stick daigram (JCE)
Hrishikesh Kamat
 
8051 Inturrpt
8051 Inturrpt8051 Inturrpt
8051 Inturrpt
Ramasubbu .P
 
8051 MICROCONTROLLER
8051 MICROCONTROLLER 8051 MICROCONTROLLER
8051 MICROCONTROLLER
THANDAIAH PRABU
 
Tutorial on avr atmega8 microcontroller, architecture and its applications
Tutorial on avr atmega8 microcontroller, architecture and its applicationsTutorial on avr atmega8 microcontroller, architecture and its applications
Tutorial on avr atmega8 microcontroller, architecture and its applications
Edgefxkits & Solutions
 
microcontroller basics
microcontroller basicsmicrocontroller basics
microcontroller basics
sagar Ramdev
 
MOSFET and Short channel effects
MOSFET and Short channel effectsMOSFET and Short channel effects
MOSFET and Short channel effects
Lee Rather
 
Serial communication in 8085
Serial communication in 8085Serial communication in 8085
Serial communication in 8085
Nitin Ahire
 
THE CMOS VLSI DESIGN
THE CMOS VLSI DESIGNTHE CMOS VLSI DESIGN
THE CMOS VLSI DESIGN
suryateja swamy
 
MicroC/OS-II
MicroC/OS-IIMicroC/OS-II
8051 data types and directives
8051 data types and directives8051 data types and directives
8051 data types and directives
SARITHA REDDY
 

What's hot (20)

Instruction Set of 8051 Microcontroller
Instruction Set of 8051 MicrocontrollerInstruction Set of 8051 Microcontroller
Instruction Set of 8051 Microcontroller
 
06. thumb instructions
06. thumb instructions06. thumb instructions
06. thumb instructions
 
8051 timer counter
8051 timer counter8051 timer counter
8051 timer counter
 
Serial Communication in 8051
Serial Communication in 8051Serial Communication in 8051
Serial Communication in 8051
 
Short Channel Effect In MOSFET
Short Channel Effect In MOSFETShort Channel Effect In MOSFET
Short Channel Effect In MOSFET
 
Lightly Doped Drain
Lightly Doped DrainLightly Doped Drain
Lightly Doped Drain
 
Universal synchronous asynchronous receiver transmitter(usart) and AtoD Coverter
Universal synchronous asynchronous receiver transmitter(usart) and AtoD CoverterUniversal synchronous asynchronous receiver transmitter(usart) and AtoD Coverter
Universal synchronous asynchronous receiver transmitter(usart) and AtoD Coverter
 
UART
UARTUART
UART
 
Keypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 MicrocontrollerKeypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 Microcontroller
 
Lambda design rule
Lambda design ruleLambda design rule
Lambda design rule
 
Vlsi stick daigram (JCE)
Vlsi stick daigram (JCE)Vlsi stick daigram (JCE)
Vlsi stick daigram (JCE)
 
8051 Inturrpt
8051 Inturrpt8051 Inturrpt
8051 Inturrpt
 
8051 MICROCONTROLLER
8051 MICROCONTROLLER 8051 MICROCONTROLLER
8051 MICROCONTROLLER
 
Tutorial on avr atmega8 microcontroller, architecture and its applications
Tutorial on avr atmega8 microcontroller, architecture and its applicationsTutorial on avr atmega8 microcontroller, architecture and its applications
Tutorial on avr atmega8 microcontroller, architecture and its applications
 
microcontroller basics
microcontroller basicsmicrocontroller basics
microcontroller basics
 
MOSFET and Short channel effects
MOSFET and Short channel effectsMOSFET and Short channel effects
MOSFET and Short channel effects
 
Serial communication in 8085
Serial communication in 8085Serial communication in 8085
Serial communication in 8085
 
THE CMOS VLSI DESIGN
THE CMOS VLSI DESIGNTHE CMOS VLSI DESIGN
THE CMOS VLSI DESIGN
 
MicroC/OS-II
MicroC/OS-IIMicroC/OS-II
MicroC/OS-II
 
8051 data types and directives
8051 data types and directives8051 data types and directives
8051 data types and directives
 

Viewers also liked

Addressing mode of 8051
Addressing mode of 8051Addressing mode of 8051
Addressing mode of 8051
Nitin Ahire
 
Addressing Modes
Addressing ModesAddressing Modes
Addressing Modes
Mayank Garg
 
8051-mazidi-solution
8051-mazidi-solution8051-mazidi-solution
8051-mazidi-solution
ZunAib Ali
 
8051 Addressing modes
8051 Addressing modes8051 Addressing modes
8051 Addressing modes
Ravikumar Tiwari
 
8051 serial communication
8051 serial communication8051 serial communication
8051 serial communication
canh phan
 
Serial1
Serial1Serial1
Serial1
anishgoel
 
Class8
Class8Class8
8051 ch9
8051 ch98051 ch9
8051 ch9
860540760
 
Addressing modes of 8051
Addressing modes  of 8051Addressing modes  of 8051
Addressing modes of 8051
Bharath Reddy
 
8051 addressing modes
8051 addressing modes8051 addressing modes
8051 addressing modes
sb108ec
 
8051 Microcontroller
8051 Microcontroller8051 Microcontroller
8051 Microcontroller
Dr. Ritula Thakur
 
8051 microcontroller by K. Vijay Kumar
8051 microcontroller by K. Vijay Kumar8051 microcontroller by K. Vijay Kumar
8051 microcontroller by K. Vijay Kumar
Vijay Kumar
 
Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051
Jay Patel
 
8051 architecture
8051 architecture8051 architecture
8051 architecture
sb108ec
 
8051 Presentation
8051 Presentation8051 Presentation
8051 Presentation
Sayan Chakraborty
 
Addressing modes of 8051
Addressing modes of 8051Addressing modes of 8051
Addressing modes of 8051
SARITHA REDDY
 
Architecture of 8051 microcontroller))
Architecture of 8051 microcontroller))Architecture of 8051 microcontroller))
Architecture of 8051 microcontroller))
Ganesh Ram
 
Question paper with solution the 8051 microcontroller based embedded systems...
Question paper with solution  the 8051 microcontroller based embedded systems...Question paper with solution  the 8051 microcontroller based embedded systems...
Question paper with solution the 8051 microcontroller based embedded systems...
manishpatel_79
 
Green house effect
Green house effectGreen house effect
Green house effect
Rishabh Sood
 
Gate life sciences 2009
Gate life sciences 2009Gate life sciences 2009
Gate life sciences 2009
Anna Purna
 

Viewers also liked (20)

Addressing mode of 8051
Addressing mode of 8051Addressing mode of 8051
Addressing mode of 8051
 
Addressing Modes
Addressing ModesAddressing Modes
Addressing Modes
 
8051-mazidi-solution
8051-mazidi-solution8051-mazidi-solution
8051-mazidi-solution
 
8051 Addressing modes
8051 Addressing modes8051 Addressing modes
8051 Addressing modes
 
8051 serial communication
8051 serial communication8051 serial communication
8051 serial communication
 
Serial1
Serial1Serial1
Serial1
 
Class8
Class8Class8
Class8
 
8051 ch9
8051 ch98051 ch9
8051 ch9
 
Addressing modes of 8051
Addressing modes  of 8051Addressing modes  of 8051
Addressing modes of 8051
 
8051 addressing modes
8051 addressing modes8051 addressing modes
8051 addressing modes
 
8051 Microcontroller
8051 Microcontroller8051 Microcontroller
8051 Microcontroller
 
8051 microcontroller by K. Vijay Kumar
8051 microcontroller by K. Vijay Kumar8051 microcontroller by K. Vijay Kumar
8051 microcontroller by K. Vijay Kumar
 
Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051
 
8051 architecture
8051 architecture8051 architecture
8051 architecture
 
8051 Presentation
8051 Presentation8051 Presentation
8051 Presentation
 
Addressing modes of 8051
Addressing modes of 8051Addressing modes of 8051
Addressing modes of 8051
 
Architecture of 8051 microcontroller))
Architecture of 8051 microcontroller))Architecture of 8051 microcontroller))
Architecture of 8051 microcontroller))
 
Question paper with solution the 8051 microcontroller based embedded systems...
Question paper with solution  the 8051 microcontroller based embedded systems...Question paper with solution  the 8051 microcontroller based embedded systems...
Question paper with solution the 8051 microcontroller based embedded systems...
 
Green house effect
Green house effectGreen house effect
Green house effect
 
Gate life sciences 2009
Gate life sciences 2009Gate life sciences 2009
Gate life sciences 2009
 

Similar to 8051 addressing modes

Microcontroller 8051 soft
Microcontroller 8051  softMicrocontroller 8051  soft
Microcontroller 8051 soft
baluusa8
 
MICROCONTROLLERS-module2 (7).pptx
MICROCONTROLLERS-module2 (7).pptxMICROCONTROLLERS-module2 (7).pptx
MICROCONTROLLERS-module2 (7).pptx
AmoghR3
 
Embedded Systems Training & Live Projects @Technogroovy Systems India Pvt Ltd
Embedded Systems Training & Live Projects @Technogroovy Systems India Pvt Ltd Embedded Systems Training & Live Projects @Technogroovy Systems India Pvt Ltd
Embedded Systems Training & Live Projects @Technogroovy Systems India Pvt Ltd
Technogroovy India
 
Microcontroller 8051- soft.ppt
Microcontroller 8051- soft.pptMicrocontroller 8051- soft.ppt
Microcontroller 8051- soft.ppt
steffydean
 
8051 addressing modes
8051 addressing modes8051 addressing modes
8051 addressing modes
Vima Mali
 
unit5_8051_microcontroller presentation.pdf
unit5_8051_microcontroller presentation.pdfunit5_8051_microcontroller presentation.pdf
unit5_8051_microcontroller presentation.pdf
tchandoo1
 
8051 instruction_set.ppt
8051 instruction_set.ppt8051 instruction_set.ppt
8051 instruction_set.ppt
20EUEE018DEEPAKM
 
432_17EC563_8051-microcontroller-moving-data_notes.pdf
432_17EC563_8051-microcontroller-moving-data_notes.pdf432_17EC563_8051-microcontroller-moving-data_notes.pdf
432_17EC563_8051-microcontroller-moving-data_notes.pdf
ShreeKrishnaTarai
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
karthiga selvaraju
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
jokersclown57
 
mup
mupmup
addressing-mode-of-8051.pdf
addressing-mode-of-8051.pdfaddressing-mode-of-8051.pdf
addressing-mode-of-8051.pdf
DhilibanSwaminathan
 
Addressing Modes of 8051.pptx
Addressing Modes of 8051.pptxAddressing Modes of 8051.pptx
Addressing Modes of 8051.pptx
TumkurInfomedia
 
5 addressing modes
5 addressing modes5 addressing modes
5 addressing modes
Channabasappa Kudarihal
 
New text document
New text documentNew text document
New text document
zocaniveb
 
Winter training,Readymade Projects,Buy Projects,Corporate Training
Winter training,Readymade Projects,Buy Projects,Corporate TrainingWinter training,Readymade Projects,Buy Projects,Corporate Training
Winter training,Readymade Projects,Buy Projects,Corporate Training
Technogroovy
 
Addressing modes of 8051
Addressing modes of 8051Addressing modes of 8051
Addressing modes of 8051
Dr. AISHWARYA N
 
Https _doc-0o-c4-apps-viewer.googleusercontent
Https  _doc-0o-c4-apps-viewer.googleusercontent Https  _doc-0o-c4-apps-viewer.googleusercontent
Https _doc-0o-c4-apps-viewer.googleusercontent
vijaydeepakg
 
1347 assemblylanguageprogrammingof8051-100523023308-phpapp01
1347 assemblylanguageprogrammingof8051-100523023308-phpapp011347 assemblylanguageprogrammingof8051-100523023308-phpapp01
1347 assemblylanguageprogrammingof8051-100523023308-phpapp01
bvenkanna
 
instructions set of 8051.pdf
instructions set of 8051.pdfinstructions set of 8051.pdf
instructions set of 8051.pdf
DhilibanSwaminathan
 

Similar to 8051 addressing modes (20)

Microcontroller 8051 soft
Microcontroller 8051  softMicrocontroller 8051  soft
Microcontroller 8051 soft
 
MICROCONTROLLERS-module2 (7).pptx
MICROCONTROLLERS-module2 (7).pptxMICROCONTROLLERS-module2 (7).pptx
MICROCONTROLLERS-module2 (7).pptx
 
Embedded Systems Training & Live Projects @Technogroovy Systems India Pvt Ltd
Embedded Systems Training & Live Projects @Technogroovy Systems India Pvt Ltd Embedded Systems Training & Live Projects @Technogroovy Systems India Pvt Ltd
Embedded Systems Training & Live Projects @Technogroovy Systems India Pvt Ltd
 
Microcontroller 8051- soft.ppt
Microcontroller 8051- soft.pptMicrocontroller 8051- soft.ppt
Microcontroller 8051- soft.ppt
 
8051 addressing modes
8051 addressing modes8051 addressing modes
8051 addressing modes
 
unit5_8051_microcontroller presentation.pdf
unit5_8051_microcontroller presentation.pdfunit5_8051_microcontroller presentation.pdf
unit5_8051_microcontroller presentation.pdf
 
8051 instruction_set.ppt
8051 instruction_set.ppt8051 instruction_set.ppt
8051 instruction_set.ppt
 
432_17EC563_8051-microcontroller-moving-data_notes.pdf
432_17EC563_8051-microcontroller-moving-data_notes.pdf432_17EC563_8051-microcontroller-moving-data_notes.pdf
432_17EC563_8051-microcontroller-moving-data_notes.pdf
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
 
mup
mupmup
mup
 
addressing-mode-of-8051.pdf
addressing-mode-of-8051.pdfaddressing-mode-of-8051.pdf
addressing-mode-of-8051.pdf
 
Addressing Modes of 8051.pptx
Addressing Modes of 8051.pptxAddressing Modes of 8051.pptx
Addressing Modes of 8051.pptx
 
5 addressing modes
5 addressing modes5 addressing modes
5 addressing modes
 
New text document
New text documentNew text document
New text document
 
Winter training,Readymade Projects,Buy Projects,Corporate Training
Winter training,Readymade Projects,Buy Projects,Corporate TrainingWinter training,Readymade Projects,Buy Projects,Corporate Training
Winter training,Readymade Projects,Buy Projects,Corporate Training
 
Addressing modes of 8051
Addressing modes of 8051Addressing modes of 8051
Addressing modes of 8051
 
Https _doc-0o-c4-apps-viewer.googleusercontent
Https  _doc-0o-c4-apps-viewer.googleusercontent Https  _doc-0o-c4-apps-viewer.googleusercontent
Https _doc-0o-c4-apps-viewer.googleusercontent
 
1347 assemblylanguageprogrammingof8051-100523023308-phpapp01
1347 assemblylanguageprogrammingof8051-100523023308-phpapp011347 assemblylanguageprogrammingof8051-100523023308-phpapp01
1347 assemblylanguageprogrammingof8051-100523023308-phpapp01
 
instructions set of 8051.pdf
instructions set of 8051.pdfinstructions set of 8051.pdf
instructions set of 8051.pdf
 

Recently uploaded

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
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
gerogepatton
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
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
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
yokeleetan1
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
ihlasbinance2003
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
University of Maribor
 
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
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
drwaing
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
ssuser36d3051
 
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
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
Madan Karki
 
Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
mahammadsalmanmech
 
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
 
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
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
RadiNasr
 
2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt
PuktoonEngr
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
gestioneergodomus
 

Recently uploaded (20)

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
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
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
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
 
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...
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
 
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
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 
Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
 
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
 
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
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
 
2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
 

8051 addressing modes

  • 1. 04/25/14 DPD 1 8051 Addressing Modes
  • 2. 04/25/14 DPD 2 Introduction • Immediate Addressing • Register Addressing • Direct Addressing • Register Indirect Addressing • Indexed Addressing
  • 3. 04/25/14 DPD 3 Immediate Addressing • MOV A, #25H • MOV R4, #62 • MOV B, #40H • MOV DTPR, #2550H Same as – MOV DPL, #50H – MOV DPH, #25H
  • 4. 04/25/14 DPD 4 Register Addressing • MOV A, R0 • MOV R2, A • ADD A, R5 • ADD A, R7 • MOV R6, A • MOV R4, R7 – invalid • MOV DTPR, A – error • MOV R7, DPL – valid • MOV R6, DPH – valid
  • 5. 04/25/14 DPD 5 Direct Addressing • MOV R0, 40H • MOV 56H, A • MOV R4, 7FH • MOV R2, #5 • MOV A, 2 • MOV B, 2 • MOV 7, 2 • MOV A, 4 • MOV A, R4 • MOV A, 7 • MOV A, R7
  • 6. 04/25/14 DPD 6 SFR registers and their addressing • SFR – special function register • A, B, PSW, DPTR can be addresses by – Names – Addresses • A – E0H • B – F0H • MOV 0E0H, #55H • MOV A, #55H • MOV 0F0H, #25H • MOV B, #25H • MOV P1, A • MOV 90H, A
  • 7. 04/25/14 DPD 7 SFR …contd. • SFR have addresses between 80H and FFH • 00 to 7FH are addresses of RAM memory inside 8051 • Not all address spaces of 80 to FF is used by the SFR. • Unused locations are reserved and must not be used by the 8051 programmer. FFH F0 – B register E0 – Accumulator D0 – PSW B0 – Port 3 A0 – Port 2 90 – Port 1 83 – DPH 82 – DPL 81 – SP 80H 80 – Port 0
  • 8. 04/25/14 DPD 8 Stack and direct addressing • PUSH A – invalid • PUSH 0E0H – valid • PUSH 05 • PUSH 06 • PUSH 0E0H • PUSH 0F0H • POP 02 • POP 03
  • 9. 04/25/14 DPD 9 Register Indirect Addressing • A register is used as a pointer to the data • Only R0 and R1 are used for this purpose • Must be preceded by ‘@’ sign • MOV A, @R0 – Move contents of RAM location whose address is held by R0 into A • MOV @R1, B – Move contents of B into RAM location whose address is held by R1
  • 10. 04/25/14 DPD 10 Advantage of register indirect addressing• Make accessing data dynamic rather than static MOV A, #55H MOV 40H, A MOV 41H, A MOV 42H, A MOV 43H, A MOV 44H, A MOV A, #55H MOV R0, #40H MOV @R0, A INC R0 MOV @R0, A INC R0 MOV @R0, A INC R0 MOV @R0, A INC R0 MOV @R0, A MOV A, #55H MOV R0, #40H MOV R2, #05 AGAIN: MOV @R0, A INC R0 DJNZ R2, AGAIN • Looping is not possible in direct addressing
  • 11. 04/25/14 DPD 11 Limitation of register indirect addressing • Only R0 and R1 can be used for this purpose • They 8 bit wide • Use is limited to internal RAM (30H – 7FH) • To access external RAM or on-chip ROM we need 16-bit pointer – DPTR is used in this case
  • 12. 04/25/14 DPD 12 Indexed addressing mode and On-chip ROM access • Used in accessing data elements of LUT entries located in the program ROM space of the 8051 • MOVC A, @A+DPTR – C means code • Contents of A is added to the 16-bit register DPTR to form the 16-bit address of the needed data
  • 13. 04/25/14 DPD 13 Example • Assume that the word ‘USA’ is burned into ROM location stating 200H, and that the program is burned into location stating at 0. • Analyze how the program works and state where ‘USA’ is stored after this program is run.
  • 14. 04/25/14 DPD 14 Solution ORG 0000H MOV DPTR, #200H CLR A MOVC A, @A+DPTR MOV R0, A INC DPTR CLR A MOVC A, @A+DPTR MOV R1, A INC DPTR CLR A MOVC A, @A+DPTR MOV R2, A HERE: SJMP HERE ORG 200H MYDATA: DB “USA” END
  • 15. 04/25/14 DPD 15 Analysis • ROM location 200H – 202H have the following content – 200 = (‘U’) – 201 = (‘S’) – 202 = (‘A’) • Start with DPTR = 200H, and A = 0 • MOVC A, @A+DPTR → moves the content of ROM location 200H (200H + 0 = 200H) to register A • Register A contains 55H, the ASCII value for ‘U’ • This is moved to R0 • Next DPTR is incremented to make DPTR = 201H
  • 16. 04/25/14 DPD 16 Example • Assuming that ROM space starting at 250H contains ‘India’ • Write a program to transfer the bytes into RAM locations stating at 40H
  • 17. 04/25/14 DPD 17 Solution ORG 0000 MOV DPTR, #MYDATA MOV R0, #40H MOV R2, #5 BACK: CLR A MOVC A, @A+DPTR MOV @R0, A INC DPTR INC R0 DJNZ R2, BACK HERE: SJMP HERE ORG 250H MYDATA: DB “India” END
  • 18. 04/25/14 DPD 18 Look-up table and MOVC ORG 0 MOV DPTR, #300H MOV A, #0FFH MOV P1, A BACK: MOV A, P1 MOVC A, @A+DPTR MOV P2, A SJMP BACK • Write a program to the x value from P1 and send x2 to P2 continuously ORG 300H XSQR_TABLE: DB 0, 1, 4, 9, 16, 25, 36, 49, 64, 81 END 300 = 00H 303 = 09H 301 = 01H 304 = 10H 302 = 04H 305 = 19H
  • 19. 04/25/14 DPD 19 Accessing RAM locations 30 – 7FH as scratch pad • Write a program to toggle P1 a total of 200 times • Use RAM location 32H to hold your counter value instead of registers R0 – R7 MOV P1, #55H MOV 32H, #200 LOOP: CPL P1 ACALL DELAY DJNZ 32H, LOOP
  • 20. 04/25/14 DPD 20 Bit-addressable RAM • 16 bytes are bit- addressable • 20H – 2FH • Provides 16 x 8 = 128 bits • Addressed as 0 to 127 or 00H to 7FH • 20H – 2FH RAM location – Bit addressable – Byte addressable SETB 42H ;set bit 42H to 1 CLR 67H ;clear bit 67 CLR 0FH ;clear bit 0F SETB 05
  • 21. 04/25/14 DPD 21 Single bit instruction SETB bit bit =1 CLR bit bit = 0 CPL bit bit = NOT bit JB bit, target Jump to target if bit = 1 JNB bit, target Jump to target if bit = 0 JBC bit, target Jump to target if bit = 1, clear bit
  • 22. 04/25/14 DPD 22 I/O port bit addresses SETB 86H ;set bit P0.6 CLR 87H ;clear bit P0.7
  • 23. 04/25/14 DPD 23 Example • Write a program to save Acc in R7 of Bank 2 CLR PSW.3 SETB PSW.4 MOV R7, A • How to check overflow? JB PSW.2, TARGET • Check if RAM location 37H contains an even value. If so, send it to P2, else make it even and send it to P2. MOV A, 37H JNB ACC.0, YES INC A YES: MOV P2, A
  • 24. 04/25/14 DPD 24 Bit Directive LED BIT P1.7 HERE: CPL LED LCALL DELAY SJMP HERE SW BIT P1.7 LED BIT P2.0 HERE: MOV C, SW MOV LED, C SJMP HERE
  • 25. 04/25/14 DPD 25 Using EQU directive • A switch is connected to pin P1.7 • Write a program to check that status of the switch and make the following decision – If SW = 0, send “No” to P2 – If SW = 1, send “Yes” to P2 SW EQU P1.7 MYDATA EQU P2 HERE: MOV C, SW JC OVER MOV MYDATA, #’N’ MOV MYDATA, #’O’ SJMP HERE OVER: MOV MYDATA, #’Y’ MOV MYDATA, #’Y’ MOV MYDATA, #’Y’ SJMP HERE END