Wednesday, March 2, 2016

8051 MOV Instruction

Move

InstructionMOV dest-byte,src-byte
FunctionMove byte variable
DescriptionThe 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.
ExampleInternal RAM location 30H holds 40H. The value of RAM location 40H is 10H. The data present at input port 1 is 11001010B (0CAH).
MOV R0,#30H ;R0 < = 30H
MOV A,@R0 ;A < = 40H
MOV R1,A ;R1 < = 40H
MOV B,@R1 ;B < = 10H
MOV @R1,P1 ;RAM (40H) < = 0CAH
MOV P2,P1 ;P2 #0CAH
leaves the value 30H in register 0, 40H in both the Accumulator and register 1, 10H in register B, and 0CAH (11001010B) both in RAM location 40H and output on port 2.
VariantsMOV A, Rn
MOV A, direct address
MOV A,@Ri
MOV A,#data
MOV Rn, A
MOV Rn, direct address
MOV Rn, #data
MOV direct address,A
MOV direct address, Rn
MOV direct address, direct address
MOV direct,@Ri
MOV direct,#data
MOV @Ri, A
MOV @Ri, direct
MOV @Ri, #data

InstructionMOV A, Rn
Bytes1
Cycles1
Encoding1 1 1 0 1 n n n
OperationA = Rn
Flags AffectedC AC F0 RS1 RS0 OV P
ExampleMOV A, R6
Bytes: Number of bytes required to encode the instruction.
Cycles: Number of instruction cycles required to execute the instruction. Note that there are 12 oscillator cycles to one instruction cycle on a standard 8051.
Encoding: Lists the byte encoding for the instruction.
Operation: Lists, step-by-step, the operations performed by the instruction.
Flags Affected: are highlighted in Bold

InstructionMOV A, direct address
Bytes2
Cycles1
Encoding1 1 1 0 0 1 0 1 A7...A0
OperationA = (direct)
Flags AffectedC AC F0 RS1 RS0 OV P
ExampleMOV A, P0
MOV A,ACC is not a valid Instruction
Bytes: Number of bytes required to encode the instruction.
Cycles: Number of instruction cycles required to execute the instruction. Note that there are 12 oscillator cycles to one instruction cycle on a standard 8051.
Encoding: Lists the byte encoding for the instruction.
Operation: Lists, step-by-step, the operations performed by the instruction.
Flags Affected: are highlighted in Bold

InstructionMOV A,@Ri
Bytes1
Cycles1
Encoding1 1 1 0 0 1 1 i
OperationA = (Ri)
Flags AffectedC AC F0 RS1 RS0 OV P
ExampleMOV A, @R1
Bytes: Number of bytes required to encode the instruction.
Cycles: Number of instruction cycles required to execute the instruction. Note that there are 12 oscillator cycles to one instruction cycle on a standard 8051.
Encoding: Lists the byte encoding for the instruction.
Operation: Lists, step-by-step, the operations performed by the instruction.
Flags Affected: are highlighted in Bold

InstructionMOV A,#data
Bytes2
Cycles1
Encoding0 1 1 1 0 1 0 0 D7...D0
OperationA = immediate data
Flags AffectedC AC F0 RS1 RS0 OV P
ExampleMOV A, #0FFh
Bytes: Number of bytes required to encode the instruction.
Cycles: Number of instruction cycles required to execute the instruction. Note that there are 12 oscillator cycles to one instruction cycle on a standard 8051.
Encoding: Lists the byte encoding for the instruction.
Operation: Lists, step-by-step, the operations performed by the instruction.
Flags Affected: are highlighted in Bold

InstructionMOV Rn, A
Bytes1
Cycles1
Encoding1 1 1 1 1 n n n
OperationRn = A
Flags AffectedC AC F0 RS1 RS0 OV P
ExampleMOV R5, A
Bytes: Number of bytes required to encode the instruction.
Cycles: Number of instruction cycles required to execute the instruction. Note that there are 12 oscillator cycles to one instruction cycle on a standard 8051.
Encoding: Lists the byte encoding for the instruction.
Operation: Lists, step-by-step, the operations performed by the instruction.
Flags Affected: are highlighted in Bold

InstructionMOV Rn, direct address
Bytes2
Cycles2
Encoding1 0 1 0 1 n n n A7...A0
OperationRn = (direct address)
Flags AffectedC AC F0 RS1 RS0 OV P
ExampleMOV R4, P1
Bytes: Number of bytes required to encode the instruction.
Cycles: Number of instruction cycles required to execute the instruction. Note that there are 12 oscillator cycles to one instruction cycle on a standard 8051.
Encoding: Lists the byte encoding for the instruction.
Operation: Lists, step-by-step, the operations performed by the instruction.
Flags Affected: are highlighted in Bold

InstructionMOV Rn, #data
Bytes2
Cycles1
Encoding0 1 1 1 1 n n n D7...D0
OperationRn = immediate
Flags AffectedC AC F0 RS1 RS0 OV P
ExampleMOV R4, #0h
Bytes: Number of bytes required to encode the instruction.
Cycles: Number of instruction cycles required to execute the instruction. Note that there are 12 oscillator cycles to one instruction cycle on a standard 8051.
Encoding: Lists the byte encoding for the instruction.
Operation: Lists, step-by-step, the operations performed by the instruction.
Flags Affected: are highlighted in Bold

InstructionMOV direct address,A
Bytes2
Cycles1
Encoding1 1 1 1 0 1 0 1 A7...A0
Operation(direct) = A
Flags AffectedC AC F0 RS1 RS0 OV P
ExampleMOV P0, A
Bytes: Number of bytes required to encode the instruction.
Cycles: Number of instruction cycles required to execute the instruction. Note that there are 12 oscillator cycles to one instruction cycle on a standard 8051.
Encoding: Lists the byte encoding for the instruction.
Operation: Lists, step-by-step, the operations performed by the instruction.
Flags Affected: are highlighted in Bold

InstructionMOV direct address, Rn
Bytes2
Cycles2
Encoding1 0 0 0 1 n n n A7...A0
Operation(direct address) = Rn
Flags AffectedC AC F0 RS1 RS0 OV P
ExampleMOV P2, R5
Bytes: Number of bytes required to encode the instruction.
Cycles: Number of instruction cycles required to execute the instruction. Note that there are 12 oscillator cycles to one instruction cycle on a standard 8051.
Encoding: Lists the byte encoding for the instruction.
Operation: Lists, step-by-step, the operations performed by the instruction.
Flags Affected: are highlighted in Bold

InstructionMOV direct address, direct address
Bytes3
Cycles2
Encoding1 0 0 0 0 1 1 1 DA7...DA0 SA7...SA0
Operation(dest_direct) = (src_direct)
Flags AffectedC AC F0 RS1 RS0 OV P
ExampleMOV P1, P0
Bytes: Number of bytes required to encode the instruction.
Cycles: Number of instruction cycles required to execute the instruction. Note that there are 12 oscillator cycles to one instruction cycle on a standard 8051.
Encoding: Lists the byte encoding for the instruction.
Operation: Lists, step-by-step, the operations performed by the instruction.
Flags Affected: are highlighted in Bold

InstructionMOV direct,@Ri
Bytes2
Cycles2
Encoding1 0 0 0 0 1 1 i A7...A0
Operation(direct) = (Ri)
Flags AffectedC AC F0 RS1 RS0 OV P
ExampleMOV P0, @R1
Bytes: Number of bytes required to encode the instruction.
Cycles: Number of instruction cycles required to execute the instruction. Note that there are 12 oscillator cycles to one instruction cycle on a standard 8051.
Encoding: Lists the byte encoding for the instruction.
Operation: Lists, step-by-step, the operations performed by the instruction.
Flags Affected: are highlighted in Bold

InstructionMOV direct,#data
Bytes3
Cycles2
Encoding0 1 1 1 0 1 0 1 A7...A0 D7...D0
Operation(direct) = immediate
Flags AffectedC AC F0 RS1 RS0 OV P
ExampleMOV P2, #0FFh
Bytes: Number of bytes required to encode the instruction.
Cycles: Number of instruction cycles required to execute the instruction. Note that there are 12 oscillator cycles to one instruction cycle on a standard 8051.
Encoding: Lists the byte encoding for the instruction.
Operation: Lists, step-by-step, the operations performed by the instruction.
Flags Affected: are highlighted in Bold

InstructionMOV @Ri, A
Bytes1
Cycles1
Encoding1 1 1 1 0 1 1 i
Operation(Ri) = A
Flags AffectedC AC F0 RS1 RS0 OV P
ExampleMOV @R0, A
Bytes: Number of bytes required to encode the instruction.
Cycles: Number of instruction cycles required to execute the instruction. Note that there are 12 oscillator cycles to one instruction cycle on a standard 8051.
Encoding: Lists the byte encoding for the instruction.
Operation: Lists, step-by-step, the operations performed by the instruction.
Flags Affected: are highlighted in Bold

InstructionMOV @Ri, direct
Bytes2
Cycles2
Encoding1 0 1 0 0 1 1 i A7...A0
Operation(Ri) = (direct)
Flags AffectedC AC F0 RS1 RS0 OV P
ExampleMOV @R1, P2
Bytes: Number of bytes required to encode the instruction.
Cycles: Number of instruction cycles required to execute the instruction. Note that there are 12 oscillator cycles to one instruction cycle on a standard 8051.
Encoding: Lists the byte encoding for the instruction.
Operation: Lists, step-by-step, the operations performed by the instruction.
Flags Affected: are highlighted in Bold

InstructionMOV @Ri, #data
Bytes2
Cycles1
Encoding0 1 1 1 0 1 1 i D7...D0
Operation(Ri) = immediate
Flags AffectedC AC F0 RS1 RS0 OV P
ExampleMOV @R0, #0
Bytes: Number of bytes required to encode the instruction.
Cycles: Number of instruction cycles required to execute the instruction. Note that there are 12 oscillator cycles to one instruction cycle on a standard 8051.
Encoding: Lists the byte encoding for the instruction.
Operation: Lists, step-by-step, the operations performed by the instruction.
Flags Affected: are highlighted in Bold

InstructionMOV dest-bit,src-bit
FunctionMove bit data
DescriptionMOV dest-bit,src-bit copies the Boolean variable indicated by the second operand into the location specified by the first operand. One of the operands must be the carry flag; the other may be any directly addressable bit. No other register or flag is affected.
ExampleThe carry flag is originally set. The data present at input Port 3 is 11000101B. The data previously written to output Port 1 is 35H (00110101B).
MOV P1.3,C
MOV C,P3.3
MOV P1.2,C
leaves the carry cleared and changes Port 1 to 39H (00111001B).
VariantsMOV C,bit
MOV bit,C

InstructionMOV C,bit
Bytes2
Cycles1
Encoding1 0 1 0 0 0 1 0 bit_address
OperationC = (bit)
Flags AffectedC AC F0 RS1 RS0 OV P
ExampleMOV C, 22h
Bytes: Number of bytes required to encode the instruction.
Cycles: Number of instruction cycles required to execute the instruction. Note that there are 12 oscillator cycles to one instruction cycle on a standard 8051.
Encoding: Lists the byte encoding for the instruction.
Operation: Lists, step-by-step, the operations performed by the instruction.
Flags Affected: are highlighted in Bold

InstructionMOV bit,C
Bytes2
Cycles2
Encoding1 0 0 1 0 0 1 0 bit_address
Operation(bit) = C
Flags AffectedC AC F0 RS1 RS0 OV P
ExampleMOV 22h, C
Bytes: Number of bytes required to encode the instruction.
Cycles: Number of instruction cycles required to execute the instruction. Note that there are 12 oscillator cycles to one instruction cycle on a standard 8051.
Encoding: Lists the byte encoding for the instruction.
Operation: Lists, step-by-step, the operations performed by the instruction.
Flags Affected: are highlighted in Bold

InstructionMOV DPTR,#data16
FunctionLoad Data Pointer with a 16-bit constant
Bytes3
Cycles2
Encoding1 0 0 1 0 0 0 0 D15...D8 D7...D0
OperationDPTR = immediate data15-0
DescriptionMOV DPTR,#data16 loads the Data Pointer with the 16-bit constant indicated. The 16-bit constant is loaded into the second and third bytes of the instruction. The second byte (DPH) is the high-order byte, while the third byte (DPL) holds the lower-order byte. No flags are affected. This is the only instruction which moves 16 bits of data at once.
Flags AffectedC AC F0 RS1 RS0 OV P
ExampleThe instruction,
MOV DPTR, # 1234H
loads the value 1234H into the Data Pointer: DPH holds 12H, and DPL holds 34H.
Bytes: Number of bytes required to encode the instruction.
Cycles: Number of instruction cycles required to execute the instruction. Note that there are 12 oscillator cycles to one instruction cycle on a standard 8051.
Encoding: Lists the byte encoding for the instruction.
Operation: Lists, step-by-step, the operations performed by the instruction.
Flags Affected: are highlighted in Bold



Related topics:
8051 Data Transfer Instructions   |   8051 MOVC Instruction   |   8051 MOVX Instruction   |   8051 PUSH Instruction   |   8051 POP Instruction   |   8051 XCH Instruction   |   8051 XCHD Instruction

List of topics: 8051

No comments:

Post a Comment