Skip to content

fix(cpu): decode wide extend-and-add (UXTAH/UXTAB/SXTAH/SXTAB)#331

Merged
w1ne merged 2 commits into
mainfrom
fix/wide-extend-and-add
Jun 22, 2026
Merged

fix(cpu): decode wide extend-and-add (UXTAH/UXTAB/SXTAH/SXTAB)#331
w1ne merged 2 commits into
mainfrom
fix/wide-extend-and-add

Conversation

@w1ne

@w1ne w1ne commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to the wide register-extend decode. That change covered only the
plain extends ({S,U}XT{B,H}.W, Rn=0xF). The extend-and-add variants
{S,U}XTA{B,H}.W (Rn != 0xF, e.g. UXTAH = 0xFA1n) still fell through to
Unknown32 and were silently skipped, leaving the destination register stale.

clang emits uxtah r6, r3, r0 (FA13 F680) for 4 + (val & 0xFFFF). A udslib
RequestFileTransfer (0x38) handler uses exactly this for its 4 + path_len
length check — with the instruction skipped, r6 kept a stale value and the
check wrongly rejected valid requests (NRC 0x13). (A debug printf "fixed"
it by perturbing register allocation — the tell that this was an emulator
instruction gap, not firmware.)

Fix

Broaden the wide-extend decode to the whole family (0xFA00..0xFA5F), capture
Rn, and in the executor add Rn when Rn != 0xF (the extend-and-add form).

Test

Adds a UXTAH case (extend-and-add with a stale-register overwrite check) to
the wide-extend regression test. Full labwired-core lib suite green (1399).

w1ne added 2 commits June 22, 2026 12:42
Follow-up to the wide register-extend decode: that change only handled the
plain extends (Rn=0xF). The extend-and-add variants {S,U}XTA{B,H}.W
(Rn != 0xF, e.g. UXTAH = 0xFA1n) still fell through to Unknown32 and were
skipped, leaving the destination register stale.

clang emits `uxtah r6, r3, r0` (FA13 F680) for `4 + (val & 0xFFFF)` — a udslib
RequestFileTransfer (0x38) handler uses exactly this for its `4 + path_len`
length check. With the insn skipped, r6 kept a stale value and the check
wrongly rejected valid requests (NRC 0x13). Broadens the decode to the whole
extend family and adds Rn to the executor (add Rn when Rn != 0xF). Adds a
UXTAH regression case; full labwired-core lib suite green (1342).
@w1ne w1ne merged commit bdc6eb4 into main Jun 22, 2026
2 checks passed
@w1ne w1ne deleted the fix/wide-extend-and-add branch June 22, 2026 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant