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

Manually merged
github merged 1 commit from gh-pr/847/head into gh-pr/847/base 2026-11-26 09:24:20 +00:00
Owner

@⁠KernelSmoker on GitHub · 2026-11-24 14:31 UTC · original
KernelSmoker:kernelsmoker/x64-recomp-primary-90 → main · +22 −1 · 2 files · 1 commits · merged 2026-11-25 21:39 UTC

Claimed in the coordination issue as: X64-RECOMP-PRIMARY-90 — #14

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

**@⁠KernelSmoker** on GitHub · 2026-11-24 14:31 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/847) `KernelSmoker:kernelsmoker/x64-recomp-primary-90` → `main` · +22 −1 · 2 files · 1 commits · merged 2026-11-25 21:39 UTC Claimed in the coordination issue as: X64-RECOMP-PRIMARY-90 — https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14 ### 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
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:24:19 +00:00
github manually merged commit be7478f5b6 into gh-pr/847/base 2026-11-26 09:24:20 +00:00
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 14:32 UTC · original · approved these changes

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** on GitHub · 2026-11-24 14:32 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/847#pullrequestreview-6041142709) · **approved these changes** ### 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.
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 14:36 UTC · original · approved these changes

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).

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 14:36 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/847#pullrequestreview-6041225392) · **approved these changes** 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).
Author
Owner

@⁠tiguan26 on GitHub · 2026-11-25 03:56 UTC · original · approved these changes

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).

**@⁠tiguan26** on GitHub · 2026-11-25 03:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/847#pullrequestreview-6051641458) · **approved these changes** 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).
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 21:39 UTC · original

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).

**@⁠aslan2142** on GitHub · 2026-11-25 21:39 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/847#issuecomment-7175378220) 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).
This discussion has been locked. Commenting is limited to contributors.
No description provided.