• Every instruction of a program has to operate on data.
• The method of specifying the data to be operated by the instruction is called addressing.
• The 8031 has the following types of addressing.
1. Immediate Addressing
2. Direct Addressing
3. Register Addressing
4. Register Indirect Addressing
5. Implied Addressing
6. Relative Addressing
1. IMMEDIATE ADDRESSING :
In immediate addressing mode, an 8/16 bit immediate data/constant is specified in the instruction itself.
MOV A, #6CH:- Move the immediate data 6CH given in the instruction to A-register.
MOV DPTR, #0100H:- Load the immediate 16-bit constant given in the instruction in DPTR (Data pointer). This constant will be an address of data memory location.
2. DIRECT ADDRESSING :
In direct addressing mode, the address of the data is directly specified in the instruction.
The direct address can be the address of an internal data RAM location (00H to 7FH) or the address of a special function register (80H to FFH).
MOV A, 07 H:- The address of the R7 register of bank-0 is 07. This instruction will move the content of the R7 register to A-register (Accumulator).
3. REGISTER ADDRESSING :
In register addressing mode, the instruction will specify the name of the register in which data is available.
MOV R2, A:- The content of A-register (accumulator) is moved to register R2.
4. REGISTER INDIRECT ADDRESSING :
In this mode, the instruction specifies the name of the register in which the address of the data is available. The internal data RAM locations (00H to 7FH) can be addressed indirectly through registers R1 and R0. The external RAM can be addressed indirectly through DPTR.
MOV A, @R0:- The internal RAM Location R0 holds the address of data. The content of the RAM location addressed by R0 is moved to A-register (Accumulator).
5. IMPLIED ADDRESSING :
In implied addressing mode, the instruction itself specifies the data to be operated by the instruction.
CPL C:- Complement carry flag.
6. RELATIVE ADDRESSING:
In relative addressing mode, the instruction specifies the address relative to the program counter.
The instruction will carry an offset whose range is -l2810 to +l2710.
The offset is added to the PC to generate the 16-bit physical address.
JC Offset:- If carry is one then the program control jumps to an address obtained by adding the content of the program counter and offset value in the instruction.