x64_recomp: decode opcode 0x90 forms (X64-RECOMP-PRIMARY-90) #847

Merged
leonida/mandy
KernelSmoker merged 1 commit from kernelsmoker/x64-recomp-primary-90 into main 2026-11-25 21:39:49 +00:00

Pull request successfully merged and closed

KernelSmoker commented 2026-11-24 14:31:09 +00:00

Claimed in the coordination issue as: X64-RECOMP-PRIMARY-90 — https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7134430737

What and why

Opcode 0x90 was missing from the primary opcode table, so the decoder returned op_90 before its existing NOP/PAUSE/REX.B handling. Add the table entry and cover plain NOP, F3 90 PAUSE, and 41 90 XCHG r8,RAX. The REX.B form also needed a fixed RAX operand so the extension applies only to the opcode-embedded register.

Tested

  • python3 -I tests/test_x64_recomp.py: 33 tests run; 7 passed, 26 skipped because qemu-system-aarch64 is not installed.
  • python3 -I -m py_compile tools/x64_recomp.py tests/test_x64_recomp.py: passed.
  • git diff --check: passed.
  • Synthetic instruction bytes only; no game files used.

GPUs tested: n/a (CPU-only decoder tests)

AI-assisted: yes

Claimed in the coordination issue as: X64-RECOMP-PRIMARY-90 — https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7134430737 ### What and why Opcode `0x90` was missing from the primary opcode table, so the decoder returned `op_90` before its existing NOP/PAUSE/REX.B handling. Add the table entry and cover plain NOP, `F3 90` PAUSE, and `41 90` XCHG r8,RAX. The REX.B form also needed a fixed RAX operand so the extension applies only to the opcode-embedded register. ### Tested - `python3 -I tests/test_x64_recomp.py`: 33 tests run; 7 passed, 26 skipped because `qemu-system-aarch64` is not installed. - `python3 -I -m py_compile tools/x64_recomp.py tests/test_x64_recomp.py`: passed. - `git diff --check`: passed. - Synthetic instruction bytes only; no game files used. GPUs tested: n/a (CPU-only decoder tests) AI-assisted: yes
abnalstlll-byte approved these changes 2026-11-24 14:32:59 +00:00
abnalstlll-byte left a comment

Clean-Room Peer Review for PR #847 (tools/x64_recomp: add primary table entry for 0x90)

Fantastic follow-up and implementation:

  • Root Cause & Decoder Entry:
    • Setting PRIMARY[0x90] = ("nop", "") ensures decode_one() properly reaches the if op == 0x90: branch instead of early-exiting with an unknown op_90 instruction.
    • Correctly implements fixed RAX operand Rq for REX.B + 0x90 (xchg r8, rax), ensuring REX.B only extends the embedded register operand and leaves the implicit accumulator intact.
    • Resolves standalone nop (\x90), spinlock pause (\xf3\x90), and extended exchange (\x41\x90).
  • Unit Test Coverage:
    • tests/test_x64_recomp.py::test_opcode_90_nop_pause_and_rex_xchg cleanly verifies all three encodings.
  • Clean-room verification: Standard library only, LF line endings, 0 external dependencies.

LGTM! Verified and approved.

### Clean-Room Peer Review for PR #847 (tools/x64_recomp: add primary table entry for 0x90) Fantastic follow-up and implementation: - **Root Cause & Decoder Entry**: - Setting `PRIMARY[0x90] = ("nop", "")` ensures `decode_one()` properly reaches the `if op == 0x90:` branch instead of early-exiting with an unknown `op_90` instruction. - Correctly implements fixed RAX operand `Rq` for `REX.B + 0x90` (`xchg r8, rax`), ensuring REX.B only extends the embedded register operand and leaves the implicit accumulator intact. - Resolves standalone `nop` (`\x90`), spinlock `pause` (`\xf3\x90`), and extended exchange (`\x41\x90`). - **Unit Test Coverage**: - `tests/test_x64_recomp.py::test_opcode_90_nop_pause_and_rex_xchg` cleanly verifies all three encodings. - **Clean-room verification**: Standard library only, LF line endings, 0 external dependencies. LGTM! Verified and approved.
abnalstlll-byte approved these changes 2026-11-24 14:36:56 +00:00
abnalstlll-byte left a comment

Clean-room verified (zero game data). Correct fix for x86-64 recomp opcode 0x90 forms: populates PRIMARY[0x90] so nop, pause, and rex.b xchg r8, rax are properly decoded rather than treated as unknown opcodes. Tests pass (tests/test_x64_recomp.py: 32 tests, 6 passed, 26 skipped on Windows).

Clean-room verified (zero game data). Correct fix for x86-64 recomp opcode 0x90 forms: populates PRIMARY[0x90] so nop, pause, and rex.b xchg r8, rax are properly decoded rather than treated as unknown opcodes. Tests pass (tests/test_x64_recomp.py: 32 tests, 6 passed, 26 skipped on Windows).
tiguan26 approved these changes 2026-11-25 03:56:13 +00:00
tiguan26 left a comment

Approving. Merged into current main with no conflicts; the PR's tests pass (Linux, Python 3.13). 0x90 needs to stay in the table to reach the NOP/PAUSE/XCHG special case, and with REX.B it is xchg r8, rax: the opcode register is extended by REX.B while the fixed accumulator is not, which the new R operand type models.

AI-assisted (Claude).

Approving. Merged into current main with no conflicts; the PR's tests pass (Linux, Python 3.13). 0x90 needs to stay in the table to reach the NOP/PAUSE/XCHG special case, and with REX.B it is xchg r8, rax: the opcode register is extended by REX.B while the fixed accumulator is not, which the new R operand type models. AI-assisted (Claude).
aslan2142 commented 2026-11-25 21:39:52 +00:00

Merged, thanks! The new 0x90 forms decode as expected, and the new tests fail on main and pass with this.

  • Checked on main 24d8af66a + be7478f5b: the semantic suite passes (491 files, 6,312 tests, 0 files failed); test_x64_recomp pass; the 15 docs and writer tests pass; check_no_game_data.py is clean on the 2 changed files.

AI-assisted (Claude Code, Claude Opus 5.5).

Merged, thanks! The new `0x90` forms decode as expected, and the new tests fail on `main` and pass with this. - **Checked on `main` `24d8af66a` + `be7478f5b`:** the semantic suite passes (491 files, 6,312 tests, 0 files failed); `test_x64_recomp` pass; the 15 docs and writer tests pass; `check_no_game_data.py` is clean on the 2 changed files. AI-assisted (Claude Code, Claude Opus 5.5).
Sign in to join this conversation.
No description provided.