1 /* This file is part of the program psim.
3 Copyright (C) 1994-1997, Andrew Cagney <cagney@highland.com.au>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>.
25 #include "build-config.h"
41 error (char *msg, ...)
53 void *memory = malloc(size);
55 error("zalloc failed\n");
56 memset(memory, 0, size);
61 dumpf (int indent, char *msg, ...)
64 for (; indent > 0; indent--)
89 if (a[1] == 'x' || a[1] == 'X') {
107 if (ch >= '0' && ch <= '9') {
108 num = (num * 10) + (ch - '0');
115 if (ch >= '0' && ch <= '7') {
116 num = (num * 8) + (ch - '0');
123 if (ch >= '0' && ch <= '9') {
124 num = (num * 16) + (ch - '0');
125 } else if (ch >= 'a' && ch <= 'f') {
126 num = (num * 16) + (ch - 'a' + 10);
127 } else if (ch >= 'A' && ch <= 'F') {
128 num = (num * 16) + (ch - 'A' + 10);
143 target_a2i(int ms_bit_nr,
147 return (ms_bit_nr - a2i(a));
153 i2target(int ms_bit_nr,
157 return ms_bit_nr - bit;
164 name2i(const char *names,
167 const name_map *curr;
168 const char *name = names;
169 while (*name != '\0') {
171 char *end = strchr(name, ',');
175 end = strchr(name, '\0');
184 while (curr->name != NULL) {
185 if (strncmp(curr->name, name, len) == 0
186 && strlen(curr->name) == len)
192 /* nothing found, possibly return a default */
194 while (curr->name != NULL)
199 error("%s contains no valid names\n", names);
207 while (map->name != NULL) {
212 error("map lookup failed for %d\n", i);