Addressing modes indicates way of locating data or operands. Depending upon the data types used in the instruction and the memory addressing modes, any instruction may belong to one or more addressing modes. Thus the addressing modes describe the types of operands and the way they are accessed for executing an instruction.
According to the flow of instruction execution, the instruction may be categorized as:
- Sequential Control flow instructions
- Control Transfer instructions
1. Sequential Control flow instructions
In this type of instruction after execution control can be transferred to the next immediately appearing instruction in the program.
The addressing modes for sequential control transfer instructions are as follows:
- Immediate addressing mode: In this mode, immediate is a part of instruction and appears in the form of successive byte or bytes.
- Example: MOV CX, 0007H; Here 0007 is the immediate data
- Direct Addressing mode: In this mode, the instruction operand specifies the memory address where data is located.
- Example: MOV AX, [5000H]; Data is available in 5000H memory location
- Effective Address (EA) is computed using 5000H as offset address and content of DS as segment address. EA=10H*DS+5000H
- Register Addressing mode: In this mode, the data is stored in a register and it is referred using particular register. All the registers except IP may be used in this mode. Example: MOV AX, BX;
- Register Indirect addressing mode: In this mode, instruction specifies a register containing an address, where data is located. This addressing mode works with SI, DI, BX and BP registers. Example: MOV AX, [BX]; EA=10H * DS +[BX]
- Indexed Addressing mode: 8-bit or 16-bit instruction operand is added to the contents of an index register (SI or DI), the resulting value is a pointer to location where data resides. DS and ES are default segments for index registers SI and DI. DS=0800H, SI=2000H, MOV DL, [SI] Example: MOV AX, [SI]; EA=10H * DS + [SI]
- Register Relative Addressing mode: In this mode, the data is available at an effective address formed by adding an 8-bit or 16-bit displacement with the content of any one of the registers BX, BP, SI, DI in the default segments.
Example: MOV AX, 50H [BX];
EA=10H * DS + 50H +[BX]
- Based Indexed Addressing mode: In this mode, the contents of a base register (BX or BP) is added to the contents of an index register (SI or DI), the resulting value is a pointer to location where data resides. Example: MOV AX, [BX] [SI];
EA=10H * DS + [BX] + [SI]
- Relative Based Indexed Addressing mode: In this mode, 8-bit or 16-bit instruction operand is added to the contents of a base register (BX or BP) and index register (SI or DI), the resulting value is a pointer to location where data resides.
Example: MOV AX, 50H [BX] [SI];
2. Control Transfer Instructions:
In control transfer instruction, the control can be transferred to some predefined address or the address somehow specified in the instruction after their execution.
- For the control transfer instructions, the addressing modes depend upon whether the destination location is within the segment or different segments. It also depends upon the method of passing the destination address to the processor. Depending on this control transfer instructions are categorized as follows:
- EA=10H * DS + 50H + [BX] +[SI]
- segment Direct mode: In this mode, the address to which control is to be transferred lies in the same segment in which control transfer instruction lies and appears directly in the instruction as an immediate displacement value.
- Intra segment Indirect mode: In this mode, the address to which control is to be transferred lies in the same segment in which control transfer instruction lies but it is passed to the instruction indirectly.
- Inter segment Direct mode: In this mode, the address to which control is to be transferred lies in a different segment in which control transfer instruction lies and appears directly in the instruction as an immediate displacement value.
- Inter segment Indirect mode: In this mode, the address to which control is to be transferred lies in a different segment in which control transfer instruction lies but it is passed to the instruction indirectly.