M68K: Fix fmove.x 96-bit extended immediate decode length and printing - #3016
Open
b1llow wants to merge 1 commit into
Open
M68K: Fix fmove.x 96-bit extended immediate decode length and printing#3016b1llow wants to merge 1 commit into
b1llow wants to merge 1 commit into
Conversation
Collaborator
|
Please add a PR description. What does the signing have to do with the bug? |
Rot127
requested changes
Aug 12, 2026
| if (!get_ea_mode_op(info, op0, info->ir, 12)) { | ||
| if (m68k_ea_is_immediate(info->ir)) { | ||
| op0->address_mode = M68K_AM_IMMEDIATE; | ||
| op0->type = M68K_OP_FP_DOUBLE; |
Collaborator
There was a problem hiding this comment.
Shouldn't this be a new operand type? Since the 96 bit is not a 64bit double? wdyt?
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.
Your checklist for this pull request
Detailed description
Summary
fmove.x #<imm>did not consume the full Motorola 96-bit extended-precision immediate, so instruction size and following bytes were wrong, and the immediate could not be printed usefully.References
Motorola MC68881/MC68882 Floating-Point Coprocessor User’s Manual, first edition (1987):
https://www.bitsavers.org/components/motorola/68000/68020/MC68881_MC68882_Floating-Point_Coprocessor_Users_Manual_1ed_1987.pdf
.x/.pFMOVE) — immediate X is six 16-bit words (12 bytes) after the F-line + command word; longest FPCP form..x(repo:M68K_FPSRC_EXTENDED).Same X layout is summarized in the M68000 Family Programmer’s Reference Manual (
.X= extended-precision real).Conversion of that external encoding to IEEE-754 binary64 for Capstone’s
dimm/ printer is an implementation detail of this patch; the ISA requirement is correct 12-byte consumption and format interpretation per the manual above.Bug
For
M68K_FPSRC_EXTENDEDimmediates the decoder used the generic EA path with size 12 and did not treat the 12-byte X encoding as a proper FP immediate:fmove.xsize was wrong and trailing instructions (e.g.nop) were mis-decoded. Contradicts the manual’s 6-word immediate X operand.inst->op_size.fpu_size. Extended immediates never became a printable FP operand type, so they showed as#<unsupported>.The sign bit is only the normal high bit of the manual’s sign+exponent word in the X→binary64 conversion. It is not the bug; the failures were undersized/incorrect immediate reads and size-based print dispatch.
Fix
read_imm_extended()/extended_to_double()— read the 12-byte X immediate per §3 (ignore reserved word) and convert to binary64 with integer arithmetic (round-ties-to-even, signed zero, inf, qNaN, subnormals).fmovepath —M68K_AM_IMMEDIATE+M68K_OP_FP_DOUBLE, value indimm.M68K_OP_FP_SINGLE/M68K_OP_FP_DOUBLE) so extended values indimmprint as#….Tests
tests/details/m68k.yamlforfmove.ximmediates:+1.0, size 16, followingnops-2.5)0.0, still full length.xsource (no inline 12-byte immediate)Impact
arch/M68K/M68KDisassembler.c— X immediate read/conversion; immediate path forM68K_FPSRC_EXTENDEDarch/M68K/M68KInstPrinter.c— print by FP operand typetests/details/m68k.yaml— cases aboveClosing issues
closes #3013