Addressing Modes of 8051

What is an addressing modes ?

In short ,a way to addressing a operand is nothing but addressing mode. Operand means data on which we are going to operate i.e source data. We can address the operand using direct address or by using register or we can address the data using some numerical value etc. e.g. MOV A,#6BH
In this example 6BH  is operand i.e. source data. After execution of this instruction 6BH is added to the accumulator.We can execute this instruction by using 5 different ways i.e we can use 5 different addressing modes to execute this instruction. Following are the different type of addressing modes.
  •  Immediate addressing mode 
  •  Direct addressing mode
  •  Register addressing mode
  •  Register indirect addressing mode 
  •  Indexed addressing mode.

Immediate addressing mode :

As word indicate 'immediate' this addressing mode transfer 8 bit immediate data to destination .
e.g MOV A, #6BH
This instruction moves immediate data hex 6B to accumulator.
In this addressing mode we use '#' symbol to indicate immediate data. In the example given above ‘#’ symbol before 6BH indicates that operand is a data. If ‘#’ is not present then the hexadecimal number considered as a address.

Direct addressing mode : 

This is type of addressing mode in which the address of the data (source data ) is given as operand.. i.e. it is given directly in the form of numerical data.
e.g. MOV B,20H
The instruction above moves value at address 20H memory location to register B . Here 20H is address of SFR.
The difference between direct addressing and immediate addressing mode is, we don't use ‘#’ in direct addressing mode, unlike immediate mode.

Register addressing mode :

This is type of  addressing mode in which we use the register name directly as source data.
e.g MOV A, R5
After execution of this instruction content of register R5 is get copied to location accumulator.

Register direct addressing mode :

In this mode of addressing address of source data is given by value at register indirectly that's y  we call it as a indirect register addressing mode.
e.g. MOV A,  @R1
Here in this instruction register R1 holds the address, suppose value at R1 is '20H' then after execution of above instruction value at location 20H is transferred to to accumulator. Here symbol '@' indicates address. In this type addressing mode we can use only register R0 and R1 to provide indirect address.

Indexed addressing mode :

In this type of addressing mode we use following instruction :
1. MOVC A, @A+DPTR  and  2. MOVC A, @A+PC 
'MOVC A, @A+DPTR' instruction copies value at the location given by result of addition of content of accumulator and 16 bit register DPTR. Suppose Accumulator contain '01H' and DPTR contains value '1000H' then after the execution of instruction 'MOVC A, @A+DPTR the value at address '1001H' will be transferred to accumulator.
'MOVC A, @A+PC'  instruction copies value at the location given by result of addition of content of accumulator and 16 bit register PC (Program counter). Suppose Accumulator contain '01H' and PC contains value '1000H' then after the execution of instruction 'MOVC A, @A+DPTR the value at address '1001H' will be transferred to accumulator.









Comments

Popular posts from this blog

Using the TLP250 Isolated MOSFET Driver - Explanation and Example Circuits

Best way to fix SVN error "Could not start external diff program"

N-Channel MOSFET High-Side Drive: When, Why and How?