3 Copyright (C) 1989-1995 Alan R. Baldwin
4 721 Berkeley St., Kent, Ohio 44240
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 3, or (at your option) any
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
26 * The module assubr.c contains the error
27 * processing routines.
29 * assubr.c contains the following functions:
36 * assubr.c contains the local array of *error[]
39 /*)Function VOID err(c)
41 * int c error type character
43 * The function err() logs the error code character
44 * suppressing duplicate errors. If the error code
45 * is 'q' then the parse of the current assembler-source
46 * text line is terminated.
49 * char * p pointer to the error array
52 * char eb[] array of generated error codes
55 * VOID longjmp() c_library
58 * The error code may be inserted into the
59 * error code array eb[] or the parse terminated.
78 longjmp(jump_env, -1);
81 /*)Function VOID diag()
83 * The function diag() prints any error codes and
84 * the source line number to the stderr output device.
87 * char * p pointer to error code array eb[]
90 * int cfile current source file index
91 * char eb[] array of generated error codes
92 * char * ep pointer into error list
93 * int incfile current include file index
94 * char incfn[] array of include file names
95 * int incline[] array of include line numbers
96 * char srcfn[] array of source file names
97 * int srcline[] array of source line numbers
98 * FILE * stderr c_library
101 * int fprintf() c_library
102 * char * geterr() assubr.c
108 extern int fatalErrors;
113 register char *p,*errstr;
118 fprintf(stderr, "?ASxxxx-Error-<");
120 fprintf(stderr, "%c", *p++);
122 fprintf(stderr, "> in line ");
124 fprintf(stderr, "%d", incline[incfil]);
125 fprintf(stderr, " of %s\n", incfn[incfil]);
127 fprintf(stderr, "%d", srcline[cfile]);
128 fprintf(stderr, " of %s\n", srcfn[cfile]);
132 if ((errstr = geterr(*p++)) != NULL) {
133 fprintf(stderr, " %s\n", errstr);
139 /*)Function VOID warnBanner()
141 * The function warnBanner() prints a generic warning message
142 * header (including the current source file/line) and positions
143 * the output for a more specific warning message.
145 * It is assumed that the call to warnBanner will be followed with
146 * a fprintf to stderr (or equivalent) with the specific warning
153 * int cfile current source file index
154 * int incfile current include file index
155 * char incfn[] array of include file names
156 * int incline[] array of include line numbers
157 * char srcfn[] array of source file names
158 * int srcline[] array of source line numbers
159 * FILE * stderr c_library
162 * int fprintf() c_library
170 fprintf(stderr, "?ASxxxx-Warning in line ");
172 fprintf(stderr, "%d", incline[incfil]);
173 fprintf(stderr, " of %s\n", incfn[incfil]);
175 fprintf(stderr, "%d", srcline[cfile]);
176 fprintf(stderr, " of %s\n", srcfn[cfile]);
178 fprintf(stderr, " ");
181 /*)Functions: VOID aerr()
185 * The functions aerr(), qerr(), and rerr() report their
186 * respective error type. These are included only for
196 * VOID err() assubr.c
199 * The appropriate error code is inserted into the
200 * error array and the parse may be terminated.
231 * ASxxxx assembler errors
234 "<.> use \". = . + <arg>\" not \". = <arg>\"",
235 "<a> machine specific addressing or addressing mode error",
236 "<b> direct page boundary error",
237 "<d> direct page addressing error",
238 "<i> .include file error or an .if/.endif mismatch",
239 "<m> multiple definitions error",
240 "<o> .org in REL area or directive / mnemonic error",
241 "<p> phase error: label location changing between passes 2 and 3",
242 "<q> missing or improper operators, terminators, or delimiters",
243 "<r> relocation error",
244 "<u> undefined symbol encountered during assembly",
248 /*)Function: char *getarr(c)
250 * int c the error code character
252 * The function geterr() scans the list of errors returning the
253 * error string corresponding to the input error character.
256 * int i error index counter
259 * char *errors[] array of pointers to the
266 * A pointer to the appropriate
267 * error code string is returned.
275 for (i=0; errors[i]!=NULL; i++) {
276 if (c == errors[i][1]) {