101. Lsr absolute x
wire LSR Absolute,X (opcode ``0x5E``).
Lesson 101 of 356 · tests/chapter_01_cpu/test_101_LSR_absolute_x.py
In this step, add only the final LSR addressing-mode adapter and dispatch entry below. The instruction primitive and other LSR modes from lessons 095-100 are prerequisites.
Suggested implementation in the production locations
`emulator/cpu/opcodes.py::lsr_absolute_x`::
def lsr_absolute_x(cpu: CPU):
addr = absolute_x(cpu)
lsr(cpu, addr)`emulator/cpu/opcodes.py::OPCODE_TABLE`::
0x5E: lsr_absolute_x,Why this step exists
Opcode handlers translate encoded operands into effective addresses; `instructions.lsr` remains independent of addressing mode.
Invariants: `absolute_x(cpu) consumes the little-endian two-byte operand, adds cpu.x, and leaves the PC three bytes past the opcode; lsr performs the read/modify/write and flag updates at that address. Thus 5E 00 02 with X=0x04 targets $0204`.
Misconception: the operand is neither the value to shift nor an 8-bit zero-page address; do not add X to only one operand byte or call `lsr_a`.
Out of scope: ROL/ROR behavior and opcodes begin in lessons 102 onward; cycle accuracy and page-cross timing are not part of this step.
Run this lesson
uv run pytest tests/chapter_01_cpu/test_101_LSR_absolute_x.py -v