Repository navigation
Conversation
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>
The decoder knew the SH-2's instructions only, so SH-4 code showed the SH-4's additions as .word. Decode every instruction GNU objdump decodes for the SH-4 that it did not: the floating-point instructions, lds and sts with fpscr and fpul, pref, movca.l, ocbi, ocbp, ocbwb, shad, shld, ldtlb, clrs, sets, and ldc and stc with the SH-3 and SH-4's control and banked registers, with the same operands. Also decode mova, an SH-1 instruction. Every register is an argument. Test every addition. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by spriteice · project thread
Builds on #438 and #439; only the last commit is new here.
The SuperH decoder knows the SH-2's instructions only, so SH-4 code (the Dreamcast's) shows the SH-4's additions as
.word. This decodes every instruction that GNU objdump decodes for the SH-4 (-m sh4) and objdiff didn't, 5,537 encodings, with the same operands:fmovforms,fadd,fsub,fmul,fdiv,fmac,fcmp/eq,fcmp/gt,flds,fsts,float,ftrc,fneg,fabs,fsqrt,fldi0,fldi1,fcnvsd,fcnvds,fipr,ftrv,fschg,frchg,fscaandfsrraldsandsts(and.l) withfpscrandfpulpref,movca.l,ocbi,ocbp,ocbwb,shad,shld,ldtlb,clrs,setsldcandstc(and.l) withssr,spc,sgr,dbrand the banked registersmova, an SH-1 instruction that was missingEvery register is an
opaqueargument, so the diff compares it. Like objdump,fmovand the arithmetic show singlefrregisters, as when FPSCR.SZ and FPSCR.PR are clear, because the bytes can't say which mode the code runs in.movashows its offset asmov.l @(disp,PC)does.Checked
objdiff-cli, against GNU objdump 2.42 (-m sh4): objdiff and objdump now decode the same 59,033 values, and agree on every one, mnemonic and operands (PC-relative operands compared as addresses). capstone 5.0.9 agrees wherever both decode; it missesfcnvds,fcnvsdandfipr, and decodes some SH-2A and SH-4A instructions in its SH-4 mode..word.test_sh4_display_instructions(every addition, with a different register in each field, every register an argument, and encodings the SH-4 doesn't have) andtest_sh4_mova.cargo test -p objdiff-core,cargo +nightly fmt --checkandcargo clippy --all-targetspass.🤖 Generated with Claude Code