108. Rol absolute x 绝对变址

接入 ROL Absolute,X(操作码 ``0x3E``)。

108 / 356 · tests/chapter_01_cpu/test_108_ROL_absolute_x.py

在本步骤中,在第 107 课之后,只添加 Absolute,X 适配器和分派条目,完成 ROL 系列。

生产代码位置中的完整示例实现

`emulator/cpu/opcodes.py::rol_absolute_x`::

def rol_absolute_x(cpu: CPU):
    addr = absolute_x(cpu)
    rol(cpu, addr)

`emulator/cpu/opcodes.py::OPCODE_TABLE`::

0x3E: rol_absolute_x,

本步骤存在的原因

`absolute_x 集中处理小端序解码和 X 变址;rol` 只负责操作语义。

不变量:消耗两个操作数字节,解码出 16 位基址,再加上 X;当 X=`0x04 时,3E 00 02 指向 $0204`,PC 最终为起始位置+3。内存原语的 C/Z/N 行为保持不变。

常见误解:不要只对单个操作数字节做变址,也不要套用零页回绕;该模式是对解码出的 16 位绝对基址做变址。

不在本步骤范围内:ROR 原语从第 109 课开始,ROR 操作码从第 111 课开始;跨页和周期精确的读/改/写行为是之后的工作。

运行本课

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