Showing posts with label movc. Show all posts
Showing posts with label movc. Show all posts

Wednesday, September 11, 2013

In 8051 micro controller have in built RAM and ROM,but size of this memory is limited size of RAM is 128 byte while size of ROM is 4KB some time we need more memory then this so we connect external memory with micro controller.

access external RAM

To access external RAM we used MOVX instruction.

MOVX A,@DPTR;this code used for read data from external RAM.

MOVX @DPTR,A;this code used for write data into external RAM.

access External ROM

MOVC A,@A+DPTR; to read data from ROM.

here we add content of A and DPTR and then using indirect addressing mode we copy the content of that location into A.

MOVC A,@A+PC; to read data from ROM.

we increment content of PC and then add with A.then we copy the content of that location into A using indirect addressing mode.


External program memory is accessed under the following condition.
  1. Whenever is low, or
  2. Whenever PC contains a number higher than 0FFFH (for 8051) or 1FFF (for 8052). 
Some typical use of code/program memory access: External program memory can be not only used to store the code, but also for lookup table of various functions required for a particular application. Mathematical functions such as Sine, Square root, Exponential, etc. can be stored in the program memory (Internal or eternal)  and these functions can be accessed using MOVC instruction.
 ----------------------------------------------------------------------------------------------------------------------
PREVIOUS:Serial communication                                                       NEXT: push & pop operation

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;

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