127 / 132 page

HT80C51 User Manual
80C51 Family Instruction Set – Instruction definitions
Handshake Solutions
© Philips Electronics N.V. 2005
Page 127 of 132
SWAP A
Function: Swap nibbles within the Accumulator
Description: SWAP A interchanges the low- and high-order nibbles (four-bit fields) of the Accumulator (bits 3-0
and bits 7-4). The operation can also be thought of as a four-bit rotate instruction. No flags are af-
fected.
Example: The Accumulator holds the value 0C5H (11000101B). The instruction,
SWAP A
leaves the Accumulator holding the value 5CH (01011100B).
Bytes: 1
Cycles: 1
Encoding:
Operation: SWAP
(A3-0)
↔ (A7-4)
XCH A,<byte>
Function: Exchange Accumulator with byte variable
Description: XCH loads the Accumulator with the contents of the indicated variable, at the same time writing
the original Accumulator contents to the indicated variable. The source/destination operand can
use register, direct, or register-indirect addressing.
Example: R0 contains the address 20H. The Accumulator holds the value 3FH (00111111B). Internal RAM
location 20H holds the value 75H (01110101B). The instruction,
XCH A,@R0
will leave the RAM location 20H holding the values 3FH (00111111B) and 75H (01110101B) in
the Accumulator.
XCH A,Rn
Bytes: 1
Cycles: 1
Encoding:
Operation: XCH
(A)
↔ (Rn)
XCH A,direct
Bytes: 2
Cycles: 1
Encoding:
Operation: XCH
(A)
↔ (direct)
XCH A,@Ri
Bytes: 1
Cycles: 1
Encoding:
Operation: XCH
(A)
↔ ((Ri))
1
1
0
0
0
1
0
0
1
1
0
0
1
r
r
r
1
1
0
0
0
1
0
1
direct address
1
1
0
0
0
1
1
i