Move
Instruction | MOV dest-byte,src-byte |
---|---|
Function | Move byte variable |
Description | 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. |
Example | Internal 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. |
Variants | MOV 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 |
Instruction | MOV A, Rn |
---|---|
Bytes | 1 |
Cycles | 1 |
Encoding | 1 1 1 0 1 n n n |
Operation | A = Rn |
Flags Affected | C AC F0 RS1 RS0 OV P |
Example | MOV 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 |
Instruction | MOV A, direct address |
---|---|
Bytes | 2 |
Cycles | 1 |
Encoding | 1 1 1 0 0 1 0 1 A7...A0 |
Operation | A = (direct) |
Flags Affected | C AC F0 RS1 RS0 OV P |
Example | MOV 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 |
Instruction | MOV A,@Ri |
---|---|
Bytes | 1 |
Cycles | 1 |
Encoding | 1 1 1 0 0 1 1 i |
Operation | A = (Ri) |
Flags Affected | C AC F0 RS1 RS0 OV P |
Example | MOV 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 |
Instruction | MOV A,#data |
---|---|
Bytes | 2 |
Cycles | 1 |
Encoding | 0 1 1 1 0 1 0 0 D7...D0 |
Operation | A = immediate data |
Flags Affected | C AC F0 RS1 RS0 OV P |
Example | MOV 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 |
Instruction | MOV Rn, A |
---|---|
Bytes | 1 |
Cycles | 1 |
Encoding | 1 1 1 1 1 n n n |
Operation | Rn = A |
Flags Affected | C AC F0 RS1 RS0 OV P |
Example | MOV 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 |
Instruction | MOV Rn, direct address |
---|---|
Bytes | 2 |
Cycles | 2 |
Encoding | 1 0 1 0 1 n n n A7...A0 |
Operation | Rn = (direct address) |
Flags Affected | C AC F0 RS1 RS0 OV P |
Example | MOV 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 |
Instruction | MOV Rn, #data |
---|---|
Bytes | 2 |
Cycles | 1 |
Encoding | 0 1 1 1 1 n n n D7...D0 |
Operation | Rn = immediate |
Flags Affected | C AC F0 RS1 RS0 OV P |
Example | MOV 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 |
Instruction | MOV direct address,A |
---|---|
Bytes | 2 |
Cycles | 1 |
Encoding | 1 1 1 1 0 1 0 1 A7...A0 |
Operation | (direct) = A |
Flags Affected | C AC F0 RS1 RS0 OV P |
Example | MOV 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 |
Instruction | MOV direct address, Rn |
---|---|
Bytes | 2 |
Cycles | 2 |
Encoding | 1 0 0 0 1 n n n A7...A0 |
Operation | (direct address) = Rn |
Flags Affected | C AC F0 RS1 RS0 OV P |
Example | MOV 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 |
Instruction | MOV direct address, direct address |
---|---|
Bytes | 3 |
Cycles | 2 |
Encoding | 1 0 0 0 0 1 1 1 DA7...DA0 SA7...SA0 |
Operation | (dest_direct) = (src_direct) |
Flags Affected | C AC F0 RS1 RS0 OV P |
Example | MOV 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 |
Instruction | MOV direct,@Ri |
---|---|
Bytes | 2 |
Cycles | 2 |
Encoding | 1 0 0 0 0 1 1 i A7...A0 |
Operation | (direct) = (Ri) |
Flags Affected | C AC F0 RS1 RS0 OV P |
Example | MOV 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 |
Instruction | MOV direct,#data |
---|---|
Bytes | 3 |
Cycles | 2 |
Encoding | 0 1 1 1 0 1 0 1 A7...A0 D7...D0 |
Operation | (direct) = immediate |
Flags Affected | C AC F0 RS1 RS0 OV P |
Example | MOV 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 |
Instruction | MOV @Ri, A |
---|---|
Bytes | 1 |
Cycles | 1 |
Encoding | 1 1 1 1 0 1 1 i |
Operation | (Ri) = A |
Flags Affected | C AC F0 RS1 RS0 OV P |
Example | MOV @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 |
Instruction | MOV @Ri, direct |
---|---|
Bytes | 2 |
Cycles | 2 |
Encoding | 1 0 1 0 0 1 1 i A7...A0 |
Operation | (Ri) = (direct) |
Flags Affected | C AC F0 RS1 RS0 OV P |
Example | MOV @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 |
Instruction | MOV @Ri, #data |
---|---|
Bytes | 2 |
Cycles | 1 |
Encoding | 0 1 1 1 0 1 1 i D7...D0 |
Operation | (Ri) = immediate |
Flags Affected | C AC F0 RS1 RS0 OV P |
Example | MOV @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 |
Instruction | MOV dest-bit,src-bit |
---|---|
Function | Move bit data |
Description | MOV 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. |
Example | The 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). |
Variants | MOV C,bit MOV bit,C |
Instruction | MOV C,bit |
---|---|
Bytes | 2 |
Cycles | 1 |
Encoding | 1 0 1 0 0 0 1 0 bit_address |
Operation | C = (bit) |
Flags Affected | C AC F0 RS1 RS0 OV P |
Example | MOV 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 |
Instruction | MOV bit,C |
---|---|
Bytes | 2 |
Cycles | 2 |
Encoding | 1 0 0 1 0 0 1 0 bit_address |
Operation | (bit) = C |
Flags Affected | C AC F0 RS1 RS0 OV P |
Example | MOV 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 |
Instruction | MOV DPTR,#data16 |
---|---|
Function | Load Data Pointer with a 16-bit constant |
Bytes | 3 |
Cycles | 2 |
Encoding | 1 0 0 1 0 0 0 0 D15...D8 D7...D0 |
Operation | DPTR = immediate data15-0 |
Description | MOV 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 Affected | C AC F0 RS1 RS0 OV P |
Example | The 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