Wednesday, March 23, 2016

8051 Exchange Accumulator

Exchange Accumulator with byte variable

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.

XCH A, Rn
Encoding: 1 1 0 0 1 n n n

XCH A, direct address
Encoding: 1 1 0 0 0 1 0 1 direct address

XCH A,@Ri
Encoding: 1 1 0 0 0 1 1 i

Example:
R0 contains the address 20H. The Accumulator holds the value 3FH (0011111lB). Internal RAM location 20H holds the value 75H (01110101B). The following instruction,

XCH A,@R0

leaves RAM location 20H holding the values 3FH ( 00111111B) and 75H (01110101B) in the accumulator.



Related topics:
8051 Complement Accumulator and Bit   |   8051 Set Bit   |   8051 Clear Accumulator and Bit   |   8051 Rotate Accumulator   |   8051 Swap Nibble   |   8051 Exchange Digit   |   8051 Push and Pop   |   8051 No Operation

List of topics: 8051

No comments:

Post a Comment