056. Adc zero page x
Connect ADC zero page,X (opcode $75) to CPU dispatch.
Lesson 56 of 356 · tests/chapter_01_cpu/test_056_ADC_zero_page_x.py
File to update
emulator/cpu/opcodes.pySymbols to create/update
opcodes.adc_zero_page_x
OPCODE_TABLE[$75]Why this step exists
This mode reuses the established zero_page_x resolver, including its page-zero wraparound. The opcode handler then reads the resolved location and passes its value to adc.
Complete example implementation
# emulator/cpu/opcodes.py
def adc_zero_page_x(cpu):
addr = zero_page_x(cpu)
value = cpu.bus.read(addr)
adc(cpu, value)
OPCODE_TABLE = {
# ...existing entries...
0x75: adc_zero_page_x,
}Important invariants
- X is added by
zero_page_x, not by the handler a second time (operand + X) & 0xFFkeeps the effective address in page zero- the byte at the effective address, not the address, is passed to
adc - PC advances by two bytes total
Common misconception
Do not use ordinary 16-bit addition for the index; $FF + $01 must resolve to $0000, not $0100.
Out of scope
- absolute indexed and indirect ADC modes
- page-crossing timing
- changes to the existing addressing helper
Run this lesson
uv run pytest tests/chapter_01_cpu/test_056_ADC_zero_page_x.py -v