Addressing mode in 8085 microprocessor

What is a Microprocessor?

Microprocessor is a unit which is able to perform arithmetic and logical operations and is built on a single chip.

The 8085 microprocessor is built by Intel which is an 8 bit microprocessor.

An 8-bit data bus is present on the 8-bit CPU.

There are a lot of operations in a microprocessor and generally each instruction has the source operand and destination operand. Addressing mode refers to how operands are specified for the instruction. The 8085 microprocessor supports the following categories of addressing modes:

  1. Immediate addressing mode
  2. Register addressing mode
  3. Direct addressing mode
  4. Indirect addressing mode
  5. Implied addressing mode

1. Immediate addressing mode

 In immediate addressing mode, data is always the source operand. When the data is 8 bits, the instruction will be 2 bytes long; when the data is 16 bits, it will be 3 bytes long.

In 8085 microprocessor instruction, if the instruction’s opcode is ending with letter ‘I’ then it is defined as immediate addressing mode.

Syntax:     

 MVI   destination_register   Data     [For move instruction]

There are general purpose registers which can be used as destination register and data can be of 8bit or 16 bit.

Example:   MVI A, 20H

It means transfer the data (20H) hexadecimal form into the accumulator. If the accumulator has any data before then it will be overridden by the data 20H.

Example:    LXI H 3225

It means Load the immediate data to HL register pair.

2. Register addressing mode

The data that has to be operated upon is present inside the register when using register addressing mode, as are the operands. Data is copied from one register to another in this manner.

Syntax: 

MOV destination_register   source_register

Example: MOV B, C

Here, register C is the source register, and register B is the destination register. Let suppose the register C has value 10H so, now this data will be copied into the register B.

So, after this operation Register C=10H and Register B=10H.

Example:  ADD B

Above instruction is an arithmetic operation, and in 8085 arithmetic operation, it is done by accumulator. So by default the destination and one operand is already register A (or accumulator) and another operand is register B.

Before this instruction:  Accumulator = 02H

                                        Register B=03H

Instruction: A=A+B

After this instruction:     Accumulator=05H

                                        Register=03H

Example: INR D

Above instruction has only one operand and that is register D. Above instruction is used to increment the value of any register contained.

Let’s suppose D has the data 02H before this instruction and after this D=02+1(03H).

3. Direct addressing mode

The data that has to be operated upon is present at a memory location, which is directly supplied as an operand in the direct addressing mode.

Syntax:               

LDA memory_location

For Example:              LDA 2134H

Above instruction will fetch the data from memory location 2134 and the data which is placed at location 2134 will be loaded into the accumulator.

For Example:                LHLD 3060H

Above instruction means the data which is placed at memory location at 3060 will be placed in HL register pair. It will definitely be 16 bit data (8bit for register H and 8 bit for register L).

4. Indirect addressing mode

 In this addressing mode, the data which we want to use will be available at any memory location and that memory location will be specified indirectly (by using the register's contents).

For Example: MOV A,M

Above instruction means the HL pair (16 bit) will have combined data of 16 bit so they will represent a memory location. The data at that memory location will be copied into accumulator.

Let suppose Register H=20H

                     Register L=30H

They combined represent the data 2030H, so the data which is placed at memory location 2030H will be copied into the accumulator.

For example:                  STAX B

Above instruction means that the memory location represented by the BC register pair, will be stored by the value present at the accumulator.

Let’s suppose accumulator has value 14H and register B has value 22H and register C has value 32H.

So, at memory location 2232H the data 14H will be stored. (register to memory transfer)

5. Implied addressing mode

In this mode, only opcode is present and no data or no operands are needed in this type of instruction.

For Example: RRC which means “rotate the bits of the accumulator right by 1 bit”, and RLC which means “rotate the bits of the accumulator left by 1 bit”.