What you will learn here 8051 addressing modes
- What is Operand
- What is Opcode
- What is addressing mode in 8051
- 8051 addressing modes
What is Operand
The operand is nothing but data on which operation is to be performed which is shown below
What is Opcode
The opcode is basically a machine code for instruction. The Opcode tells the processor which operation is to be performed on the operand or data which is shown below
What is addressing mode in 8051
Addressing modes are nothing but the different ways to specify operand or data in the instruction.
8051 addressing modes
8051 has 10 addressing modes. The addressing modes of 8051 are listed below
- Immediate addressing mode
- Register addressing mode
- Direct addressing mode
- Indirect addressing mode
- Relative addressing mode
- Absolute addressing mode
- Long addressing mode
- Indexed addressing mode
- Bit inherent addressing mode
- Bit direct addressing mode
Immediate addressing mode in 8051
Immediate addressing mode in 8051 data or operand is provided as part of the instruction. The example of the immediate addressing mode is shown below. In the below example immediate data 55H is moved to the accumulator. In immediate addressing mode # symbol represents immediate data.
Register addressing mode in 8051
In register addressing mode in 8051, general purpose register holds the data or operand which is shown below. In register addressing mode example, data or value stored in register R1 is moved to the accumulator. The general purpose register R0- R7 is selected from the register bank. The default register bank is bank 0.
Direct addressing mode in 8051
Direct addressing mode allows user to access the internal memory. In Direct addressing mode, memory address is specified as part of the instruction which is shown below. In direct addressing 8 bits are used used to specify internal memory address. In direct addressing mode, we can specify the address only in the range of 00H to FFH. In this addressing mode, data or operand is directly obtained from the memory.
Indirect addressing mode in 8051
The indirect addressing mode uses a register to hold the actual address that will be used in data movement. In 8051, @ symbol represents indirect addressing which is shown below. Registers R0 and R1 and DPTR are the only registers that can be used as data pointers. Indirect addressing cannot be used to refer to SFR registers. Both R0 and R1 can hold 8 bit address and DPTR can hold 16 bit address.
Relative addressing mode in 8051
Relative addressing mode in 8051 is used with conditional jump instruction. The relative addressing mode used to take execuation control to another place. We all know, program counter holds the address of the next instruction to be executed. The relative address, (offset), is an 8 bit signed number, which is automatically added to the Program Counter to make the address of the next instruction which is to be executed. The 8 bit signed offset value gives an address range of +127 to —128 locations. The example of relative addressing mode is shown below.
Absolute addressing mode in 8051
The Absolute addressing mode in 8051 is used with absolute jump (AJMP) and absolute call (ACALL) instructions. AJMP and ACALL instructions are 2 bytes instructions. In the absolute addressing mode lowest 11 bits are specified as part of instruction. The upper 5 bits of destination address are the upper 5 bits of the current program counter. The absolute addressing allows jumping or branching within the 2K program memory space starting from 0800H to 0FFFH.
Long addressing mode in 8051
The long addressing mode in 8051 is used with long jump (LJMP) and long call (LCALL) instructions. LJMP and LCALL are 3 bytes instructions. The destination memory address is 16 bits address so that jump can be made within 64K bytes memory space.
Indexed addressing mode in 8051
In indexed addressing mode in 8051, either program counter or data pointer is used to hold the base address and Accumulator is used to hold offset address. In indexed addressing base addressing along with offset address forms the effective or final address. The example of indexed addressing is shown below.
Bit inherent addressing mode in 8051
In Bit inherent addressing mode in 8051, the address of the flag which contains the operand, is implied in the opcode of the instruction. The example of bit inherent addressing mode is show below
Bit direct addressing mode in 8051
Bit direct addressing mode in 8051,the direct address of the bit is specified in the instruction. The RAM space 20H to 2FH and most of the special function registers are bit addressable. Bit address values are between 00H to 7FH. The example of Bit direct addressing mode is shown below