152. Cmp absolute y

add CMP absolute,Y opcode ``0xD9``.

Lesson 152 of 356 · tests/chapter_01_cpu/test_152_CMP_absolute_y.py

Why this step exists

Absolute,Y provides the corresponding indexed comparison through Y while reusing the shared CMP behavior.

In this step, lesson 151 has already added absolute,X. Add exactly the following to `emulator/cpu/opcodes.py`:

def cmp_absolute_y(cpu: CPU):
    addr = absolute_y(cpu)
    value = cpu.bus.read(addr)
    cmp(cpu, value)

OPCODE_TABLE = {
    ...
    0xD9: cmp_absolute_y,
}

`emulator/cpu/addressing_modes.py::absolute_y fetches the little-endian base word and adds Y before the bus read. instructions.cmp` changes only C/Z/N; A, Y, memory, and Overflow remain invariant, while opcode plus word advances PC three bytes.

Misconception: Y modifies the effective address, not the fetched value, and the base bytes are not big-endian. Out of scope: CMP indirect,X and indirect,Y (153-154), then CPX/CPY (155-162).

Run this lesson

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