EOR (bitwise Exclusive OR)¶
A = A ^ [operand]
EOR performs a bitwise exclusive OR operation between the accumulator register (A) and an operand. The result is stored in the accumulator.
Addressing Modes¶
Mode |
Syntax |
Bytes |
Cycles |
---|---|---|---|
EOR #const |
|
2 |
|
EOR zp |
|
3 |
|
EOR zp,x |
|
4 |
|
EOR addr |
|
4 |
|
EOR addr,x |
|
4-5 |
|
Absolute+Y |
EOR addr,y |
|
4-5 |
EOR (zp,x) |
|
6 |
|
EOR (zp),y |
|
5-6 |
Flags Affected¶
N (Negative) – Set if the result has the most significant bit set (i.e., is negative); otherwise, it is cleared.
Z (Zero) – Set if the result is zero; otherwise, it is cleared.
Examples¶
Simple Exclusive OR with a Constant¶
LDA #0x55 ; load A with 01010101b
EOR #0xAA ; perform exclusive OR with 10101010b
; A now contains 11111111b
Exclusive OR with a Memory Location¶
LDA $12 ; load A with the value at memory location $12
EOR #$FF ; perform exclusive OR with constant FFh
; A now contains the bitwise complement of the value at $12
Exclusive OR with a Memory Location using Zero Page Addressing¶
LDA $04 ; load A with the value at memory location $04
EOR $05 ; perform exclusive OR with the value at memory location $05
; A now contains the result of the bitwise exclusive OR operation
Exclusive OR with a Memory Location using Zero Page Addressing with Indexing¶
LDX #$02 ; load X with 2
LDA $05,X ; load A with the value at memory location $07
EOR #$FF ; perform exclusive OR with constant FFh
; A now contains the bitwise complement of the value at $07
Exclusive OR with a Memory Location using Absolute Addressing¶
LDA $1234 ; load A with the value at memory location $1234
EOR #$AA ; perform exclusive OR with constant AAh
; A now contains the result of the bitwise exclusive OR operation
Exclusive OR with a Memory Location using Absolute Addressing with Indexing¶
LDY #$02 ; load Y with 2
LDA $1234,Y ; load A with the value at memory location $1236
EOR #$0F ; perform exclusive OR with constant 0Fh
; A now contains the result of the bitwise exclusive OR operation
Exclusive OR with a Memory Location using Indirect Addressing with Indexing¶
asmCopy code LDX #$01 ; load X with 1
LDA ($10,X) ; load A with the value at the address contained in $11
EOR #$55 ; perform exclusive OR with constant 55h
; A now contains the result of the bitwise exclusive OR operation
Exclusive OR with a Memory Location using Indirect Addressing with Indexing¶
LDY #$01 ; load Y with 1
LDA ($10),Y ; load A with the value at the address contained in $11
EOR #$FF ; perform exclusive OR with constant FFh
; A now contains the bitwise complement of the value at $11
Note: These examples are for illustrative purposes only and may not be suitable for use in actual programs.