8051 Addressing Mode
8051 Addressing Mode
Immediate addressing
In this addressing mode, the data to be manipulated is given in the instruction itself. The data is
preceded by the # symbol.
e.g. ADD A, #80H
This instruction adds the data 80H to the contents of the accumulator and the result is stored in
the accumulator itself. This addressing mode is used when the data for the arithmetic and logical
operation is needed only once and is a constant.
The value stored in the register R0 is now the address of the memory location of the data to be
fetched. From this memory location, the data is fetched and the instruction is executed. The DPTR
is used to access the data in the external memory with 16 bit addresses. The indirect addressing
mode is very useful for accessing data that are stored in consecutive memory locations and
accessed serially in the program.
Indexed addressing
In this type of addressing, the instruction consists of two parts- a base address and in offset. This
type of addressing is useful in relative memory accessing and relative jumping. The base address
is stored in the DPTR or any other register. The offset value is stored in the accumulator.
e.g. MOVC A, @A+DPTR
This instruction adds the contents of the accumulator to the contents of the data pointer and the
results forms the actual address from where data is to be fetched. This data is moved to the
accumulator.