3 Copyright (C) 1997-2018 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
22 /* Stand-alone test for instruction specification table support.
23 Run using "itbl-test <itbl> <asm.s>"
24 where <itbl> is the name of the instruction table,
25 and <asm.s> is the name of the assembler fie. */
33 static int test_reg (e_processor processor
, e_type type
, char *name
,
37 main (int argc
, char **argv
)
46 printf ("usage: %s itbl asm.s\n", argv
[0]);
49 if (itbl_parse (argv
[1]) != 0)
51 printf ("failed to parse itbl\n");
55 fas
= fopen (argv
[2], "r");
58 printf ("failed to open asm file %s\n", argv
[2]);
61 while (fgets (s
, 80, fas
))
66 if (p
= strchr (s
, ';'), p
) /* strip comments */
68 if (p
= strchr (s
, '#'), p
) /* strip comments */
70 p
= s
+ strlen (s
) - 1;
71 while (p
>= s
&& (*p
== ' ' || *p
== '\t' || *p
== '\n')) /* strip trailing spaces */
75 while (*p
&& (*p
== ' ' || *p
== '\t' || *p
== '\n')) /* strip leading spaces */
80 name
= itbl_get_field (&p
);
81 insn
= itbl_assemble (name
, p
);
83 printf ("line %d: Invalid instruction (%s)\n", aline
, s
);
87 printf ("line %d: insn(%s) = 0x%x)\n", aline
, s
, insn
);
88 if (!itbl_disassemble (buf
, insn
))
89 printf ("line %d: Can't disassemble instruction "
90 "(0x%x)\n", aline
, insn
);
92 printf ("line %d: disasm(0x%x) = %s)\n", aline
, insn
, buf
);
96 test_reg (1, e_dreg
, "d1", 1);
97 test_reg (3, e_creg
, "c2", 22);
98 test_reg (3, e_dreg
, "d3", 3);
105 test_reg (e_processor processor
, e_type type
, char *name
,
111 n
= itbl_get_name (processor
, type
, val
);
112 if (!n
|| strcmp (n
, name
))
113 printf ("Error - reg name not found for proessor=%d, type=%d, val=%d\n",
114 processor
, type
, val
);
116 printf ("name=%s found for processor=%d, type=%d, val=%d\n",
117 n
, processor
, type
, val
);
119 /* We require that names be unique among processors and types. */
120 if (! itbl_get_reg_val (name
, &v
)
122 printf ("Error - reg val not found for processor=%d, type=%d, name=%s\n",
123 processor
, type
, name
);
125 printf ("val=0x%x found for processor=%d, type=%d, name=%s\n",
126 v
, processor
, type
, name
);
This page took 0.035615 seconds and 4 git commands to generate.