ADDRESSING
MODES OF 8086
Addressing mode indicates a 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, or some instruction may not belong to any of the addressing modes. Thus
the addressing modes describe the types of operands and the way they are
accessed for executing an instruction. Here, we will present the addressing
modes of the instructions depending upon their types. According to the flow of
instruction execution, the instructions may be categorized as
(i)
Sequential control flow instructions and
(ii)
Control transfer instructions.
Sequential control
flow instructions are the instructions, which after execution, transfer control
to the next instruction appearing immediately after it (in the sequence) in the
program. For example, the arithmetic, logical, data transfer and processor control
instructions are sequential control flow instructions. The control transfer
instructions, on the other hand, transfer control to some predefined address
somehow specified in the instruction after their execution. For example, INT,
CALL, RET and JUMP instructions fall under this category.
The addressing modes
for sequential control transfer instructions are explained as follows:
- Immediate: In this type of addressing, immediate data is a part of instruction, and appears in the form of successive byte or bytes.
Example: MOV AX, 0005H
In the above example,
0005H is the immediate data. The immediate data may be 8-bit or 16-bit in size.
- Direct: In the direct addressing mode, a 16-bit memory address (offset) is directly specified in the instruction as a part of it.
Example: MOV AX,
[5000H]
Here, data resides in
a memory location in the data segment, whose effective address may be computed
using 5000H as the offset address and content of DS as segment address. The
effective address, here, is 10H*DS+5000H.
- Register: In register addressing mode, the data is stored in a register and it is referred using the particular register. All the registers, except IP, may be used in this mode.
Example: MOV BX, AX.
- Register Indirect: Sometimes, the address of the memory location, which contains data or operand, is determined in an indirect way, using the offset registers. This mode of addressing is known as register indirect mode. In this addressing mode, the offset address of data is in either BX or SI or DI registers. The default segment is either DS or ES. The data is supposed to be available at the address pointed to by the content of any of the above registers in the default data segment.
Example: MOV AX, [BX]
Here, data is present
in a memory location in DS whose offset address is in BX. The effective address
of the data is given as 10H*DS+ [BX].
- Indexed: In this addressing mode, offset of the operand is stored in one of the index registers. DS and ES are the default segments for index registers SI and DI respectively. This mode is a special case of the above discussed register indirect addressing mode.
Example: MOV AX, [SI]
Here, data is
available at an offset address stored in SI in DS. The effective address, in
this case, is computed as 10H*DS+ [SI].
- Register Relative: In this addressing 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 and DI in the default (either DS or ES) segment. The example given before explains this mode.
Example: MOV Ax, 50H [BX]
Here, effective address is given as
10H*DS+50H+ [BX].
- Based Indexed: The effective address of data is formed, in this addressing mode, by adding content of a base register (any one of BX or BP) to the content of an index register (any one of SI or DI). The default segment register may be ES or DS.
Example: MOV AX, [BX]
[SI]
Here, BX is the base
register and SI is the index register. The effective address is computed as
10H*DS+ [BX] + [SI].
- Relative Based Indexed: The effective address is formed by adding an 8-bit or 16-bit displacement with the sum of contents of any one of the bases registers (BX or BP) and any one of the index registers, in a default segment.
Example: MOV AX, 50H
[BX] [SI]
Here, 50H is an
immediate displacement, BX is a base register and SI is an index register. The
effective address of data is computed as 160H*DS+ [BX] + [SI] + 50H.
For the control
transfer instructions, the addressing modes depend upon whether the destination
location is within the same segment or a different one. It also depends upon
the method of passing the destination address to the processor. Basically,
there are two addressing modes for the control transfer instructions, viz.
inter-segment and intra-segment addressing modes.
If the location to
which the control is to be transferred lies in a different segment other than
the current one, the mode is called inter-segment mode. If the destination
location lies in the same segment, the mode is called intra-segment.
Inter-segment Direct
Inter-segment
Inter-segment
Indirect
Modes for control
Transfer instructions
Intra-segment
Intra-segment Direct
Intra-segment
Indirect
Addressing Modes for Control Transfer Instruction
9. Intra-segment direct mode: In this mode,
the address to which the control is to be transferred lies in the same segment
in which the control transfer instruction lies and appears directly in the
instruction as an immediate displacement value. In this addressing mode, the
displacement is computed relative to the content of the instruction pointer IP.
The effective
address to which the control will be transferred is given by the sum of 8 or 16
bit displacement and current content of IP. In case of jump instruction, if the
signed displacement (d) is of 8 bits (i.e. –128<d<+128), we term it as
short jump and if it is of
16 bits (i.e. –32768<+32768), it is termed
as long jump.
10. Intra-segment Indirect Mode: In this
mode, the displacement to which the control is to be transferred, is in the
same segment in which the control transfer instruction lies, but it is passed
to the instruction indirectly. Here, the branch address is found as the content
of a register or a memory location. This addressing mode may be used in
unconditional branch instructions.
11. Inter-segment Direct Mode: In this mode,
the address to which the control is to be transferred is in a different
segment. This addressing mode provides a means of branching from one code
segment to another code segment. Here, the CS and IP of the destination address
are specified directly in the instruction.
12. Inter-segment Indirect Mode: In this
mode, the address to which the control is to be transferred lies in a different
segment and it is passed to the instruction indirectly, i.e. contents of a
memory block containing four bytes, i.e. IP (LSB), IP (MSB), CS (LSB) and CS
(MSB) sequentially. The starting address of the memory block may be referred
using any of the addressing modes, except immediate mode.
0 comments:
Post a Comment