mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:25:52 +01:00
[PR #1428] x64_recomp: fix short-form xchg (0x91..0x97) and movnti (0F C3) widths/emission (X64-RECOMP-SHORT-XCHG-MOVNTI) #1458
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1458
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1428
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/x64-recomp-short-xchg-movnti📝 Commits (1)
41db945x64_recomp: fix short-form xchg (0x91..0x97) and movnti (0F C3) widths/emission (X64-RECOMP-SHORT-XCHG-MOVNTI)📊 Changes
2 files changed (+191 additions, -0 deletions)
View changed files
➕
tests/test_x64_recomp_xchg_movnti.py(+182 -0)📝
tools/x64_recomp.py(+9 -0)📄 Description
Item ID:
X64-RECOMP-SHORT-XCHG-MOVNTIAI-assisted: yes
Summary
Fixes two bugs in
tools/x64_recomp.py:xchg rAX, r(0x91..0x97) decoded asOq Oq(a 64-bit self-swap no-op):PRIMARY[0x91..0x97]had opspec"Oq Oq", which decoded both operands as the opcode register(opcode & 7) | (rexb << 3)at fixed 64-bit width — makingxchg eax, r/xchg ax, r/xchg rax, rswaprwith itself and never touchRAX, while also ignoring 32-bit zero-extension and 16-bit upper-48-bit preservation.xchgshort-form opspec ("Oq Oq"or"Oq Rq"from #847) to"Ov Av"indecode_onebefore_finish()gives the exact opcode register (O, REX.B-extended) and fixed accumulator (A=r0, never REX.B-extended) at operand widthv(2/4/8 bytes), with zero merge conflict against #847 (X64-RECOMP-PRIMARY-90).movnti(0F C3) width and emission:OF[0xC3]had opspec"Ev Gv", so66 0F C3decoded as 16-bit even though x86-64movntiignores0x66and only has 32-bit (0F C3) and 64-bit (48 0F C3) memory-store forms.decode_onenow sets"Eq Gq" if rexw else "Ed Gd"formovnti, and_emit_movemits memorymovntistores directly (and rejects non-memorymod=3forms).Verification (macOS Apple M5, arm64, Python 3.14; no game files)
python3 -m compileall -q make_game.py tools tests— OKpython3 -I scripts/check_no_game_data.py tools/x64_recomp.py tests/test_x64_recomp_xchg_movnti.py— OKpython3 -I tests/test_x64_recomp_xchg_movnti.py(standalone) — 6 decode/translate tests OK (5 exec tests skipped without #1174 runner)python3 -I tests/test_text_write_line_endings.py— 3/3 OKpython3 -I tests/test_ci_registration.py— 16/16 OKupstream/main364ab4eab+ #1174 runner + new test file):Ran 11 tests — FAILED (failures=10, errors=1)(all 11 decode + native execution tests fail without this fix).x64_recompPR branches + this PR): 0 conflicts, all 24tests/test_x64_recomp*.pysuites (208/208 tests OK, 0 skips).pull/847/headon top of the 24-way merge with 0 conflicts; verified41 90,66 41 90,49 90, and66 48 91all decode with exact operand widths.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.