Sunday, July 7, 2013

Data Transfer Instruction of 8051
This instructions are used to copy the content of source operand to Destination operand


MOV A,Rn - Moves the Rn register to the accumulator
The instruction moves the Rn register to the accumulator. The Rn register is not affected.

EXAMPLE:
MOV A,Rn 

Before execution: R3=58h
After execution: R3=58h A=58h

MOV A,@Ri - Moves the indirect RAM to the accumulator
Description: Instruction moves the indirectly addressed register of RAM to the accumulator. The register address is stored in the Ri register (R0 or R1). The result is stored in the accumulator. The register is not affected.

EXAMPLE:
MOV A,@Ri

Register Address SUM=F2h R0=F2h
Before execution: SUM=58h
After execution: A=58h SUM=58h

MOV A,direct - Moves the direct byte to the accumulator
Description: Instruction moves the direct byte to the accumulator. As it is direct addressing, the register can be any SFRs or general-purpose register with address 0-7Fh. (0-127 dec.). After executing the instruction, the register is not affected.

EXAMPLE:
MOV A,Rx

Before execution: Rx=68h
After execution: Rx=68h A=68h

MOV Rn,A - Moves the accumulator to the Rn register
Desription: Instruction moves the accumulator to the Rn register. The accumulator is not affected.

EXAMPLE:
MOV Rn,A

Before execution: A=58h
After execution: R3=58h A=58h

MOV A,#data - Moves the immediate data to the accumulator
Desription: Instruction moves the immediate data to the accumulator.

EXAMPLE:
MOV A,#X

After execution: A=28h

MOV Rn,#data - Moves the immediate data to the Rn register
Description: Instruction moves the immediate data to the Rn register.
MOV Rn,#X

After execution: R5=32h

MOV Rn,direct - Moves the direct byte to the Rn register
Description: Instruction moves the direct byte to the Rn register. As it is direct addressing, the register can be any SFRs or general-purpose register with address 0-7Fh. (0-127 dec.). After executing the instruction, the register is not affected.

EXAMPLE:
MOV Rn,Rx

Before execution: SUM=58h
After execution: SUM=58h R3=58h

MOV direct,Rn - Moves the Rn register to the direct byte
Description: Instruction moves the Rn register to the direct byte. As it is direct addressing, the register can be any SFRs or general-purpose register with address 0-7Fh. (0-127 dec.). After executing the instruction, the register is not affected.

EXAMPLE:
MOV Rx,Rn

Before execution: R3=18h
After execution: R3=18h CIF=18h

MOV direct,A - Moves the accumulator to the direct byte
Description: Instruction moves the accumulator to the direct byte. As it is direct addressing, the register can be any SFRs or general-purpose register with address 0-7Fh. (0-127 dec.). After executing the instruction, the register is not affected.

EXAMPLE:
MOV Rx,A

Before execution: A=98h
After execution: A=98h REG=98h

MOV direct,@Ri - Moves the indirect RAM to the direct byte
Description: Instruction moves the indirectly adressed register of RAM to the direct byte. The register is not affected.

EXAMPLE:
MOV Rx,@Ri

Register Address SUM=F3
Before execution: SUM=58h R1=F3
After execution: SUM=58h TEMP=58h

MOV direct1,direct2 - Moves the direct byte to the direct byte
Description: Instruction moves the direct byte to another direct byte. As it is direct addressing, both registers can be any SFRs or general-purpose registers with address 0-7Fh. (0-127 dec.). The direct1 is not affected.

EXAMPLE:
MOV Rx,Ry

Before execution: TEMP=58h
After execution: TEMP=58h SUM=58h

MOV @Ri,A - Moves the accumulator to the indirect RAM
Description: Instruction moves the accumulator to the indirectly addressed register of RAM. The register address is stored in the Ri register (R0 or R1). After executing the instruction, the accumulator is not affected.

EXAMPLE:
MOV @Ri,A

Register Address SUM=F2h
Before execution: R0=F2h A=58h
After execution: SUM=58h A=58h

MOV direct,#data - Moves the immediate data to the direct byte
Description: Instruction moves the immediate data to the direct byte. As it is direct addressing, the direct byte can be any SFRs or general-purpose register with address 0-7Fh. (0-127 dec.).

EXAMPLE:
MOV Rx,#X

After execution: TEMP=22h

MOV @Ri,#data - Moves the immediate data to the indirect RAM
Description: Instruction moves the immediate data to the idirectly addressed register of RAM. The register address is stored in the Ri register (R0 or R1).


EXAMPLE:
MOV @Ri,#X

Register address TEMP=E2h
Before execution: R1=E2h
After execution: TEMP=44h

MOV @Ri,direct - Moves the direct byte to the indirect RAM
Description: Instruction moves the direct byte to a register the address of which is stored in the Ri register (R0 or R1). After executing the instruction, the direct byte is not affected.

EXAMPLE:
MOV @Ri,Rx

Register address TEMP=E2h
Before execution: SUM=58h R1=E2h
After execution: SUM=58h TEMP=58h

MOVC A,@A+DPTR - Moves the code byte relative to the DPTR to the accumulator
Description: Instruction first adds the 16-bit DPTR register to the accumulator. The result of addition is then used as a memory address from which the 8-bit data is moved to the accumulator.

EXAMPLE:
MOVC A,@A+DPTR

Before execution:
DPTR=1000:
A=0
A=1
A=2
A=3
After execution:
A=66h
A=77h
A=88h
A=99h
Note: DB (Define Byte) is a directive in assembly language used to define constant.

MOV DPTR,#data16 - Loads the data pointer with a 16-bit constant
Description: Instruction stores a 16-bit constant to the DPTR register. The 8 high bits of the constant are stored in the DPH register, while the 8 low bits are stored in the DPL register.

EXAMPLE:
MOV DPTR,#X16

After execution: DPH=12h DPL=34h

MOVX A,@Ri - Moves the external RAM (8-bit address) to the accumulator
Description: Instruction reads the content of a register in external RAM and moves it to the accumulator. The register address is stored in the Ri register (R0 or R1).

EXAMPLE:
MOVX A,@Ri

Register Address: SUM=12h
Before execution: SUM=58h R0=12h
After execution: A=58h
Note:
SUM Register is stored in external RAM which is 256 bytes in size.

MOVC A,@A+PC - Moves the code byte relative to the PC to the accumulator
Description: Instruction first adds the 16-bit PC register to the accumulator (the current program address is stored in the PC register). The result of addition is then used as a memory address from which the 8-bit data is moved to the accumulator.


EXAMPLE:
MOVC A,@A+PC

After the subroutine "Table" has been executed, one of four values is stored in the accumulator:
Before execution:
A=0
A=1
A=2
A=3
After execution:
A=66h
A=77h
A=88h
A=99h
Note: DB (Define Byte) is a directive in assembly language used to define constant.

MOVX @Ri,A - Moves the accumulator to the external RAM (8-bit address)
Description: Instruction moves the accumulator to a register stored in external RAM. Its address is stored in the Ri register.

EXAMPLE:
MOVX @Ri,A 

Register address: SUM=34h
Before execution: A=58 R1=34h
After execution: SUM=58h
NOTE:
Register SUM is located in external RAM which is 256 bytes in size.

MOVX A,@DPTR - Moves the external memory (16-bit address) to the accumulator
Description: Instruction moves the content of a register in external memory to the accumulator. The 16-bit address of the register is stored in the DPTR register (DPH and DPL).

EXAMPLE:
MOVX A,@DPTR

Register address: SUM=1234h
Before execution: DPTR=1234h SUM=58
After execution: A=58h
Note:
Register SUM is located in external RAM which is up to 64K in size.

MOVX @DPTR,A - Moves the accumulator to the external RAM (16-bit address)
Description: Instruction moves the accumulator to a register stored in external RAM. The 16-bit address of the register is stored in the DPTR register (DPH and DPL).

EXAMPLE:
MOVX @DPTR,A

Register address: SUM=1234h
Before execution: A=58 DPTR=1234h
After execution: SUM=58h

1 comments:

Hema Yadav said...

Great insights on Data Transfer Instructions for the 8051 controller. Informative and well-explained! Thanks for posting.
Read my blog:
A Hands-On Guide to Data Science Tools: Python, R, and More

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