diff mbox

[1/1] target/m68k: correctly disassemble move16

Message ID 20180625203559.21370-2-laurent@vivier.eu (mailing list archive)
State New, archived
Headers show

Commit Message

Laurent Vivier June 25, 2018, 8:35 p.m. UTC
"move16 %a0@+,%a1@" and "fmovel (cpid=3) %a0@-,%fpcr"
share the same opcode.

To fix that, backport the fix from binutils:

  2005-11-10  Andreas Schwab  <schwab@suse.de>

     * m68k-dis.c (print_insn_m68k): Only match FPU insns with
     coprocessor ID 1.

Reported-by: Thomas Huth <huth@tuxfamily.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 disas/m68k.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Thomas Huth June 26, 2018, 4:24 a.m. UTC | #1
Am Mon, 25 Jun 2018 22:35:59 +0200
schrieb Laurent Vivier <laurent@vivier.eu>:

> "move16 %a0@+,%a1@" and "fmovel (cpid=3) %a0@-,%fpcr"
> share the same opcode.
> 
> To fix that, backport the fix from binutils:
> 
>   2005-11-10  Andreas Schwab  <schwab@suse.de>
> 
>      * m68k-dis.c (print_insn_m68k): Only match FPU insns with
>      coprocessor ID 1.
> 
> Reported-by: Thomas Huth <huth@tuxfamily.org>
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
>  disas/m68k.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)

Thank you very much, Laurent, this indeed fixes the problem for me!

Tested-by: Thomas Huth <huth@tuxfamily.org>
diff mbox

Patch

diff --git a/disas/m68k.c b/disas/m68k.c
index 61b689ef3e..a687df437c 100644
--- a/disas/m68k.c
+++ b/disas/m68k.c
@@ -2017,6 +2017,20 @@  print_insn_m68k (bfd_vma memaddr, disassemble_info *info)
 		}
 	    }
 
+          /* Don't match FPU insns with non-default coprocessor ID.  */
+          if (*d == '\0')
+            {
+              for (d = opc->args; *d; d += 2)
+                {
+                  if (d[0] == 'I')
+                    {
+                      val = fetch_arg (buffer, 'd', 3, info);
+                      if (val != 1)
+                        break;
+                    }
+                }
+            }
+
 	  if (*d == '\0')
 	    if ((val = match_insn_m68k (memaddr, info, opc, & priv)))
 	      return val;