200. Plp implied

register implied PLP.

Lesson 200 of 356 · tests/chapter_01_cpu/test_200_PLP_implied.py

Prerequisite: step 199 added `plp. In this step, change only emulator/cpu/opcodes.py by importing plp and adding its OPCODE_TABLE` entry.

Why this step exists

PLP obtains its value from the stack selected by S. Opcode $28 has no operand and must dispatch directly to `plp(cpu)`.

Suggested implementation

from emulator.cpu.instructions import plp

OPCODE_TABLE = {
    # existing entries
    0x28: plp,
}

Invariants: preserve all existing mappings; map exactly $28 to `plp`; use no addressing-mode wrapper; consume only the opcode byte; preserve step 199's replace-and-mask semantics.

Misconception: the byte after $28 is the next instruction, not the status byte to restore; status comes exclusively from the incremented stack slot.

Out of scope: PLP behavior is step 199. TXS/TSX belong to steps 201-204. Later Break/ONE behavior must not be anticipated.

Run this lesson

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