4. IMMEDIATE ADDRESSING MODE
• The data will be specified directly in the source operand.
• Since 8051 Microcontroller is a 8 bit microcontroller, only 8 bit data (2 decimal digits) can
be specified.
• The immediate data will be followed by the symbol #
Example:
MOV A, #04H- The 8 bit data 04H will be moved to accumulator (A) register.
MOV R3, #0AE H- The 8 bit data AE is moved to R3 register.
Note: In 8051, A, B and R0-R7 registers will be generally used.
Also, whenever the data starts from A to F, the data must be preceded by 0.
Before Execution After Execution
The value of A---->09 The value of A---->04
5. REGISTER ADDRESSING MODE
• In this mode, both source and destination operands are registers.
Example:
MOV A, R0- The data which resides in R0 register is moved/copied to A register.
ADD A, R1- The data in R1 register and A register are summed up and the result is stored
in A register.
Note: Both the source and the destination operand cannot be register banks(R0-R7). For eg,
MOV R3,R7 is not possible. The sequence can be,
MOV A, R7
MOV R3, A
Before Execution After Execution
The value of A---->0C
The value of R0--->09
The value of A---->09
The value of R0--->09
Before Execution After Execution
The value of A---->0C
The value of R1--->09
The value of A---->15
The value of R1--->09
6. DIRECT ADDRESSING MODE
• Here the address of the data is specified either in source operand or destination operand.
Example:
MOV R2, 04 - The data which resides in memory location 04H is moved to R2 register.
Don’t use # symbol, otherwise 04 becomes data rather than address.
Only the internal memory address (00 to 7F) will be used in this mode.
Assume the data in 04 address----> 0C.
Before Execution After Execution
The value of R2---->09 The value of R2---->0C
7. REGISTER INDIRECT ADDRESSING MODE
• As the name suggests, the address of the memory location which contains the data (will be
enclosed in square brackets) is specified by registers.
• The @ symbol in the instruction specifies this addressing mode.
• Only R0 and R1 registers can be accessed via this mode.
Example:
MOV A, @R0-Assume the R0 register is pointing to location 80H. Then the value say 0E
in 80H is moved to A register.
MOV @R1, 85-Assume the value in 85H is 02. This data is moved to the memory location
pointed by R1 register.
In other words, this example moves data from one location to another location.
Before Execution After Execution
The value of A--->0C The value of A---->0E
8. INDEXED ADDRESSING MODE
• In this mode, the effective address is formed by summing up the base register and
accumulator register.
• Base registers-PC (Program counter), DPTR (Data pointer register)
• The destination operand will be always A register.
• The source memory can be accessed only by program memory which is represented by
letter C (means code) in the instruction.
Example:
MOVC A, @A+PC- Assume the A register holds the value 07H and the PC has the value
4100H. Then, the data in memory location 4107H(4100+07) is moved to A register.
MOVC A, @A+DPTR- The same explanation holds good for this instruction also.