141. Eor indirect x
add EOR (indirect,X) opcode ``0x41``.
Lesson 141 of 356 · tests/chapter_01_cpu/test_141_EOR_indirect_x.py
Why this step exists
Pre-indexed indirect EOR enables pointer-table access through zero page while preserving the split between effective-address resolution and exclusive OR.
In this step, lessons 134-140 already provide `or_e, its opcode import, and the earlier EOR modes. Add exactly the following to emulator/cpu/opcodes.py`:
def eor_indirect_x(cpu: CPU):
addr = indirect_x(cpu)
value = cpu.bus.read(addr)
or_e(cpu, value)
OPCODE_TABLE = {
...
0x41: eor_indirect_x,
}`emulator/cpu/addressing_modes.py::indirect_x adds X to the operand in zero page, reads the wrapped little-endian pointer there, and returns its target. The handler reads that target and delegates XOR semantics to emulator/cpu/instructions.py::or_e`. A and Z/N may change; Carry, Overflow, X, Y, and memory remain invariant; opcode plus operand advances PC two bytes.
Misconception: X indexes the zero-page pointer location, not the final target. Out of scope: EOR (indirect),Y is lesson 142; BIT begins in lesson 143.
Run this lesson
uv run pytest tests/chapter_01_cpu/test_141_EOR_indirect_x.py -v