8051 Microcontrollers Addressing Mode Notes by NK Sinha
8051 Microcontrollers Addressing Mode Notes by NK Sinha
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
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
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
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
N. V. SINHA, LDCE 9
https://codembedded.wordpress.com
N. V. SINHA, LDCE 10