198. Php implied

register implied PHP.

Lesson 198 of 356 · tests/chapter_01_cpu/test_198_PHP_implied.py

Prerequisite: step 197 added `php. In this step, change only emulator/cpu/opcodes.py by importing php and registering it in OPCODE_TABLE`.

Why this step exists

PHP obtains P and S directly from CPU state. Opcode $08 therefore has no operand and dispatches directly to `php(cpu)`.

Suggested implementation

from emulator.cpu.instructions import php

OPCODE_TABLE = {
    # existing entries
    0x08: php,
}

Invariants: preserve existing mappings; map exactly $08 to the `php` function object; use no addressing wrapper or operand fetch; consume one opcode byte and retain step 197's stack/status semantics.

Misconception: the byte after $08 is not status data; PHP pushes live P.

Out of scope: PHP behavior belongs to step 197, and PLP begins at step 199. Changes to PHP's pushed byte do not belong to this opcode-registration step.

Run this lesson

uv run pytest tests/chapter_01_cpu/test_198_PHP_implied.py -v