From a7f081a5be64456cdd268ceb515db7c94737c2b2 Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Tue, 11 Feb 1997 08:22:27 +0000 Subject: [PATCH] * gas/mips/itbl-test.c: Add copyright message and fix indentation. --- gas/testsuite/ChangeLog | 8 +- gas/testsuite/gas/mips/itbl-test.c | 190 +++++++++++++++++++++---------------- 2 files changed, 116 insertions(+), 82 deletions(-) diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index 1367d92..8235c16 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,7 +1,11 @@ +Mon Feb 10 22:24:00 1997 Dawn Perchik dawn@cygnus.com> + + * gas/mips/itbl-test.c: Add copyright message and fix indentation. + 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. + * gas/mips/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> diff --git a/gas/testsuite/gas/mips/itbl-test.c b/gas/testsuite/gas/mips/itbl-test.c index 4f6bcee..8b8e896 100644 --- a/gas/testsuite/gas/mips/itbl-test.c +++ b/gas/testsuite/gas/mips/itbl-test.c @@ -1,98 +1,128 @@ + +/* itbl-test.c + + Copyright (C) 1997 Free Software Foundation, Inc. + + This file is part of GAS, the GNU Assembler. + + GAS is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + GAS is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GAS; see the file COPYING. If not, write to the Free + Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ + +/* Stand-alone test for instruction specification table support. + Run using "itbl-test " + where is the name of the instruction table, + and is the name of the assembler fie. */ + + #include #include #include #include "itbl-ops.h" -static int test_reg(e_processor processor, e_type type, char* name, - unsigned long val); +static int test_reg (e_processor processor, e_type type, char *name, + unsigned long val); -int main(int argc, char **argv) +int +main (int argc, char **argv) { - unsigned int insn; - FILE *fas; - int aline=0; - char s[81], *name; + 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); - } + 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 + 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); - } + 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); + test_reg (1, e_dreg, "d1", 1); + test_reg (3, e_creg, "c2", 22); + test_reg (3, e_dreg, "d3", 3); - return 0; + return 0; } -static int test_reg(e_processor processor, e_type type, char* name, - unsigned long val) +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; + 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; } -- 2.7.4