Tuesday, March 22, 2016

8051 Move Byte

The MOV instruction copies data from one location to another. It has the following format:

MOV destination, source ;copy source to dest.

Move Byte – MOV dest-byte, src-byte The byte variable indicated by the second operand is copied into the location specified by the first operand. The source byte is not affected. No other register or flag is affected. This is by far the most flexible operation. Fifteen combinations of source and destination addressing modes are allowed.

MOV A, Rn
Encoding:11101nnn

MOV A, direct address
Encoding:11100101 direct address

MOV A,@Ri
Encoding:1110011i

MOV A,#data
Encoding:01110100 immediate data

MOV Rn, A
Encoding:11111nnn

MOV Rn, direct address
Encoding:10101nnn direct address

MOV Rn, #data
Encoding:01111nnn immediate data

MOV direct address,A
Encoding:11110101 direct address

MOV direct address, Rn
Encoding:10001rrr direct address

MOV direct address, direct address
Encoding:10000111 direct address (dest) direct address (src)

MOV direct,@Ri
Encoding:1000011i direct address

MOV direct,#data
Encoding:01110101 direct address immediate data

MOV @Ri, A
Encoding:1111011i

MOV @Ri, direct
Encoding:1010011i direct address

MOV @Ri, #data
Encoding:0111011i immediate data

Example:
ORG 0H; start (origin) at location 0
MAIN :
MOV A, R6; copy contents of R6 in to A
MOV A, P0; copy contents of P0 in to A
MOV A, @R1; copy data at location pointed by R6 in to A
MOV A, #0FFh; load FFH in to A
MOV R5, A; copy contents of A in to R5
MOV R4, P1; copy contents of P1 in to R4
MOV R4, #0h; load 0H in to A
MOV P0, A; copy contents of A in to P0
MOV P2, R5; copy contents of R5 in to P2
MOV P1, P0; copy contents of P0 in to P1
MOV P0, @R1; copy data at location pointed by R1 in to P0
MOV P2, #0FFh; load FFH in to A
MOV @R0, A; copy content of A in to the location pointed by R0
MOV @R1, P2; copy content of p2 in to the location pointed by R1
MOV @R0, #0; load 0H in to the location pointed by R0
END; end of asm source file



Related topics:
8051 Move Bit   |   8051 Move Word   |   8051 Move Code Byte   |   8051 Move External   |   8051 MOVX Instruction   |   8051 MOVC Instruction   |   8051 MOV Instruction

List of topics: 8051

No comments:

Post a Comment