xor
Exclusive OR - 7C 00 00 78
xor
Instruction Syntax
Mnemonic | Format | Flags |
xor | rA,rS,rB | Rc = 0 |
xor. | rA,rS,rB | Rc = 1 |
Instruction Encoding
0
1
1
1
1
1
S
S
S
S
S
A
A
A
A
A
B
B
B
B
B
0
0
0
0
0
0
0
0
0
0
1
1
1
1
0
0
0
Rc
Field | Bits | Description |
Primary Opcode | 0-5 | 011111 (0x1F) |
rS | 6-10 | Source register |
rA | 11-15 | Destination register |
rB | 16-20 | Source register |
Reserved | 21-29 | 000000000 |
Reserved | 30 | 0 |
Rc | 31 | Record Condition Register |
Operation
rA ← (rS) ⊕ (rB)
The exclusive OR of the values in registers rS and rB is placed into register rA.
Note: The xor instruction performs bitwise exclusive OR operation. If Rc = 1, the condition register is updated.
Affected Registers
Condition Register (CR0 field)
(if Rc = 1)
- LT (Less Than)
- GT (Greater Than)
- EQ (Equal)
- SO (Summary Overflow)
For more information on condition codes see Section 2.1.3, "Condition Register," in the PowerPC Microprocessor Family: The Programming Environments manual.
Examples
Basic Exclusive OR
xor r3, r1, r2 # r3 = r1 ⊕ r2 xor. r3, r1, r2 # Same as above, but also sets condition register
Bit Manipulation
# Toggle specific bits li r4, 0xFF # Load mask xor r5, r3, r4 # Toggle all bits in r3
Register Clearing
# Clear register using XOR with itself xor r3, r3, r3 # r3 = 0