EOR EOR "Exclusive-Or" memory with accumulator EOR
Operation: A EOR M -> A N V - B D I Z C
/ . . . . . / .
+----------------+-----------------------+---------+---------+----------+
| Addressing Mode| Assembly Language Form| OP CODE |No. Bytes|No. Cycles|
+----------------+-----------------------+---------+---------+----------+
| Immediate | EOR #$FF | $49 | 2 | 2 |
| ZeroPage | EOR $FF | $45 | 2 | 3 |
| ZeroPage,X | EOR $FF,X | $55 | 2 | 4 |
| Absolute | EOR $FFFF | $4D | 3 | 4 |
| Absolute,X | EOR $FFFF,X | $5D | 3 | 4* |
| Absolute,Y | EOR $FFFF,Y | $59 | 3 | 4* |
| (Indirect,X) | EOR ($FF,X) | $41 | 2 | 6 |
| (Indirect),Y | EOR ($FF),Y | $51 | 2 | 5* |
+----------------+-----------------------+---------+---------+----------+
* Add 1 if page boundary is crossed.
For penalty cycles on the 65816, check the desired addressing mode.
65816 Extensions:
+----------------+-----------------------+---------+---------+----------+
| Addressing Mode| Assembly Language Form| OP CODE |No. Bytes|No. Cycles|
+----------------+-----------------------+---------+---------+----------+
| AbsoluteLong | EOR $FFFFFF | $4F | 4 | 5 |
| AbsoluteLong,X | EOR $FFFFFF,X | $5F | 4 | 5 |
| (Indirect) | EOR ($FF) | $52 | 2 | 5 |
| [Indirect Long]| EOR [$FF] | $47 | 2 | 6 |
| [Ind.Long],Y | EOR [$FF],Y | $57 | 2 | 6 |
| Relative,S | EOR $FF,S | $43 | 2 | 4 |
| (Indirect,S),Y | EOR ($FF,S),Y | $53 | 2 | 7 |
+----------------+-----------------------+---------+---------+----------+
What it does: Exclusive ORs a byte in memory with the Accumulator. Each bit in memory is compared with each bit in the Accumulator, and the bits are then set (given a 1) if one of the compared bits is 1. However, bits are cleared if both are 0 or if both are 1. The bits in the byte held in the Accumulator are the only ones affected by this comparison.
Major uses: EOR doesn't have too many uses. Its main value is to toggle a bit. If a bit is clear (is a 0), it will be set (to a 1); if a bit is set, it will be cleared. For example, if you want to reverse the current state of the sixth bit in a given byte: LDA BYTE:EOR #$40:STA BYTE. This will set bit 6 in BYTE if it was 0 (and clear it if it was 1). This selective bit toggling could be used to "shift" an unshifted ASCII character via EOR #$80 (1000000). Or if the character were shifted, EOR #$80 would make it lowercase. EOR toggles.