194. Pha implied
register implied PHA.
Lesson 194 of 356 · tests/chapter_01_cpu/test_194_PHA_implied.py
Prerequisite: step 193 added `pha. In this step, change only emulator/cpu/opcodes.py by importing pha and adding its entry to OPCODE_TABLE`.
Why this step exists
PHA gets its source from CPU register A, so opcode $48 requires no addressing mode or operand and can dispatch directly to `pha(cpu)`.
Suggested implementation
from emulator.cpu.instructions import pha
OPCODE_TABLE = {
# existing entries
0x48: pha,
}Invariants: preserve existing mappings; map exactly $48 to the `pha` function object; consume only the opcode byte; leave stack behavior to step 193's function.
Misconception: the byte following $48 is the next opcode, not an accumulator value to push.
Out of scope: implementing `pha` is step 193. PLA starts at step 195; other stack instruction mappings belong to their later numbered steps.
Run this lesson
uv run pytest tests/chapter_01_cpu/test_194_PHA_implied.py -v