0% found this document useful (0 votes)
26 views10 pages

8051 Microcontrollers Addressing Mode Notes by NK Sinha

The document provides an overview of the addressing modes used in the 8051 microcontroller, detailing immediate, register, direct, indirect, and indexed addressing modes. It explains how operands are accessed and includes examples of instructions for each mode. Additionally, it highlights the importance of proper memory addressing and the use of registers as pointers in data transfer operations.

Uploaded by

ytpremium8904
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views10 pages

8051 Microcontrollers Addressing Mode Notes by NK Sinha

The document provides an overview of the addressing modes used in the 8051 microcontroller, detailing immediate, register, direct, indirect, and indexed addressing modes. It explains how operands are accessed and includes examples of instructions for each mode. Additionally, it highlights the importance of proper memory addressing and the use of registers as pointers in data transfer operations.

Uploaded by

ytpremium8904
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

8051 Microcontroller

Addressing Modes
Subject: MICROPROCESSORS AND MICROCONTROLLERS Code: 3160914

Prof. N. V. Sinha
Associate Professor
Dept. of Electrical Engineering
L. D. College of Engineering

N. V. SINHA, LDCE
• Any statement is made up of two parts – (Instruction or task to
be performed) and (Data on which task is to be performed)
• The different ways in which an operand is accessed are known as the
addressing modes

Addressing
modes

Immediate Register Direct Indirect Indexed


Addressing Addressing Addressing Addressing Addressing
Mode Mode Mode Mode Mode

N. V. SINHA, LDCE 2
• Specify data by its value
• Operand comes immediately after the op-code
• Data must be preceded by ‘#’ sign
• Loads information in any of the registers, including the DPTR
Opcode / Data
Instruction value

• MOV A,#34H // load 34H in A


• MOV R4,#26H // load 26H in R4
• MOV DPTR,#1234H // load 1234H in DPTR
• MOV R0,#0AAH // load AAH in R0
N. V. SINHA, LDCE 3
• Registers hold the data to be transferred
• Data is copied into the destination, source is not modified
• Reg to reg MOVs occur between A and R0 – R7
• Values cannot be destinations

Opcode / Source or Destination Registers


Instructions

• MOV A,R0 // copy the content of R0 in A


• MOV R0,A // copy the content of A in R2
• ADD A,R5 // add the content of R5 to content of A
• MOV R5,DPL // copy the content of DPL in R5
N. V. SINHA, LDCE 4
• Data is in a RAM memory location whose address is known
• This address is given as a part of the instruction
• Usually the addresses are in the range of 30h to 7Fh

Opcode / Source or Destination


Address in
Instructions RAM

• MOV R0, 40H // save content of RAM location 40h into R0


• MOV 56H, A // save content of A in RAM location 56H

N. V. SINHA, LDCE 5
• All registers (GPRs and SFRs) and memory locations are on the chip
physically
• Direct Addresses above 7FH that are not SFRs will generate an error
• If source and destination are the same it could lead to errors
• By default SP is set to 07H, growing stack will overwrite registers
above Bank0
• Ensure SP is set to an address above the working range
• R7 is not used in the direct addressing mode
N. V. SINHA, LDCE 6
• Register is used as a pointer to the data
• Only register R0 and R1 are used for this purpose
• When R0 and R1 are used as pointers, ie when they hold the address
of RAM locations, they must be preceded by “@” sign

Opcode /
Instructions Source or Destination (@) R0 or R1 RAM address
(@Rn)

N. V. SINHA, LDCE 7
• MOV A,@R0 // move contents of RAM location whose address is held
by R0 into A

• MOV @R1,B // move contents of B RAM location whose address is


held by R1

N. V. SINHA, LDCE 8
• Uses DPTR / PC for 16-bit addresses
• MOVX is used for data transfer with external locations
• MOV DPTR, #9000H // loads 9000H into DPTR
• MOVX A, @DPTR // loads the value stored at memory location 9000H
into A

• MOVC is used if the data is stored in the space ROM of 8051


• Generally used in accessing data elements of look-up table entries located in ROM space of the
8051
• Content of A is added to the 16-bit register DPTR / PC to form the 16-bit address of the needed
data
• MOVC A, @A + PC
• MOVC A, @A + DPTR

N. V. SINHA, LDCE 9
https://codembedded.wordpress.com
N. V. SINHA, LDCE 10

You might also like