From e827819b6b6b71beb55a321b9a18531c78e5b453 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Wed, 8 Jun 2005 17:02:54 +0000 Subject: [PATCH] PR991 * config/tc-m68k.c (m68k_ip): Test for insn compatiblity using a temporary copy of the operands array so that changes can be safely backed out if the insn does not match. (m68k_compare_opcode): Shortcut the test when the parameters are the same. Return 1 if the names match but the second opcode is further on in the array than the first. --- gas/ChangeLog | 10 ++++++++++ gas/config/tc-m68k.c | 22 ++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index 9bb49febc..5ea13977d 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,13 @@ +2005-06-08 Tomas Hurka + + PR991 + * config/tc-m68k.c (m68k_ip): Test for insn compatiblity using a + temporary copy of the operands array so that changes can be safely + backed out if the insn does not match. + (m68k_compare_opcode): Shortcut the test when the parameters are + the same. Return 1 if the names match but the second opcode is + further on in the array than the first. + 2005-06-08 Nick Clifton PR 994 diff --git a/gas/config/tc-m68k.c b/gas/config/tc-m68k.c index eb6e4690a..07b06e743 100644 --- a/gas/config/tc-m68k.c +++ b/gas/config/tc-m68k.c @@ -1089,6 +1089,7 @@ m68k_ip (char *instring) char c; int losing; int opsfound; + struct m68k_op operands_backup[6]; LITTLENUM_TYPE words[6]; LITTLENUM_TYPE *wordp; unsigned long ok_arch = 0; @@ -1213,7 +1214,15 @@ m68k_ip (char *instring) ++losing; else { - for (s = opcode->m_operands, opP = &the_ins.operands[0]; + int i; + + /* Make a copy of the operands of this insn so that + we can modify them safely, should we want to. */ + assert (opsfound <= (int) ARRAY_SIZE (operands_backup)); + for (i = 0; i < opsfound; i++) + operands_backup[i] = the_ins.operands[i]; + + for (s = opcode->m_operands, opP = &operands_backup[0]; *s && !losing; s += 2, opP++) { @@ -1974,6 +1983,12 @@ m68k_ip (char *instring) if (losing) break; } + + /* Since we have found the correct instruction, copy + in the modifications that we may have made. */ + if (!losing) + for (i = 0; i < opsfound; i++) + the_ins.operands[i] = operands_backup[i]; } if (!losing) @@ -4116,6 +4131,9 @@ m68k_compare_opcode (const void * v1, const void * v2) struct m68k_opcode * op1, * op2; int ret; + if (v1 == v2) + return 0; + op1 = *(struct m68k_opcode **) v1; op2 = *(struct m68k_opcode **) v2; @@ -4126,7 +4144,7 @@ m68k_compare_opcode (const void * v1, const void * v2) return ret; if (op1 < op2) return -1; - return 0; + return 1; } void -- 2.11.4.GIT