026. Sta absolute y
Add absolute,Y STA ($99).
Lesson 26 of 356 · tests/chapter_01_cpu/test_026_STA_absolute_y.py
File to update
emulator/cpu/opcodes.pyLocations
opcodes.sta_absolute_y
opcodes.OPCODE_TABLE[$99]Why this step exists
This is the Y-indexed counterpart to Test 025. It reuses absolute_y so the handler only coordinates destination resolution and the existing sta write.
Complete example implementation
# emulator/cpu/opcodes.py
def sta_absolute_y(cpu) -> None:
address = absolute_y(cpu)
sta(cpu, address)
OPCODE_TABLE = {
# Preserve existing entries.
0x99: sta_absolute_y,
}Important invariants
- two operand bytes form the base before Y is added
- Y, not X, selects the final destination
- the full indexed address is passed to sta
- STA does not update flags
Common misconception
Copying the absolute,X handler without changing the addressing helper silently uses the wrong index register when X and Y differ.
Out of scope
- indirect STA opcodes
- page-cross cycle behavior
- changes to absolute_y or sta
Run this lesson
uv run pytest tests/chapter_01_cpu/test_026_STA_absolute_y.py -v