127. Ora zero page
add ORA zero-page opcode ``0x05``.
Lesson 127 of 356 · tests/chapter_01_cpu/test_127_ORA_zero_page.py
Why this step exists
ORA must distinguish a zero-page address operand from literal data, read the addressed byte, and then apply the already-defined inclusive-OR behavior.
In this step, with `or_a imported by lesson 126, the complete incremental implementation in emulator/cpu/opcodes.py` is:
def ora_zero_page(cpu: CPU):
addr = zero_page(cpu)
value = cpu.bus.read(addr)
or_a(cpu, value)
OPCODE_TABLE = {
...
0x05: ora_zero_page,
}`emulator/cpu/addressing_modes.py::zero_page fetches the one-byte address, then the handler reads its value before calling instructions.or_a. A and Z/N change; Carry/Overflow and memory remain invariant; 05 10 reads $0010` and advances PC two bytes.
Misconception: pass the byte stored at `$0010 to or_a, not address 0x10`, and do not write the result back to memory. Out of scope: zero-page,X through indirect,Y ORA modes (lessons 128-133).
Run this lesson
uv run pytest tests/chapter_01_cpu/test_127_ORA_zero_page.py -v