* config/tc-m68k.c (m68k_ip): If instruction is invalid for the

selected architecture, print a message saying so and listing what
processors support it, rather than saying "operands mismatch".
This commit is contained in:
Ken Raeburn
1992-08-15 02:57:12 +00:00
parent 2e20e59abc
commit 8be74775cd

View File

@ -992,6 +992,7 @@ void m68k_ip (instring)
char *crack_operand();
LITTLENUM_TYPE words[6];
LITTLENUM_TYPE *wordp;
unsigned long ok_arch = 0;
if (*instring == ' ')
instring++; /* skip leading whitespace */
@ -1048,7 +1049,6 @@ void m68k_ip (instring)
for(n=opsfound;n>0;--n)
the_ins.operands[n]=the_ins.operands[n-1];
/* memcpy((char *)(&the_ins.operands[1]), (char *)(&the_ins.operands[0]), opsfound*sizeof(the_ins.operands[0])); */
memset((char *)(&the_ins.operands[0]), '\0', sizeof(the_ins.operands[0]));
the_ins.operands[0].mode=MSCR;
the_ins.operands[0].reg=COPNUM; /* COP #1 */
@ -1062,11 +1062,12 @@ void m68k_ip (instring)
then reject this pattern. */
if (opsfound != opcode->m_opnum
|| ((opcode->m_arch & current_architecture) == 0)) {
|| ((opcode->m_arch & current_architecture) == 0))
{
++losing;
} else {
ok_arch |= opcode->m_arch;
}
else {
for (s=opcode->m_operands, opP = &the_ins.operands[0]; *s && !losing; s += 2, opP++) {
/* Warning: this switch is huge! */
/* I've tried to organize the cases into this order:
@ -1378,7 +1379,8 @@ void m68k_ip (instring)
*s, __LINE__, __FILE__);
} /* switch on type of operand */
if (losing) break;
if (losing)
break;
} /* for each operand */
} /* if immediately wrong */
@ -1389,7 +1391,67 @@ void m68k_ip (instring)
opcode = opcode->m_next;
if (!opcode) {
the_ins.error = "instruction/operands mismatch or invalid\n instruction for this architecture";
if (ok_arch)
{
char buf[200], *cp;
int len;
strcpy (buf, "invalid instruction for this architecture; needs ");
cp = buf + strlen (buf);
switch (ok_arch)
{
case mfloat:
strcpy (cp, "fpu");
break;
case mmmu:
strcpy (cp, "mmu");
break;
case m68020up:
strcpy (cp, "68020 or higher");
break;
case m68000up:
strcpy (cp, "68000 or higher");
break;
case m68010up:
strcpy (cp, "68010 or higher");
break;
default:
{
int got_one = 0, idx;
const static struct {
enum m68k_architecture arch;
const char *name;
} archs[] = {
m68000, "68000",
m68010, "68010",
m68020, "68020",
m68030, "68030",
m68040, "68040",
m68881, "68881",
m68851, "68851",
};
for (idx = 0; idx < sizeof (archs)/sizeof (archs[0]); idx++)
{
if (archs[idx].arch & ok_arch)
{
if (got_one)
{
strcpy (cp, " or ");
cp += strlen (cp);
}
got_one = 1;
strcpy (cp, archs[idx].name);
cp += strlen (cp);
}
}
}
}
len = cp - buf + 1;
cp = malloc (len);
strcpy (cp, buf);
the_ins.error = cp;
}
else
the_ins.error = "operands mismatch";
return;
} /* Fell off the end */