Friday, June 28, 2013

addressing mode of  8051 micro-controller

what is addressing mode?
CPU access data from memory,register,immediate value.These various  way to access data are called addressing mode.
The 8051 micro-controller are five addressing mode.
  1. immediate
  2. register
  3. direct
  4. register indirect
  5. index
Immediate:
  • in this addressing mode source operand is constant.
  • it's come after op code in instruction.
  • it must be preceded by "#" .
  • its used to load data into register.
  • examples:
  1. MOV A,#32H                                         ;Load 32h into A register.
  2. MOV DPTR,#1234H                              ;Load 1234h into DPTR.
Register:
  • In this mode registers are used to hold data to be manipulated.
  • Size of destination register and source register are always equal.
  • the data between to registers Rn(n=0 to 7) and Rn(n=0 to7) do not transfer.
  • examples:
  1. MOV A,R0               ;copy content of R0 into A.
  2. MOV R0,R1             ;not possible because data to be processed in some memory location of RAM.
  Direct:
  • to access data directly form RAM location.
  • using this mode we can access 128Byte RAM directly.
  • in this data is in a RAM memory location whose address is known.
  • the difference between immediate and direct addressing mode is "#"sign.in this mode this sign is absent.
  • examples:
  1. MOV R0,30H                                                  ;save content of RAM location 30h into R0.
  2. MOV 7,2                                                          ;invalid (it means copy content of R2 into R7).
Register indirect:
  • in this register used as pointer to the data.
  • only register R0 and R1 used in this mode.
  • R0 and R1 hold address of RAM location.
  • both register must be preceded by "@"sign.
  • looping is easily used in this mode.
  • drawback of this mode is we can used two register R0 & R1 only.
  • examples:
  1. MOV A,@R0                ;move content of RAM location whose address stored in R0.
  2. MOV @R1,A                ;move content of A into RAM location whose address stored in R1.
 index :
  • in this mode data access from look up table entire located in the program memory ROM space of 8051.
  • register A and DPTR used in this addressing mode.
  • here instruction MOVC used instead of MOV because C indicate Code memory(ROM).
  • examples:
  1. MOVC A,@A+DPTR;

0 comments:

Related Posts Plugin for WordPress, Blogger...
Subscribe to RSS Feed Follow me on Twitter!