* cgen-asm.in (insert_normal): Handle empty fields and 64 bit hosts.
[deliverable/binutils-gdb.git] / opcodes / cgen-asm.in
index 37250da97d52b096ca389a9ea4a77bcb77be0952..b714009d69b840beac69fb3e3b842075080a942d 100644 (file)
@@ -28,6 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "bfd.h"
 #include "symcat.h"
 #include "@arch@-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
@@ -36,11 +37,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
    compiled with GCC), or switch to macros, or use something else.
 */
 
+static const char * insert_normal
+     PARAMS ((long, unsigned int, int, int, int, char *));
 static const char * parse_insn_normal
      PARAMS ((const CGEN_INSN *, const char **, CGEN_FIELDS *));
 static const char * insert_insn_normal
      PARAMS ((const CGEN_INSN *, CGEN_FIELDS *, cgen_insn_t *));
 \f
+/* -- assembler routines inserted here */
+\f
 /* Default insertion routine.
 
    ATTRS is a mask of the boolean attributes.
@@ -55,32 +60,25 @@ static const char * insert_insn_normal
    store insn in `field' struct and add registers, etc. while parsing?  */
 
 static const char *
-insert_normal (value, attrs, start, length, shift, total_length, buffer)
+insert_normal (value, attrs, start, length, total_length, buffer)
      long value;
      unsigned int attrs;
      int start;
      int length;
-     int shift;
      int total_length;
      char * buffer;
 {
   bfd_vma x;
   static char buf[100];
 
-  if (shift < 0)
-    value <<= -shift;
-  else
-    value >>= shift;
-
   /* Ensure VALUE will fit.  */
   if ((attrs & (1 << CGEN_OPERAND_UNSIGNED)) != 0)
     {
       unsigned long max = (1 << length) - 1;
       if ((unsigned long) value > max)
        {
-         const char *err = "operand out of range (%lu not between 0 and %lu)";
-
-         sprintf (buf, err, value, max);
+         sprintf (buf, _("operand out of range (%lu not between 0 and %lu)"),
+                  value, max);
          return buf;
        }
     }
@@ -89,12 +87,9 @@ insert_normal (value, attrs, start, length, shift, total_length, buffer)
       long min = - (1 << (length - 1));
       long max = (1 << (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);
-         return buf;
-       }
+       return sprintf
+         (buf, _("operand out of range (%ld not between %ld and %ld)"),
+          value, min, max);
     }
 
 #if 0 /*def CGEN_INT_INSN*/
@@ -150,8 +145,6 @@ insert_normal (value, attrs, start, length, shift, total_length, buffer)
   return NULL;
 }
 \f
-/* -- assembler routines inserted here */
-\f
 /* Default insn parser.
 
    The syntax string is scanned and operands are parsed and stored in FIELDS.
@@ -186,8 +179,9 @@ parse_insn_normal (insn, strp, fields)
   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 ();
@@ -225,7 +219,7 @@ parse_insn_normal (insn, strp, fields)
              /* 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;
        }
@@ -251,7 +245,7 @@ parse_insn_normal (insn, strp, fields)
        ++ 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;
     }
@@ -330,9 +324,14 @@ insert_insn_normal (insn, fields, buffer)
    This routine is called for each instruction to be assembled.
    STR points to the insn to be assembled.
    We assume all necessary tables have been initialized.
+   The assembled instruction, less any fixups, is stored in buf.
+   [??? What byte order?]
    The result is a pointer to the insn's entry in the opcode table,
    or NULL if an error occured (an error message will have already been
-   printed).  */
+   printed).
+
+   Note that when processing (non-alias) macro-insns,
+   this function recurses.  */
 
 const CGEN_INSN *
 @arch@_cgen_assemble_insn (str, fields, buf, errmsg)
@@ -396,8 +395,12 @@ const CGEN_INSN *
      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 ? "..." : "");
+    /* xgettext:c-format */
+    if (strlen (start) > 50)
+      sprintf (errbuf, _("bad instruction `%.50s...'"), start);
+    else
+      sprintf (errbuf, _("bad instruction `%.50s'"), start);
+      
     *errmsg = errbuf;
     return NULL;
   }
This page took 0.025269 seconds and 4 git commands to generate.