Wednesday, March 2, 2016

8051 MOVX Instruction

Move External

InstructionMOVX dest-byte,src-byte
FunctionMove External
DescriptionThe MOVX instructions transfer data between the Accumulator and a byte of external data memory, which is why “X” is appended to MOV. There are two types of instructions, differing in whether they provide an 8-bit or 16-bit indirect address to the external data RAM.
In the first type, the contents of R0 or R1 in the current register bank provide an 8-bit address multiplexed with data on P0. Eight bits are sufficient for external I/O expansion decoding or for a relatively small RAM array. For somewhat larger arrays, any output port pins can be used to output higher-order address bits. These pins are controlled by an output instruction preceding the MOVX.
In the second type of MOVX instruction, the Data Pointer generates a 16-bit address. P2 outputs the high-order eight address bits (the contents of DPH), while P0 multiplexes the low-order eight bits (DPL) with data. The P2 Special Function Register retains its previous contents, while the P2 output buffers emit the contents of DPH. This form of MOVX is faster and more efficient when accessing very large data arrays (up to 64K bytes), since no additional instructions are needed to set up the output ports.
It is possible to use both MOVX types in some situations. A large RAM array with its high-order address lines driven by P2 can be addressed via the Data Pointer, or with code to output high-order address bits to P2, followed by a MOVX instruction using R0 or R1.
ExampleAn external 256 byte RAM using multiplexed address/data lines is connected to the 8051 Port 0. Port 3 provides control lines for the external RAM. Ports 1 and 2 are used for normal I/O. Registers 0 and 1 contain 12H and 34H. Location 34H of the external RAM holds the value 56H. The instruction sequence,
MOVX A,@R1
MOVX @R0,A
copies the value 56H into both the Accumulator and external RAM location 12H.
VariantsMOVX A,@Ri
MOVX A,@DPTR
MOVX @Ri, A
MOVX @DPTR,A

InstructionMOVX A,@Ri
Bytes1
Cycles2
Encoding1 1 1 0 0 0 1 i
OperationA = (Ri)
Flags AffectedC AC F0 RS1 RS0 OV P
ExampleMOVX 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

InstructionMOVX A,@DPTR
Bytes1
Cycles1
Encoding1 1 1 0 0 0 0 0
OperationA = (DPTR)
Flags AffectedC AC F0 RS1 RS0 OV P
ExampleMOVX A, @DPTR
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

InstructionMOVX @Ri, A
Bytes1
Cycles2
Encoding1 1 1 1 0 0 1 i
Operation(Ri) = A
Flags AffectedC AC F0 RS1 RS0 OV P
ExampleMOVX @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

InstructionMOVX @DPTR,A
Bytes1
Cycles2
Encoding1 1 1 1 0 0 0 0
Operation(DPTR) = A
Flags AffectedC AC F0 RS1 RS0 OV P
ExampleMOVX @DPTR, 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



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

List of topics: 8051

No comments:

Post a Comment