Addressing Modes of 8051
Addressing Modes of 8051
In this section, we will see different addressing modes of the 8051 microcontrollers. In 8051
there are 1-byte, 2-byte instructions and very few 3-byte instructions are present. The opcodes
are 8-bit long. As the opcodes are 8-bit data, there are 256 possibilities. Among 256, 255
opcodes are implemented.
The clock frequency is12MHz, so 64 instruction types are executed in just 1 µs, and rest are just 2
µs. The Multiplication and Division operations take 4 µsto to execute.
Immediate AddressingMode
Register AddressingMode
Direct AddressingMode
Register IndirectAddressing Mode
Indexed AddressingMode
Implied AddressingMode
MOVA, #0AFH;
MOVR3, #45H;
MOVDPTR, #FE00H;
In these instructions, the # symbol is used for immediate data. In the last instruction, there is
DPTR. The DPTR stands for Data Pointer. Using this, it points the external data memory location.
In the first instruction, the immediate data is AFH, but one 0 is added at the beginning. So when
the data is starting with A to F, the data should be preceded by 0.
Page 2 of 4
MOVA, R5;
MOVR2, #45H;
MOVR0, A;
In 8051, there is no instruction like MOVR5, R7. But we can get the same result by using this
instruction MOV R5, 07H, or by using MOV 05H, R7. But this two instruction will work when the
selected register bank is RB0. To use another register bank and to get the same effect, we have
to add the starting address of that register bank with the register number. For an example, if the
RB2 is selected, and we want to access R5, then the address will be (10H + 05H = 15H), so the
instruction will look like this MOV 15H, R7. Here 10H is the starting address of Register Bank 2.
Explore our latest online courses and learn new skills at your own pace. Enroll and become a
certified expert to boost your career.
MOV80H, R6;
MOVR2, 45H;
MOVR0, 05H;
The first instruction will send the content of registerR6 to port P0 (Address of Port 0 is 80H). The
second one is forgetting content from 45H to R2. The third one is used to get data from Register
R5 (When register bank RB0 is selected) to register R5.
MOV0E5H, @R0;
Page 3 of 4
MOV@R1, 80H
In the instructions, the @ symbol is used for register indirect addressing. In the first instruction, it
is showing that theR0 register is used. If the content of R0 is 40H, then that instruction will take
the data which is located at location 40H of the internal RAM. In the second one, if the content of
R1 is 30H, then it indicates that the content of port P0 will be stored at location 30H in the
internal RAM.
MOVXA, @R1;
MOV@DPTR, A;
In these two instructions, the X in MOVX indicates the external data memory. The external data
memory can only be accessed in register indirect mode. In the first instruction if the R0 is holding
40H, then A will get the content of external RAM location40H. And in the second one, the content
of A is overwritten in the location pointed by DPTR.
MOVCA, @A+PC;
MOVCA, @A+DPTR;
The C in MOVC instruction refers to code byte. For the first instruction, let us consider A holds
30H. And the PC value is1125H. The contents of program memory location 1155H (30H + 1125H)
are moved to register A.
RLA;
SWAPA;
These are 1- byte instruction. The first one is used to rotate the A register content to the Left. The
second one is used to swap the nibbles in A.