121. And absolute x

add AND absolute,X opcode ``0x3D``.

Lesson 121 of 356 · tests/chapter_01_cpu/test_121_AND_absolute_x.py

Why this step exists

Programs need AND over table-like memory addressed by a full base plus X; this step connects that effective-address calculation to the shared AND behavior.

In this step, with AND semantics and the unindexed absolute handler already present, add exactly this incremental code to `emulator/cpu/opcodes.py`:

def and_absolute_x(cpu: CPU):
    addr = absolute_x(cpu)
    value = cpu.bus.read(addr)
    and_a(cpu, value)

OPCODE_TABLE = {
    ...
    0x3D: and_absolute_x,
}

`emulator/cpu/addressing_modes.py::absolute_x fetches the little-endian base word, then adds cpu.x. The handler reads the resolved address and passes its value to instructions.and_a`. A and Z/N change; X, Carry/Overflow, and memory are invariant; opcode plus word advances PC three bytes.

Misconception: X indexes the decoded address, not either operand byte or the loaded value. Out of scope: AND absolute,Y and indirect modes (lessons 122-124), plus ORA/EOR/BIT work in lessons 125-145.

Run this lesson

uv run pytest tests/chapter_01_cpu/test_121_AND_absolute_x.py -v