* itbl-test.c: New file. Stand-alone assembler and dissassembler for
authorDawn Perchik <dawn@cygnus>
Tue, 11 Feb 1997 01:57:34 +0000 (01:57 +0000)
committerDawn Perchik <dawn@cygnus>
Tue, 11 Feb 1997 01:57:34 +0000 (01:57 +0000)
itbl support.

gas/testsuite/ChangeLog
gas/testsuite/gas/mips/.Sanitize
gas/testsuite/gas/mips/itbl-test.c [new file with mode: 0644]

index df820ecf98a83ac04c963a0d6bbc88c24af62387..1367d92fc3d6ed6c52682f3af6eade9f9426b58c 100644 (file)
@@ -1,3 +1,8 @@
+Mon Feb 10 17:54:00 1997  Dawn Perchik  dawn@cygnus.com>
+
+       * itbl-test.c: New file.  Stand-alone assembler and dissassembler 
+       for itbl support.
+
 Mon Feb 10 17:20:00 1997  Dawn Perchik  dawn@cygnus.com>
 
        * gas/mips/itbl: New file.  Instruction Spec for testing --itbl option.
index f62406958c06b9269f7b2da09b4555163ee76d81..6d370dbca25c58925eb508fe627a1c4a910179d6 100644 (file)
@@ -47,6 +47,7 @@ dli.d
 dli.s
 itbl
 itbl.s
+itbl-test.c
 jal-empic.d
 jal-svr4pic.d
 jal-svr4pic.s
diff --git a/gas/testsuite/gas/mips/itbl-test.c b/gas/testsuite/gas/mips/itbl-test.c
new file mode 100644 (file)
index 0000000..4f6bcee
--- /dev/null
@@ -0,0 +1,98 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "itbl-ops.h"
+
+static int test_reg(e_processor processor, e_type type, char* name, 
+       unsigned long val);
+
+int main(int argc, char **argv)
+{
+       unsigned int insn;
+       FILE *fas;
+       int aline=0;
+       char s[81], *name;
+
+       if (argc<3)
+       {
+               printf("usage: %s itbl asm.s\n", argv[0]);
+               exit(0);
+       }
+       if (itbl_parse(argv[1]) != 0)
+       {
+               printf("failed to parse itbl\n");
+               exit(0);
+       }
+
+       fas=fopen(argv[2],"r");
+       if (fas==0)
+       {
+               printf("failed to open asm file %s\n", argv[2]);
+               exit(0);
+       }
+       while (fgets(s,80,fas))
+       {
+       char *p;
+       aline++;
+
+       if (p = strchr(s,';'),p)        /* strip comments */
+           *p = 0;
+       if (p = strchr(s,'#'),p)        /* strip comments */
+           *p = 0;
+       p = s+strlen(s)-1;
+       while (p>=s && (*p==' ' || *p=='\t' || *p=='\n')) /* strip trailing spaces */
+           p--;
+       *(p+1) = 0;
+       p = s;
+       while (*p && (*p==' ' || *p=='\t' || *p == '\n')) /* strip leading spaces */
+           p++;
+       if (!*p)
+               continue;
+
+       name = itbl_get_insn_name(&p);
+       insn = itbl_assemble(name,p);
+       if (insn == 0)
+           printf("line %d: Invalid instruction (%s)\n", aline, s);
+       else
+       {
+           char buf[128];
+           printf("line %d: insn(%s) = 0x%x)\n", aline, s, insn);
+           if (!itbl_disassemble(buf,insn))
+               printf("line %d: Can't disassemble instruction "
+                       "(0x%x)\n", aline, insn);
+           else
+               printf("line %d: disasm(0x%x) = %s)\n", aline, insn, buf);
+       }
+       }
+
+    test_reg(1, e_dreg, "d1", 1);
+    test_reg(3, e_creg, "c2", 22);
+    test_reg(3, e_dreg, "d3", 3);
+
+    return 0;
+}
+
+static int test_reg(e_processor processor, e_type type, char* name, 
+       unsigned long val)
+{
+    char *n;
+    unsigned long v;
+
+    n = itbl_get_reg_name(processor, type, val);
+    if (!n || strcmp(n,name))
+           printf("Error - reg name not found for proessor=%d, type=%d, val=%d\n",
+                       processor, type, val);
+    else
+           printf("name=%s found for processor=%d, type=%d, val=%d\n",
+                   n, processor, type, val);
+
+    v = itbl_get_reg_val(processor, type, name);
+    if (!v || v!=val)
+           printf("Error - reg val not found for processor=%d, type=%d, name=%s\n",
+                   processor, type, name);
+    else
+           printf("val=0x%x found for processor=%d, type=%d, name=%s\n",
+                   v, processor, type, name);
+    return 0;
+}