156. Cpx immediate
expose CPX immediate as opcode ``0xE0``.
Lesson 156 of 356 · tests/chapter_01_cpu/test_156_CPX_immediate.py
Why this step exists
Immediate CPX first exposes the comparison through CPU execution with a literal value and no data-memory lookup.
In this step, after lesson 155 creates the instruction, make these additions in `emulator/cpu/opcodes.py`:
from emulator.cpu.instructions import (..., cpx)
def cpx_immediate(cpu: CPU):
cpx(cpu, immediate(cpu))
OPCODE_TABLE = {
...
0xE0: cpx_immediate,
}`emulator/cpu/addressing_modes.py::immediate returns CPU.fetch_byte()` directly as the compared value. CPX changes only C/Z/N; X, memory, and Overflow remain invariant, and opcode plus operand advances PC two bytes.
Misconception: the immediate byte is a value, not an address requiring a bus read. Out of scope: CPX zero-page and absolute (157-158), and every CPY symbol and opcode (159-162).
Run this lesson
uv run pytest tests/chapter_01_cpu/test_156_CPX_immediate.py -v