132. Ora indirect x
add ORA (indirect,X) opcode ``0x01``.
Lesson 132 of 356 · tests/chapter_01_cpu/test_132_ORA_indirect_x.py
Why this step exists
Pre-indexed indirect ORA supports zero-page pointer tables and confirms that pointer lookup is completed before the resulting memory value is ORed with A.
In this step, lesson 131 has completed the direct ORA modes. Add exactly the following to `emulator/cpu/opcodes.py`:
def ora_indirect_x(cpu: CPU):
addr = indirect_x(cpu)
value = cpu.bus.read(addr)
or_a(cpu, value)
OPCODE_TABLE = {
...
0x01: ora_indirect_x,
}`emulator/cpu/addressing_modes.py::indirect_x fetches the operand, adds X with zero-page wrapping, and reads a little-endian pointer whose high-byte lookup also wraps in zero page. The handler reads the pointed-to value and delegates ORA flags/result to instructions.or_a`. A and Z/N may change; Carry/Overflow, memory, X, and Y remain invariant; PC advances two bytes.
Misconception: X is added before pointer dereferencing, not to the final 16-bit address. Out of scope: ORA (indirect),Y (lesson 133) and EOR/BIT (134-145).
Run this lesson
uv run pytest tests/chapter_01_cpu/test_132_ORA_indirect_x.py -v