081. Inx 隐含寻址

接入 INX 隐含寻址操作码。

81 / 356 · tests/chapter_01_cpu/test_081_INX_implied.py

在这一步中,仅在测试 080 提供了 instructions.inx 之后,添加 INX 操作码的接入。

生产代码位置与符号

emulator/cpu/opcodes.py: imported `inx` and `OPCODE_TABLE[0xE8]`

本步骤存在的原因

INX 采用隐含寻址,因此分发可以直接调用指令函数。不需要包装器或寻址模式辅助函数。

本步骤的实现建议

# emulator/cpu/opcodes.py
from emulator.cpu.instructions import inx  # alongside existing imports

OPCODE_TABLE = {
    # ... existing entries ...
    0xE8: inx,
}

重要不变量

  • 操作码 0xE8 精确分发到 inx(cpu) 函数
  • 不获取操作数字节,因此 CPU.step 将 PC 推进一个字节
  • 寄存器回绕以及 Z/N 更新仍由测试 080 的 inx 负责

常见误解

不要创建 inx_implied 包装器;隐含寻址指令可以是直接的表项,包装器不会带来额外的解码行为。

不在本步骤范围内

  • 测试 082 的 dex 指令行为以及测试 083 的 DEX 映射
  • 后续的 INY/DEY 及移位指令
  • 周期计时

运行本课

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