XOR EXCLUSIVE OR
Purpose |
perform logical exclusive OR of two integers |
Format |
opcode mask.rx, dst.mx 2 operand opcode mask.rx, src.rx, dst.wx 3 operand |
Operation |
dst ß dst XOR mask; 2 operand dst ß src XOR mask; 3 operand |
Condition codes |
N ß dst LSS 0; Z ß dst EQL 0; V ß 0; C ß C; |
Exceptions |
None |
Opcodes |
8C XORB2 Exclusive OR Byte 2 Operand 8D XORB3 Exclusive OR Byte 3 Operand AC XORW2 Exclusive OR Word 2 Operand AD XORW3 Exclusive OR Word 3 Operand CC XORL2 Exclusive OR Long 2 Operand CD XORL3 Exclusive Or Long 3 Operand |
Description |
In 2 operand format, the mask operand is XORed with the destination operand and the destination operand is replaced by the result. In 3 operand format, the mask operand is XORed with the source operand and the destination operand is re placed by the result. |
Example 1
Simple example of XORL3:
.text
main: .word 0
movl $0xF0F0F0F0, r5
xorl3 $0x0A0B0C0D, r5, r6
pushl r6
pushal format
calls $2, .printf
pushl $0
calls $1, .exit
.data
format: .asciz "%lX\n"
The program's output is FAFBFCFD.
Example 2
XORW3 example:
.text
main: .word 0
movw $0xF0F0, r5
xorw3 $0x0FF0, r5, r6
pushl r6
pushal format
calls $2, .printf
pushl $0
calls $1, .exit
.data
format: .asciz "%lX\n"
Program's output is FF00.
Example 3
Flags raised by XOR commands:
.text
main: .word 0
movw $0xF0F0, r5
xorw3 $0x0FF0, r5, r6 # N = 1
movl $0xF0F00000, r5
xorl3 $0x0FF00000, r5, r6 # N = 1
movb $0xF0, r5
xorb3 $0x0F, r5, r6 # N = 1
movb $0x00, r5
xorb3 $0x0F, r5, r6 # N = 0
movb $0xFF, r5
xorb3 $0xFF, r5, r6 # N = 0, Z = 1
movw $0xF0F0, r5
xorw2 $0x0FF0, r5 # N = 1
movl $0xF0F00000, r5
xorl2 $0x0FF00000, r5 # N = 1
movb $0xF0, r5
xorb2 $0x0F, r5 # N = 1
movb $0x00, r5
xorb2 $0x0F, r5 # N = 0
movb $0xFF, r5
xorb2 $0xFF, r5 # N = 0, Z = 1
pushl $0
calls $1, .exit
.data
format: .asciz "%X\n"