Addressing modes of 8086

The way in which an operand is given to an instruction is known as addressing mode. Addressing modes do exist in every processor and microcontroller, however they vary little. There are various types of addressing modes in 8086, and important ones are immediate addressing mode, register addressing mode, direct addressing mode, indirect addressing mode and implied addressing mode. To access more articles about 8051 Click here.

  • Immediate addressing mode.
  • Register addressing mode.
  • Direct addressing mode.
  • Indirect addressing mode.
  • Implied addressing mode.

Immediate addressing mode in 8086

In this type of addressing modes in 8086, direct data is given to instruction to perform operation. Data and address of a location looks the same( both are numbers ). So both of them are differentiated by something. Data is given directly , where as an address is given inside the square brackets. 

  •  MOV CL , 16H ; this instruction means move data ( 16H ) to register CL,  location of 16H is not defined here.
    CL ←16H ; CL is an 8-bit register, so we can give only 8-bit data.
  • MOV CX, 202AH
    CX ← 202AH ; CX is a 16-bit register, 202A is also a 16-bit number. 

In any addressing mode, the processor fetches instruction , decodes the instruction and executes it. However in this type of addressing mode , processors immediately can fetch data ( operand ), so this is known as immediate addressing mode

Register addressing mode in 8086

In this type of addressing mode, instead of giving the data directly, the register name is given. Data from one register is moved to another register, data doesn’t get erased from the first register. Generally the data is stored in general purpose registers, thus it is named as register addressing mode

MOV CL , BL  ; it means access to the data is moved from register A to register R1. However the data is not removed from A register, it is just copied.

MOV BX , CX;
BX ← CX

Direct addressing mode in 8086

In this type, the address of the data location is given in the instruction.

MOV CL , [ 25H ]  ; data from 25H  location is given to register CL.
CL ← [ 25H ]

Here [ ]  is used, because it is an address.

MOV CX , [ 202AH ]  ; CX is a 16-bit register, but location 202AH has only 8-bit of data.
CL ← DS : [ 202AH ]
CH ← DS : [ 202BH ]
Here DS is the data segment address and 202A is the offset address.
In memory most of the operations take place in data segment only, until unless specified. And as in memory banking, 16-bit of data is stored in two consecutive locations.

Indirect addressing mode in 8086

There are four types of Indirect addressing modes. Basically indirect addressing mode means giving the location of the target indirectly. We give the location of data through a register. Not all registers can be used to give locations.
Only BX, SI, DI, BP are the registers that can be used to store locations. 

Register Indirect addressing mode in 8086

The location of the target is stored in the register.
MOV CL , [ BX ] ; CL ← DS : [ BX ] If BX = 100H , then CL will get the value from 100H
MOV CX, [ BX ] ; CL ← DS : [ BX ]
CH ← DS : [ BX + 1 ]

Why is indirect addressing mode when direct addressing mode is simple?

Simple things aren’t always best! Using direct addressing mode we can perform single byte operations only. In microcontrollers we don’t perform single byte operations. Using indirect addressing mode we can perform operations like loops.

Let’s consider an example of an array which holds 100 values. 

Array[0] = 1
Array[1] = 2
Array[2] = 3
.
.
.
Array[99] = 100

Addressing Modes of 8086 | Immediate addressing mode

As shown in the picture, In indirect addressing mode we can set the value of i and increment it and then add total code in a loop. So indirect addressing mode is used to move multiple bytes of data. Instead of A consider CL register.  Indirect Addressing modes are further classifies as

Register relative indirect addressing mode in 8086

In register indirect addressing mode, address is given using only register. Here a constant is added to it.
MOV CL, [ BX + 12H ] ;
suppose BX = 05H , then 05H + 12H = 17H . Which means data from location 17H will be moved to the CL register. This summed up address was the relative of address stored in BX register, thus it was named as register relative indirect addressing mode.

MOV CX , [ BX + 12H, ] ;
CL ← DS : [ BX + 12H ]
CH ← DS : [ BX + 12H + 01H ]

MOV CX , [ BP + 12H ];
CL ← SS : [ BX + 12H ]
CH ← SS : [ BX + 12H + 01H ]
In this example we used BP register to store address, so this operated in the stack segment of memory.
The maximum limit of a segment is FFFFH , if we are adding a number which exceeds the limit, then it bounces back to 0000H.

Base indexed indirect addressing mode in 8086

Here instead of adding numbers to the register, another register is added.

MOV CL , [ BX + SI ] ;
CL ← DS : [ BX + SI ]

MOV CL, [ BP + SI ];
CL ← SS : [ BP + SI ]

Base relative indirect addressing mode in 8086:

It is the combination of base indexed indirect addressing mode and register relative indirect addressing mode.

MOV CX , [ BX + SI + 12H ] ;
CL ← DS : [ BX + SI + 12H ]
CH ← DS : [ BX + SI + 12H + 1H ]

MOV CL , [ BP + SI + 12H ] ;
CL ← SS : [ BP + SI + 12H ]

Implied addressing mode:
Few instructions in 8086 are meant for particular things only, where we cannot give an operand.

STC ;
CF ← 1 STC stands for Set The Carry flag, instruction itself says everything.

CLC ;
CF ← 0 CLC stands for CLear the Carry flag

Note:

  • All the addresses given in brackets are offset addresses, refer to the memory segmentation tutorial.
  • MOV operation works on a data segment by default. 
  • SI and DI are index registers.
  • The segment to be operated is decided by base register ( BX & BP ) not index register( SI & DI ).

These were addressing modes of 8086.

Related topic:
Addressing modes of 8051
Addressing modes in ARM
Addressing modes in 8085
Read wikipedia page of 8086.

Spread knowledge

Leave a Comment

Your email address will not be published. Required fields are marked *