5 Copyright (C) 1997 Free Software Foundation, Inc.
7 This file is part of GAS, the GNU Assembler.
9 GAS is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
14 GAS is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GAS; see the file COPYING. If not, write to the Free
21 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
24 /* Stand-alone test for instruction specification table support.
25 Run using "itbl-test <itbl> <asm.s>"
26 where <itbl> is the name of the instruction table,
27 and <asm.s> is the name of the assembler fie. */
35 static int test_reg (e_processor processor
, e_type type
, char *name
,
39 main (int argc
, char **argv
)
48 printf ("usage: %s itbl asm.s\n", argv
[0]);
51 if (itbl_parse (argv
[1]) != 0)
53 printf ("failed to parse itbl\n");
57 fas
= fopen (argv
[2], "r");
60 printf ("failed to open asm file %s\n", argv
[2]);
63 while (fgets (s
, 80, fas
))
68 if (p
= strchr (s
, ';'), p
) /* strip comments */
70 if (p
= strchr (s
, '#'), p
) /* strip comments */
72 p
= s
+ strlen (s
) - 1;
73 while (p
>= s
&& (*p
== ' ' || *p
== '\t' || *p
== '\n')) /* strip trailing spaces */
77 while (*p
&& (*p
== ' ' || *p
== '\t' || *p
== '\n')) /* strip leading spaces */
82 name
= itbl_get_field (&p
);
83 insn
= itbl_assemble (name
, p
);
85 printf ("line %d: Invalid instruction (%s)\n", aline
, s
);
89 printf ("line %d: insn(%s) = 0x%x)\n", aline
, s
, insn
);
90 if (!itbl_disassemble (buf
, insn
))
91 printf ("line %d: Can't disassemble instruction "
92 "(0x%x)\n", aline
, insn
);
94 printf ("line %d: disasm(0x%x) = %s)\n", aline
, insn
, buf
);
98 test_reg (1, e_dreg
, "d1", 1);
99 test_reg (3, e_creg
, "c2", 22);
100 test_reg (3, e_dreg
, "d3", 3);
106 test_reg (e_processor processor
, e_type type
, char *name
,
112 n
= itbl_get_name (processor
, type
, val
);
113 if (!n
|| strcmp (n
, name
))
114 printf ("Error - reg name not found for proessor=%d, type=%d, val=%d\n",
115 processor
, type
, val
);
117 printf ("name=%s found for processor=%d, type=%d, val=%d\n",
118 n
, processor
, type
, val
);
120 /* We require that names be unique amoung processors and types. */
121 if (! itbl_get_reg_val (name
, &v
)
123 printf ("Error - reg val not found for processor=%d, type=%d, name=%s\n",
124 processor
, type
, name
);
126 printf ("val=0x%x found for processor=%d, type=%d, name=%s\n",
127 v
, processor
, type
, name
);
This page took 0.03265 seconds and 4 git commands to generate.