Addressing modes in Intel 8086

The Intel 8086 microprocessor supports several addressing modes, which determine how the processor calculates the effective address of instruction operands. Addressing modes are crucial for accessing data in memory, in registers or immediate values. Below is a detailed description of the addressing modes in the 8086:

Register addressing

Description: the operand is in a register.

Syntax: mov ax, bx

Example: mov ax, bx ; copies the contents of BX into AX

Application: the fastest way to access data, since the registers are internal to the processor.

Immediate addressing

Description: the operand is a constant value specified directly in the instruction.

Syntax: mov ax, 1234h

Example: mov ax, 1234h ; load AX with the immediate value 1234h

Application: useful for loading constants or initialising registers.

Direct addressing

Description: the address of the operand is specified directly in the instruction.

Syntax: mov ax, [1234h]

Example: mov ax, [1234h] ; load AX with the contents of memory cell 1234h

Application: access to fixed memory cells.

Register indirect addressing

Description: the address of the operand is stored in a register.

Syntax: mov ax, [bx]

Example: mov ax, [bx] ; load into AX the contents of the memory cell pointed to by BX

Application: access to memory cells whose addresses are calculated at run time.

Based addressing

Description: the address of the operand is calculated by adding a base register (BX or BP) to the offset.

Syntax: mov ax, [bx+10h]

Example: mov ax, [bx+10h] ; load AX with the contents of the memory cell at address BX + 10h

Application: access to arrays or structures whose base address is known.

Indexed addressing

Description: the address of the operand is calculated by adding an index register (SI or DI) to the offset.

Syntax: mov ax, [si+20h]

Example: mov ax, [si+20h] ; load into AX the contents of the memory cell at address SI + 20h

Application: access to arrays or strings where the index is known.

Based indexed addressing

Description: the address of the operand is calculated by adding a base register (BX or BP) and an index register (SI or DI) to the offset.

Syntax: mov ax, [bx+si+30h]

Example: mov ax, [bx+si+30h] ; load AX with the contents of the memory cell at address BX + SI + 30h

Application: access to complex data structures such as multidimensional arrays.

String addressing

Description: used specifically for string operations. The source operand is addressed using SI, and the destination operand using DI.

Syntax: movsb

Example: movsb ; move a byte from DS:SI to ES:DI and increment SI and DI

Application: efficient moving or comparing of strings.

I/O port addressing

Description: used for input/output operations. The operand is the I/O port address.

Syntax: in al, 20h

Example: in al, 20h ; read a byte from I/O port 20h into AL; out 20h, al ; write a byte from AL to I/O port 20h

Application: communication with external devices.

Implied addressing

Description: the operand is implied by the instruction itself.

Syntax: stc

Example: stc ; set the carry flag (CF)

Application: instructions that operate on specific registers or flags.

Relative addressing

Description: the address of the operand is calculated relative to the current value of the instruction pointer (IP).

Syntax: jmp short label

Example: jmp short label ; jump to label within the short range (-128 to +127 bytes)

Application: implementation of loops and conditional jumps.

Conclusion

The 8086 microprocessor supports a wide range of addressing modes, providing flexibility and efficiency in accessing data. Understanding these addressing modes is essential for writing efficient assembly language programs and optimising memory access. Each addressing mode has its own application, and the choice of a suitable mode depends on the specific requirements of the program.