148. Cmp zero page

add CMP zero-page opcode ``0xC5``.

Lesson 148 of 356 · tests/chapter_01_cpu/test_148_CMP_zero_page.py

Why this step exists

CMP must compare A with memory as well as literals; this form resolves a compact zero-page address and passes the fetched byte to the common comparison logic.

In this step, lessons 146-147 already provide CMP semantics, import, and immediate wiring. Add exactly the following to `emulator/cpu/opcodes.py`:

def cmp_zero_page(cpu: CPU):
    addr = zero_page(cpu)
    value = cpu.bus.read(addr)
    cmp(cpu, value)

OPCODE_TABLE = {
    ...
    0xC5: cmp_zero_page,
}

The operand names a zero-page location; its bus value, not the address byte, is compared with A. C/Z/N may change; A, Overflow, X, Y, and memory remain invariant; PC advances two bytes.

Misconception: `C5 10 compares against RAM[$0010], not literal $10`. Out of scope: indexed zero page is lesson 149 and wider/indirect CMP modes are lessons 150-154.

Run this lesson

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