EOR - Exclusive OR
EOR performs a bitwise logical Exclusive-OR of the value in the accumulator with that of the memory location with the result stored in the accumulator.
The result will be each bit in the accumulator will be set ONLY if that same bit in the original accumulator value and the memory differ. If the bits were the same then the resultant bit will be 0.
Second Operand | |||
---|---|---|---|
First Operand | 0 | 1 | |
0 | 0 | 1 | |
1 | 1 | 0 |
For 8-bit processors n has the value of bit 7 and v the value of bit 6 of the memory location.
For 16-bit processors, when m=0, n has the value of bit 15 and v the value of bit 14 of the memory location.
Second it performs a logical AND of the memory and the accumulator. If the result is zero the z flag is set.
In both operations, the contents of the accumulator and memory are not modified.
Flags Affected
Flags |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
n | Set if most significant bit of result is set | ||||||||
z | Set if result is zero, otherwise clear |
Instructions
Syntax | Opcode | Available on: | # of | # of | Addressing Mode | ||
---|---|---|---|---|---|---|---|
(hex) | 6502 | 65C02 | 65816 | bytes | cycles | ||
EOR #const | 49 | x | x | x | 21 | 22 | Immediate |
EOR addr | 4D | x | x | x | 3 | 42 | Absolute |
EOR long | 4F | x | 4 | 52 | Absolute Long | ||
EOR dp | 45 | x | x | x | 2 | 32, 3 | Direct Page |
EOR (dp) | 52 | x | x | 2 | 52, 3 | Direct Page Indirect | |
EOR [dp] | 47 | x | 2 | 62, 3 | Direct Page Indirect Long | ||
EOR addr,X | 5D | x | x | x | 3 | 42, 4 | Absolute Indexed X |
EOR long,X | 5F | x | 4 | 52 | Absolute Long Indexed X | ||
EOR addr,Y | 59 | x | x | x | 3 | 42, 4 | Absolute Indexed Y |
EOR dp,X | 55 | x | x | x | 2 | 42, 3 | Direct Page Indexed X |
EOR (dp,X) | 41 | x | x | x | 2 | 62, 3 | Direct Page Indexed Indirect X |
EOR (dp),Y | 51 | x | x | x | 2 | 52, 3, 4 | Direct Page Indirect Indexed Y |
EOR [dp],Y | 57 | x | 2 | 62, 3 | Direct Page Indirect Long Indexed Y | ||
EOR sr,S | 43 | x | 2 | 42 | Stack Relative | ||
EOR (sr,S),Y | 53 | x | 2 | 72 | Stack Relative Indirect Indexed Y |
Notes:
- 65816: Add 1 byte if m=0 (16-bit memory/accumulator)
- 65816: Add 1 cycle if m=0 (16-bit memory/accumulator)
- 65816: Add 1 cycle if low byte of Direct Page register is not 0
- Add 1 cycle if adding index crosses a page boundary