Thursday, March 7, 2019

FMA Unit 2.1 Addressing Modes of 8051



Addressing Modes
When the microcontrollers execute an instruction, it performs specific function on data. The data is stored at some source location. This data must be moved or copied to destination location. The ways these addresses location are specified are called as Addressing Modes.
Every Instruction consists of Opcode and Operand:-
Ø Opcode: It is operational code which contains all the information about which operation is to be performed, register used and memory location which is to be used.
Ø Operand: It is a data which is to be operated for a specific task.

Types of addressing modes:
A.         Immediate addressing mode 
B.         Direct addressing mode
C.         Register addressing mode
D.         Register indirect addressing mode 
E.          External addressing mode (Indexed addressing mode)



A.   Immediate addressing mode :
In this addressing mode transfers 8 bit immediate data to destination.
e.g
1. MOV A, #6BH (This instruction moves immediate data hex 6B to accumulator.)
2. MOV P1, #0FFH
3. MOV DPTR, #1234H
In this addressing mode we use '#' symbol to indicate immediate data. Here ‘#’ symbol indicates that operand is a data. If ‘#’ is not present then the hexadecimal number considered as a address.)

B.   Direct addressing mode: 
This is type of addressing mode; source operand is specified by its 8 bit addresses in an instruction after opcode.
e.g.
1.       MOV B, 20H (The instruction above moves value at address 20H memory location to register B.)
2.       MOV R0, 14H

C.   Register addressing mode:
This is type of addressing mode, the source operand is specified by the registers (R0 to R7, A, B)
e.g    
1.     MOV R0, A
2.     ADD A, R5
3.     MOV A, R5 (After execution of this instruction content of register R5 is get copied to location accumulator.)

D.   Register indirect addressing mode :
This is type of addressing mode; addresses of operand (data) are specified indirectly by a register (R0, R1, DPTR).
 e.g.  
1.  ADD A, @R0
2.  MOVX A, @DPTR
3.  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 accumulator.)
Here symbol '@' indicates address the register as a pointer. In this type addressing mode only register R0 and R1 to provide indirect address.

E.   External addressing mode (Indexed addressing mode) :
This is type of addressing mode; data accessed from external RAM or on chip ROM.
a. Code access (External ROM access):
Using these instruction only external memory can be accessed
Eg
1.     MOVC A, @A+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.
2.     MOVC A, @A+PC 
b. Data access (External RAM access):
                   Using this instruction, the programmer can access the external data memory.
Eg  MOVX @R0, A 

No comments:

Post a Comment