Skip to content

SuperH: compare every register as an instruction argument - #439

Open
spriteice wants to merge 2 commits into
encounter:mainfrom
spriteice:superh-register-arguments
Open

spriteice wants to merge 2 commits into
encounter:mainfrom
spriteice:superh-register-arguments

Conversation

@spriteice

Copy link
Copy Markdown

Requested by spriteice · project thread

Builds on #438, so that its test can use the byte order field; only the last commit is new here.

objdiff compares instructions by their arguments, and the SuperH decoder pushes some registers as InstructionPart::basic: Rn of add #imm,Rn, and both registers of mov.l Rm,@(disp,Rn) and mov.l @(disp,Rm),Rn. So two functions that differ only in one of those registers show as a 100% match: add #0x1, r4 against add #0x1, r5, for example, on Saturn code as well as Dreamcast code. This makes them opaque arguments like every other register. It also shows tas.b @Rn with its @ (it showed as tas.b r0).

Checked

  • A new test, test_sh2_registers_are_arguments, checks the text and the arguments of each instruction; the existing tas.b expectation now has its @.
  • objdiff-cli diff of two objects that differ only in add #0x1, r4 / r5: a 100% match before, an argument mismatch now.
  • cargo test -p objdiff-core, cargo +nightly fmt --check and cargo clippy --all-targets pass.

🤖 Generated with Claude Code

spriteice and others added 2 commits December 4, 2026 20:08
The SuperH backend read every opcode, and the literal pool values shown
after mov.w and mov.l, as big-endian. That suits the Saturn, but Dreamcast
(SH-4) objects are little-endian, so every instruction was decoded wrongly.
Take the byte order from the object, as the ARM and MIPS backends do, and
test both orders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The diff compares instructions by their arguments, and the SuperH decoder
pushed the register of add #imm,Rn and both registers of
mov.l Rm,@(disp,Rn) and mov.l @(disp,Rm),Rn as plain text. Two functions
that differed only in one of those registers showed as a 100% match. Make
them arguments, like every other register, and show tas.b @rn with its @.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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