145. Bit absolute
add BIT absolute opcode ``0x2C``.
Lesson 145 of 356 · tests/chapter_01_cpu/test_145_BIT_absolute.py
Why this step exists
Absolute BIT extends the flag-only test to the full address space and verifies that its two-byte operand is decoded as a little-endian memory address.
In this step, with BIT semantics and its opcode import established in lessons 143-144, add exactly the following to `emulator/cpu/opcodes.py`:
def bit_absolute(cpu: CPU):
addr = absolute(cpu)
value = cpu.bus.read(addr)
bit(cpu, value)
OPCODE_TABLE = {
...
0x2C: bit_absolute,
}`emulator/cpu/addressing_modes.py::absolute uses CPU.fetch_word` to decode the little-endian address. The handler performs one bus read and BIT only consumes that value. Z/N/V may change; A, Carry, X, Y, and memory remain invariant; opcode plus word advances PC three bytes.
Misconception: `2C 02 20 does not test literal $2002`; it reads that address, with any bus-owned side effects remaining bus behavior. Out of scope: CMP and its compare opcodes begin in lesson 146.
Run this lesson
uv run pytest tests/chapter_01_cpu/test_145_BIT_absolute.py -v