Wednesday, March 23, 2016

8051 Logical XOR for Byte

Logical Exclusive-OR for byte variables

XRL performs the bitwise logical Exclusive-OR operation between the indicated variables, storing the results in the destination. No flags are affected.

The two operands allow six addressing mode combinations. When the destination is the Accumulator, the source can use register, direct, register-indirect, or immediate addressing; when the destination is a direct address, the source can be the Accumulator or immediate data.

Note: When this instruction is used to modify an output port, the value used as the original port data is read from the output data latch, not the input pins.

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

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

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

XRL A, #data
Encoding: 0 1 1 0 0 1 0 0 immediate data

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

XRL direct, #data
Encoding: 0 1 1 0 0 0 1 1 direct address immediate data

If the Accumulator holds 0C3H (1100001lB) and register 0 holds 0AAH (10101010B) then the instruction,

XRL A,R0

leaves the Accumulator holding the value 69H (01101001B).

When the destination is a directly addressed byte, this instruction can complement combinations of bits in any RAM location or hardware register. The pattern of bits to be complemented is then determined by a mask byte, either a constant contained in the instruction or a variable computed in the Accumulator at run-time. The following instruction,

XRL P1,#00110001B

complements bits 5, 4, and 0 of output Port 1.

Example:

ORG 0H
MAIN :
MOV A, #35H
MOV R4, #03H
MOV 40h, #02H
MOV R0, #40H
XRL A, R4
XRL A, P0
XRL A, @R0
XRL A, #0FH
XRL 40h, A
XRL 40h, #77h
END; end of asm source file



Related topics:
8051 Increment Byte and DPTR   |   8051 Decrement Byte   |   8051 Logical AND for Byte and Bit   |   8051 Logical OR for Byte and Bit   |   8051 Addition

List of topics: 8051

No comments:

Post a Comment