#include "bfd.h"
#include "symcat.h"
#include "m32r-opc.h"
+#include "opintl.h"
/* ??? The layout of this stuff is still work in progress.
For speed in assembly/disassembly, we use inline functions. That of course
if (**strp == '#')
++*strp;
- if (strncmp (*strp, "high(", 5) == 0)
+ if (strncasecmp (*strp, "high(", 5) == 0)
{
*strp += 5;
errmsg = cgen_parse_address (strp, opindex, BFD_RELOC_M32R_HI16_ULO,
*valuep >>= 16;
return errmsg;
}
- else if (strncmp (*strp, "shigh(", 6) == 0)
+ else if (strncasecmp (*strp, "shigh(", 6) == 0)
{
*strp += 6;
errmsg = cgen_parse_address (strp, opindex, BFD_RELOC_M32R_HI16_SLO,
if (**strp == '#')
++*strp;
- if (strncmp (*strp, "low(", 4) == 0)
+ if (strncasecmp (*strp, "low(", 4) == 0)
{
*strp += 4;
errmsg = cgen_parse_address (strp, opindex, BFD_RELOC_M32R_LO16,
return errmsg;
}
- if (strncmp (*strp, "sda(", 4) == 0)
+ if (strncasecmp (*strp, "sda(", 4) == 0)
{
*strp += 4;
errmsg = cgen_parse_address (strp, opindex, BFD_RELOC_M32R_SDA16, NULL, valuep);
if (**strp == '#')
++*strp;
- if (strncmp (*strp, "low(", 4) == 0)
+ if (strncasecmp (*strp, "low(", 4) == 0)
{
*strp += 4;
errmsg = cgen_parse_address (strp, opindex, BFD_RELOC_M32R_LO16,
break;
default :
- fprintf (stderr, "Unrecognized field %d while parsing.\n", opindex);
+ /* xgettext:c-format */
+ fprintf (stderr, _("Unrecognized field %d while parsing.\n"), opindex);
abort ();
}
break;
default :
- fprintf (stderr, "Unrecognized field %d while building insn.\n",
+ /* xgettext:c-format */
+ fprintf (stderr, _("Unrecognized field %d while building insn.\n"),
opindex);
abort ();
}
{
bfd_vma x;
static char buf[100];
+ /* Written this way to avoid undefined behaviour.
+ Yes, `long' will be bfd_vma but not yet. */
+ long mask = (((1L << (length - 1)) - 1) << 1) | 1;
+
+ /* If LENGTH is zero, this operand doesn't contribute to the value. */
+ if (length == 0)
+ return NULL;
/* Ensure VALUE will fit. */
- if ((attrs & (1 << CGEN_OPERAND_UNSIGNED)) != 0)
+ if ((attrs & CGEN_ATTR_MASK (CGEN_OPERAND_UNSIGNED)) != 0)
{
- unsigned long max = (1 << length) - 1;
+ unsigned long max = mask;
if ((unsigned long) value > max)
{
- const char *err = "operand out of range (%lu not between 0 and %lu)";
-
- sprintf (buf, err, value, max);
+ /* xgettext:c-format */
+ sprintf (buf, _("operand out of range (%lu not between 0 and %lu)"),
+ value, max);
return buf;
}
}
else
{
- long min = - (1 << (length - 1));
- long max = (1 << (length - 1)) - 1;
+ long min = - (1L << (length - 1));
+ long max = (1L << (length - 1)) - 1;
if (value < min || value > max)
{
- const char *err = "operand out of range (%ld not between %ld and %ld)";
-
- sprintf (buf, err, value, min, max);
+ sprintf
+ /* xgettext:c-format */
+ (buf, _("operand out of range (%ld not between %ld and %ld)"),
+ value, min, max);
return buf;
}
}
#if 0 /*def CGEN_INT_INSN*/
- *buffer |= ((value & ((1 << length) - 1))
- << (total_length - (start + length)));
+ *buffer |= (value & mask) << (total_length - (start + length));
#else
switch (total_length)
{
abort ();
}
- x |= ((value & ((1 << length) - 1))
- << (total_length - (start + length)));
+ x |= (value & mask) << (total_length - (start + length));
switch (total_length)
{
p = CGEN_INSN_MNEMONIC (insn);
while (* p && * p == * str)
++ p, ++ str;
+
if (* p || (* str && !isspace (* str)))
- return "unrecognized instruction";
+ return _("unrecognized instruction");
CGEN_INIT_PARSE ();
cgen_init_parse_operand ();
/* Syntax char didn't match. Can't be this insn. */
/* FIXME: would like to return something like
"expected char `c'" */
- return "syntax error";
+ return _("syntax error");
}
continue;
}
++ str;
if (* str != '\0')
- return "junk at end of line"; /* FIXME: would like to include `str' */
+ return _("junk at end of line"); /* FIXME: would like to include `str' */
return NULL;
}
Need to track why it failed and pick the right one. */
{
static char errbuf[100];
- sprintf (errbuf, "bad instruction `%.50s%s'",
- start, strlen (start) > 50 ? "..." : "");
+ if (strlen (start) > 50)
+ /* xgettext:c-format */
+ sprintf (errbuf, _("bad instruction `%.50s...'"), start);
+ else
+ /* xgettext:c-format */
+ sprintf (errbuf, _("bad instruction `%.50s'"), start);
+
*errmsg = errbuf;
return NULL;
}