1 /* gasp.c - Gnu assembler preprocessor main program.
2 Copyright (C) 1994, 95, 96, 97, 98, 99, 2000
3 Free Software Foundation, Inc.
5 Written by Steve and Judy Chamberlain of Cygnus Support,
8 This file is part of GASP, the GNU Assembler Preprocessor.
10 GASP is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
15 GASP is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with GASP; see the file COPYING. If not, write to the Free
22 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
27 This program translates the input macros and stuff into a form
28 suitable for gas to consume.
31 gasp [-sdhau] [-c char] [-o <outfile>] <infile>*
33 -s copy source to output
34 -c <char> comments are started with <char> instead of !
35 -u allow unreasonable stuff
37 -d print debugging stats
38 -s semi colons start comments
39 -a use alternate syntax
40 Pseudo ops can start with or without a .
41 Labels have to be in first column.
42 -I specify include dir
43 Macro arg parameters subsituted by name, don't need the &.
44 String can start with ' too.
45 Strings can be surrounded by <..>
46 A %<exp> in a string evaluates the expression
47 Literal char in a string with !
63 #ifdef NEED_MALLOC_DECLARATION
64 extern char *malloc ();
68 #include "libiberty.h"
73 char *program_version
= "1.2";
75 /* This is normally declared in as.h, but we don't include that. We
76 need the function because other files linked with gasp.c might call
78 extern void as_abort
PARAMS ((const char *, int, const char *));
80 /* The default obstack chunk size. If we set this to zero, the
81 obstack code will use whatever will fit in a 4096 byte block. This
82 is used by the hash table code used by macro.c. */
85 #define MAX_INCLUDES 30 /* Maximum include depth */
86 #define MAX_REASONABLE 1000 /* Maximum number of expansions */
88 int unreasonable
; /* -u on command line */
89 int stats
; /* -d on command line */
90 int print_line_number
; /* -p flag on command line */
91 int copysource
; /* -c flag on command line */
92 int warnings
; /* Number of WARNINGs generated so far. */
93 int errors
; /* Number of ERRORs generated so far. */
94 int fatals
; /* Number of fatal ERRORs generated so far (either 0 or 1). */
95 int alternate
= 0; /* -a on command line */
96 int mri
= 0; /* -M on command line */
97 char comment_char
= '!';
98 int radix
= 10; /* Default radix */
100 int had_end
; /* Seen .END */
102 /* The output stream */
105 /* the attributes of each character are stored as a bit pattern
106 chartype, which gives us quick tests. */
113 #define COMMENTBIT 16
115 #define ISCOMMENTCHAR(x) (chartype[(unsigned char)(x)] & COMMENTBIT)
116 #define ISFIRSTCHAR(x) (chartype[(unsigned char)(x)] & FIRSTBIT)
117 #define ISNEXTCHAR(x) (chartype[(unsigned char)(x)] & NEXTBIT)
118 #define ISSEP(x) (chartype[(unsigned char)(x)] & SEPBIT)
119 #define ISWHITE(x) (chartype[(unsigned char)(x)] & WHITEBIT)
120 #define ISBASE(x) (chartype[(unsigned char)(x)] & BASEBIT)
121 static char chartype
[256];
124 /* Conditional assembly uses the `ifstack'. Each aif pushes another
125 entry onto the stack, and sets the on flag if it should. The aelse
126 sets hadelse, and toggles on. An aend pops a level. We limit to
127 100 levels of nesting, not because we're facists pigs with read
128 only minds, but because more than 100 levels of nesting is probably
129 a bug in the user's macro structure. */
131 #define IFNESTING 100
134 int on
; /* is the level being output */
135 int hadelse
; /* has an aelse been seen */
140 /* The final and intermediate results of expression evaluation are kept in
141 exp_t's. Note that a symbol is not an sb, but a pointer into the input
142 line. It must be coped somewhere safe before the next line is read in. */
153 int value
; /* constant part */
154 symbol add_symbol
; /* name part */
155 symbol sub_symbol
; /* name part */
160 /* Hashing is done in a pretty standard way. A hash_table has a
161 pointer to a vector of pointers to hash_entrys, and the size of the
162 vector. A hash_entry contains a union of all the info we like to
163 store in hash table. If there is a hash collision, hash_entries
164 with the same hash are kept in a chain. */
166 /* What the data in a hash_entry means */
169 hash_integer
, /* name->integer mapping */
170 hash_string
, /* name->string mapping */
171 hash_macro
, /* name is a macro */
172 hash_formal
/* name is a formal argument */
177 sb key
; /* symbol name */
178 hash_type type
; /* symbol meaning */
183 struct macro_struct
*m
;
184 struct formal_struct
*f
;
186 struct hs
*next
; /* next hash_entry with same hash key */
196 /* Structures used to store macros.
198 Each macro knows its name and included text. It gets built with a
199 list of formal arguments, and also keeps a hash table which points
200 into the list to speed up formal search. Each formal knows its
201 name and its default value. Each time the macro is expanded, the
202 formals get the actual values attatched to them. */
204 /* describe the formal arguments to a macro */
206 typedef struct formal_struct
208 struct formal_struct
*next
; /* next formal in list */
209 sb name
; /* name of the formal */
210 sb def
; /* the default value */
211 sb actual
; /* the actual argument (changed on each expansion) */
212 int index
; /* the index of the formal 0..formal_count-1 */
216 /* describe the macro. */
218 typedef struct macro_struct
220 sb sub
; /* substitution text. */
221 int formal_count
; /* number of formal args. */
222 formal_entry
*formals
; /* pointer to list of formal_structs */
223 hash_table formal_hash
; /* hash table of formals. */
227 /* how we nest files and expand macros etc.
229 we keep a stack of of include_stack structs. each include file
230 pushes a new level onto the stack. we keep an sb with a pushback
231 too. unget chars are pushed onto the pushback sb, getchars first
232 checks the pushback sb before reading from the input stream.
234 small things are expanded by adding the text of the item onto the
235 pushback sb. larger items are grown by pushing a new level and
236 allocating the entire pushback buf for the item. each time
237 something like a macro is expanded, the stack index is changed. we
238 can then perform an exitm by popping all entries off the stack with
239 the same stack index. if we're being reasonable, we can detect
240 recusive expansion by checking the index is reasonably small.
245 include_file
, include_repeat
, include_while
, include_macro
250 sb pushback
; /* current pushback stream */
251 int pushback_index
; /* next char to read from stream */
252 FILE *handle
; /* open file */
253 sb name
; /* name of file */
254 int linecount
; /* number of lines read so far */
256 int index
; /* index of this layer */
258 include_stack
[MAX_INCLUDES
];
260 struct include_stack
*sp
;
261 #define isp (sp - include_stack)
263 /* Include file list */
265 typedef struct include_path
267 struct include_path
*next
;
271 include_path
*paths_head
;
272 include_path
*paths_tail
;
275 static void quit
PARAMS ((void));
276 static void hash_new_table
PARAMS ((int, hash_table
*));
277 static int hash
PARAMS ((sb
*));
278 static hash_entry
*hash_create
PARAMS ((hash_table
*, sb
*));
279 static void hash_add_to_string_table
PARAMS ((hash_table
*, sb
*, sb
*, int));
280 static void hash_add_to_int_table
PARAMS ((hash_table
*, sb
*, int));
281 static hash_entry
*hash_lookup
PARAMS ((hash_table
*, sb
*));
282 static void checkconst
PARAMS ((int, exp_t
*));
283 static int sb_strtol
PARAMS ((int, sb
*, int, int *));
284 static int level_0
PARAMS ((int, sb
*, exp_t
*));
285 static int level_1
PARAMS ((int, sb
*, exp_t
*));
286 static int level_2
PARAMS ((int, sb
*, exp_t
*));
287 static int level_3
PARAMS ((int, sb
*, exp_t
*));
288 static int level_4
PARAMS ((int, sb
*, exp_t
*));
289 static int level_5
PARAMS ((int, sb
*, exp_t
*));
290 static int exp_parse
PARAMS ((int, sb
*, exp_t
*));
291 static void exp_string
PARAMS ((exp_t
*, sb
*));
292 static int exp_get_abs
PARAMS ((const char *, int, sb
*, int *));
294 static void strip_comments
PARAMS ((sb
*));
296 static void unget
PARAMS ((int));
297 static void include_buf
PARAMS ((sb
*, sb
*, include_type
, int));
298 static void include_print_where_line
PARAMS ((FILE *));
299 static void include_print_line
PARAMS ((FILE *));
300 static int get_line
PARAMS ((sb
*));
301 static int grab_label
PARAMS ((sb
*, sb
*));
302 static void change_base
PARAMS ((int, sb
*, sb
*));
303 static void do_end
PARAMS ((sb
*));
304 static void do_assign
PARAMS ((int, int, sb
*));
305 static void do_radix
PARAMS ((sb
*));
306 static int get_opsize
PARAMS ((int, sb
*, int *));
307 static int eol
PARAMS ((int, sb
*));
308 static void do_data
PARAMS ((int, sb
*, int));
309 static void do_datab
PARAMS ((int, sb
*));
310 static void do_align
PARAMS ((int, sb
*));
311 static void do_res
PARAMS ((int, sb
*, int));
312 static void do_export
PARAMS ((sb
*));
313 static void do_print
PARAMS ((int, sb
*));
314 static void do_heading
PARAMS ((int, sb
*));
315 static void do_page
PARAMS ((void));
316 static void do_form
PARAMS ((int, sb
*));
317 static int get_any_string
PARAMS ((int, sb
*, sb
*, int, int));
318 static int skip_openp
PARAMS ((int, sb
*));
319 static int skip_closep
PARAMS ((int, sb
*));
320 static int dolen
PARAMS ((int, sb
*, sb
*));
321 static int doinstr
PARAMS ((int, sb
*, sb
*));
322 static int dosubstr
PARAMS ((int, sb
*, sb
*));
323 static void process_assigns
PARAMS ((int, sb
*, sb
*));
324 static int get_and_process
PARAMS ((int, sb
*, sb
*));
325 static void process_file
PARAMS ((void));
326 static void free_old_entry
PARAMS ((hash_entry
*));
327 static void do_assigna
PARAMS ((int, sb
*));
328 static void do_assignc
PARAMS ((int, sb
*));
329 static void do_reg
PARAMS ((int, sb
*));
330 static int condass_lookup_name
PARAMS ((sb
*, int, sb
*, int));
331 static int whatcond
PARAMS ((int, sb
*, int *));
332 static int istrue
PARAMS ((int, sb
*));
333 static void do_aif
PARAMS ((int, sb
*));
334 static void do_aelse
PARAMS ((void));
335 static void do_aendi
PARAMS ((void));
336 static int condass_on
PARAMS ((void));
337 static void do_if
PARAMS ((int, sb
*, int));
338 static int get_mri_string
PARAMS ((int, sb
*, sb
*, int));
339 static void do_ifc
PARAMS ((int, sb
*, int));
340 static void do_aendr
PARAMS ((void));
341 static void do_awhile
PARAMS ((int, sb
*));
342 static void do_aendw
PARAMS ((void));
343 static void do_exitm
PARAMS ((void));
344 static void do_arepeat
PARAMS ((int, sb
*));
345 static void do_endm
PARAMS ((void));
346 static void do_irp
PARAMS ((int, sb
*, int));
347 static void do_local
PARAMS ((int, sb
*));
348 static void do_macro
PARAMS ((int, sb
*));
349 static int macro_op
PARAMS ((int, sb
*));
350 static int getstring
PARAMS ((int, sb
*, sb
*));
351 static void do_sdata
PARAMS ((int, sb
*, int));
352 static void do_sdatab
PARAMS ((int, sb
*));
353 static int new_file
PARAMS ((const char *));
354 static void do_include
PARAMS ((int, sb
*));
355 static void include_pop
PARAMS ((void));
356 static int get
PARAMS ((void));
357 static int linecount
PARAMS ((void));
358 static int include_next_index
PARAMS ((void));
359 static void chartype_init
PARAMS ((void));
360 static int process_pseudo_op
PARAMS ((int, sb
*, sb
*));
361 static void add_keyword
PARAMS ((const char *, int));
362 static void process_init
PARAMS ((void));
363 static void do_define
PARAMS ((const char *));
364 static void show_usage
PARAMS ((FILE *, int));
365 static void show_help
PARAMS ((void));
368 do { include_print_where_line (stderr); fprintf x ; fatals++; quit(); } while(0)
370 do { include_print_where_line (stderr); fprintf x; errors++; } while(0)
372 do { include_print_where_line (stderr); fprintf x; warnings++;} while(0)
376 /* exit the program and return the right ERROR code. */
389 for (i
= 0; i
< sb_max_power_two
; i
++)
391 fprintf (stderr
, "strings size %8d : %d\n", 1<<i
, string_count
[i
]);
397 /* hash table maintenance. */
399 /* build a new hash table with size buckets, and fill in the info at ptr. */
402 hash_new_table (size
, ptr
)
408 ptr
->table
= (hash_entry
**) xmalloc (size
* (sizeof (hash_entry
*)));
409 /* Fill with null-pointer, not zero-bit-pattern. */
410 for (i
= 0; i
< size
; i
++)
414 /* calculate and return the hash value of the sb at key. */
423 for (i
= 0; i
< key
->len
; i
++)
431 /* lookup key in hash_table tab, if present, then return it, otherwise
432 build a new one and fill it with hash_integer. */
436 hash_create (tab
, key
)
440 int k
= hash (key
) % tab
->size
;
442 hash_entry
**table
= tab
->table
;
450 hash_entry
*n
= (hash_entry
*) xmalloc (sizeof (hash_entry
));
453 sb_add_sb (&n
->key
, key
);
455 n
->type
= hash_integer
;
458 if (strncmp (table
[k
]->key
.ptr
, key
->ptr
, key
->len
) == 0)
466 /* add sb name with key into hash_table tab. if replacing old value
467 and again, then ERROR. */
471 hash_add_to_string_table (tab
, key
, name
, again
)
477 hash_entry
*ptr
= hash_create (tab
, key
);
478 if (ptr
->type
== hash_integer
)
480 sb_new (&ptr
->value
.s
);
482 if (ptr
->value
.s
.len
)
485 ERROR ((stderr
, _("redefinition not allowed\n")));
488 ptr
->type
= hash_string
;
489 sb_reset (&ptr
->value
.s
);
491 sb_add_sb (&ptr
->value
.s
, name
);
494 /* add integer name to hash_table tab with sb key. */
498 hash_add_to_int_table (tab
, key
, name
)
503 hash_entry
*ptr
= hash_create (tab
, key
);
507 /* lookup sb key in hash_table tab. if found return hash_entry result,
512 hash_lookup (tab
, key
)
516 int k
= hash (key
) % tab
->size
;
517 hash_entry
**table
= tab
->table
;
518 hash_entry
*p
= table
[k
];
521 if (p
->key
.len
== key
->len
522 && strncmp (p
->key
.ptr
, key
->ptr
, key
->len
) == 0)
532 are handled in a really simple recursive decent way. each bit of
533 the machine takes an index into an sb and a pointer to an exp_t,
534 modifies the *exp_t and returns the index of the first character
535 past the part of the expression parsed.
537 expression precedence:
548 /* make sure that the exp_t at term is constant, if not the give the op ERROR. */
552 checkconst (op
, term
)
556 if (term
->add_symbol
.len
557 || term
->sub_symbol
.len
)
559 ERROR ((stderr
, _("the %c operator cannot take non-absolute arguments.\n"), op
));
563 /* turn the number in string at idx into a number of base,
564 fill in ptr and return the index of the first character not in the
569 sb_strtol (idx
, string
, base
, ptr
)
576 idx
= sb_skip_white (idx
, string
);
578 while (idx
< string
->len
)
580 int ch
= string
->ptr
[idx
];
584 else if (ch
>= 'a' && ch
<= 'f')
586 else if (ch
>= 'A' && ch
<= 'F')
594 value
= value
* base
+ dig
;
602 level_0 (idx
, string
, lhs
)
607 lhs
->add_symbol
.len
= 0;
608 lhs
->add_symbol
.name
= 0;
610 lhs
->sub_symbol
.len
= 0;
611 lhs
->sub_symbol
.name
= 0;
613 idx
= sb_skip_white (idx
, string
);
617 if (isdigit ((unsigned char) string
->ptr
[idx
]))
619 idx
= sb_strtol (idx
, string
, 10, &lhs
->value
);
621 else if (ISFIRSTCHAR (string
->ptr
[idx
]))
624 lhs
->add_symbol
.name
= string
->ptr
+ idx
;
625 while (idx
< string
->len
&& ISNEXTCHAR (string
->ptr
[idx
]))
630 lhs
->add_symbol
.len
= len
;
632 else if (string
->ptr
[idx
] == '"')
636 ERROR ((stderr
, _("string where expression expected.\n")));
637 idx
= getstring (idx
, string
, &acc
);
642 ERROR ((stderr
, _("can't find primary in expression.\n")));
645 return sb_skip_white (idx
, string
);
651 level_1 (idx
, string
, lhs
)
656 idx
= sb_skip_white (idx
, string
);
658 switch (string
->ptr
[idx
])
661 idx
= level_1 (idx
+ 1, string
, lhs
);
664 idx
= level_1 (idx
+ 1, string
, lhs
);
665 checkconst ('~', lhs
);
666 lhs
->value
= ~lhs
->value
;
671 idx
= level_1 (idx
+ 1, string
, lhs
);
672 lhs
->value
= -lhs
->value
;
674 lhs
->add_symbol
= lhs
->sub_symbol
;
680 idx
= level_5 (sb_skip_white (idx
, string
), string
, lhs
);
681 if (string
->ptr
[idx
] != ')')
682 ERROR ((stderr
, _("misplaced closing parens.\n")));
687 idx
= level_0 (idx
, string
, lhs
);
690 return sb_skip_white (idx
, string
);
694 level_2 (idx
, string
, lhs
)
701 idx
= level_1 (idx
, string
, lhs
);
703 while (idx
< string
->len
&& (string
->ptr
[idx
] == '*'
704 || string
->ptr
[idx
] == '/'))
706 char op
= string
->ptr
[idx
++];
707 idx
= level_1 (idx
, string
, &rhs
);
711 checkconst ('*', lhs
);
712 checkconst ('*', &rhs
);
713 lhs
->value
*= rhs
.value
;
716 checkconst ('/', lhs
);
717 checkconst ('/', &rhs
);
719 ERROR ((stderr
, _("attempt to divide by zero.\n")));
721 lhs
->value
/= rhs
.value
;
725 return sb_skip_white (idx
, string
);
730 level_3 (idx
, string
, lhs
)
737 idx
= level_2 (idx
, string
, lhs
);
739 while (idx
< string
->len
740 && (string
->ptr
[idx
] == '+'
741 || string
->ptr
[idx
] == '-'))
743 char op
= string
->ptr
[idx
++];
744 idx
= level_2 (idx
, string
, &rhs
);
748 lhs
->value
+= rhs
.value
;
749 if (lhs
->add_symbol
.name
&& rhs
.add_symbol
.name
)
751 ERROR ((stderr
, _("can't add two relocatable expressions\n")));
753 /* change nn+symbol to symbol + nn */
754 if (rhs
.add_symbol
.name
)
756 lhs
->add_symbol
= rhs
.add_symbol
;
760 lhs
->value
-= rhs
.value
;
761 lhs
->sub_symbol
= rhs
.add_symbol
;
765 return sb_skip_white (idx
, string
);
769 level_4 (idx
, string
, lhs
)
776 idx
= level_3 (idx
, string
, lhs
);
778 while (idx
< string
->len
&&
779 string
->ptr
[idx
] == '&')
781 char op
= string
->ptr
[idx
++];
782 idx
= level_3 (idx
, string
, &rhs
);
786 checkconst ('&', lhs
);
787 checkconst ('&', &rhs
);
788 lhs
->value
&= rhs
.value
;
792 return sb_skip_white (idx
, string
);
796 level_5 (idx
, string
, lhs
)
803 idx
= level_4 (idx
, string
, lhs
);
805 while (idx
< string
->len
806 && (string
->ptr
[idx
] == '|' || string
->ptr
[idx
] == '~'))
808 char op
= string
->ptr
[idx
++];
809 idx
= level_4 (idx
, string
, &rhs
);
813 checkconst ('|', lhs
);
814 checkconst ('|', &rhs
);
815 lhs
->value
|= rhs
.value
;
818 checkconst ('~', lhs
);
819 checkconst ('~', &rhs
);
820 lhs
->value
^= rhs
.value
;
824 return sb_skip_white (idx
, string
);
828 /* parse the expression at offset idx into string, fill up res with
829 the result. return the index of the first char past the expression.
833 exp_parse (idx
, string
, res
)
838 return level_5 (sb_skip_white (idx
, string
), string
, res
);
842 /* turn the expression at exp into text and glue it onto the end of
846 exp_string (exp
, string
)
854 if (exp
->add_symbol
.len
)
856 sb_add_buffer (string
, exp
->add_symbol
.name
, exp
->add_symbol
.len
);
864 sb_add_char (string
, '+');
865 sprintf (buf
, "%d", exp
->value
);
866 sb_add_string (string
, buf
);
870 if (exp
->sub_symbol
.len
)
872 sb_add_char (string
, '-');
873 sb_add_buffer (string
, exp
->add_symbol
.name
, exp
->add_symbol
.len
);
879 sb_add_char (string
, '0');
883 /* parse the expression at offset idx into sb in, return the value in val.
884 if the expression is not constant, give ERROR emsg. returns the index
885 of the first character past the end of the expression. */
888 exp_get_abs (emsg
, idx
, in
, val
)
895 idx
= exp_parse (idx
, in
, &res
);
896 if (res
.add_symbol
.len
|| res
.sub_symbol
.len
)
897 ERROR ((stderr
, "%s", emsg
));
903 sb label
; /* current label parsed from line */
904 hash_table assign_hash_table
; /* hash table for all assigned variables */
905 hash_table keyword_hash_table
; /* hash table for keyword */
906 hash_table vars
; /* hash table for eq variables */
908 #define in_comment ';'
917 for (i
= 0; i
< out
->len
; i
++)
919 if (ISCOMMENTCHAR(s
[i
]))
928 /* push back character ch so that it can be read again. */
938 if (sp
->pushback_index
)
939 sp
->pushback_index
--;
941 sb_add_char (&sp
->pushback
, ch
);
944 /* push the sb ptr onto the include stack, with the given name, type and index. */
948 include_buf (name
, ptr
, type
, index
)
955 if (sp
- include_stack
>= MAX_INCLUDES
)
956 FATAL ((stderr
, _("unreasonable nesting.\n")));
958 sb_add_sb (&sp
->name
, name
);
961 sp
->pushback_index
= 0;
964 sb_new (&sp
->pushback
);
965 sb_add_sb (&sp
->pushback
, ptr
);
969 /* used in ERROR messages, print info on where the include stack is onto file. */
972 include_print_where_line (file
)
975 struct include_stack
*p
= include_stack
+ 1;
979 fprintf (file
, "%s:%d ", sb_name (&p
->name
), p
->linecount
- 1);
984 /* used in listings, print the line number onto file. */
986 include_print_line (file
)
990 struct include_stack
*p
= include_stack
+ 1;
992 n
= fprintf (file
, "%4d", p
->linecount
);
996 n
+= fprintf (file
, ".%d", p
->linecount
);
1001 fprintf (file
, " ");
1007 /* read a line from the top of the include stack into sb in. */
1018 putc (comment_char
, outfile
);
1019 if (print_line_number
)
1020 include_print_line (outfile
);
1034 WARNING ((stderr
, _("End of file not at start of line.\n")));
1036 putc ('\n', outfile
);
1055 /* continued line */
1058 putc (comment_char
, outfile
);
1059 putc ('+', outfile
);
1072 sb_add_char (in
, ch
);
1080 /* find a label from sb in and put it in out. */
1083 grab_label (in
, out
)
1089 if (ISFIRSTCHAR (in
->ptr
[i
]) || in
->ptr
[i
] == '\\')
1091 sb_add_char (out
, in
->ptr
[i
]);
1093 while ((ISNEXTCHAR (in
->ptr
[i
])
1094 || in
->ptr
[i
] == '\\'
1095 || in
->ptr
[i
] == '&')
1098 sb_add_char (out
, in
->ptr
[i
]);
1105 /* find all strange base stuff and turn into decimal. also
1106 find all the other numbers and convert them from the default radix */
1109 change_base (idx
, in
, out
)
1116 while (idx
< in
->len
)
1118 if (in
->ptr
[idx
] == '\\'
1119 && idx
+ 1 < in
->len
1120 && in
->ptr
[idx
+ 1] == '(')
1123 while (idx
< in
->len
1124 && in
->ptr
[idx
] != ')')
1126 sb_add_char (out
, in
->ptr
[idx
]);
1132 else if (idx
< in
->len
- 1 && in
->ptr
[idx
+ 1] == '\'' && ! mri
)
1136 switch (in
->ptr
[idx
])
1155 ERROR ((stderr
, _("Illegal base character %c.\n"), in
->ptr
[idx
]));
1160 idx
= sb_strtol (idx
+ 2, in
, base
, &value
);
1161 sprintf (buffer
, "%d", value
);
1162 sb_add_string (out
, buffer
);
1164 else if (ISFIRSTCHAR (in
->ptr
[idx
]))
1166 /* copy entire names through quickly */
1167 sb_add_char (out
, in
->ptr
[idx
]);
1169 while (idx
< in
->len
&& ISNEXTCHAR (in
->ptr
[idx
]))
1171 sb_add_char (out
, in
->ptr
[idx
]);
1175 else if (isdigit ((unsigned char) in
->ptr
[idx
]))
1178 /* all numbers must start with a digit, let's chew it and
1180 idx
= sb_strtol (idx
, in
, radix
, &value
);
1181 sprintf (buffer
, "%d", value
);
1182 sb_add_string (out
, buffer
);
1184 /* skip all undigsested letters */
1185 while (idx
< in
->len
&& ISNEXTCHAR (in
->ptr
[idx
]))
1187 sb_add_char (out
, in
->ptr
[idx
]);
1191 else if (in
->ptr
[idx
] == '"' || in
->ptr
[idx
] == '\'')
1193 char tchar
= in
->ptr
[idx
];
1194 /* copy entire names through quickly */
1195 sb_add_char (out
, in
->ptr
[idx
]);
1197 while (idx
< in
->len
&& in
->ptr
[idx
] != tchar
)
1199 sb_add_char (out
, in
->ptr
[idx
]);
1205 /* nothing special, just pass it through */
1206 sb_add_char (out
, in
->ptr
[idx
]);
1220 fprintf (outfile
, "%s\n", sb_name (in
));
1226 do_assign (again
, idx
, in
)
1231 /* stick label in symbol table with following value */
1236 idx
= exp_parse (idx
, in
, &e
);
1237 exp_string (&e
, &acc
);
1238 hash_add_to_string_table (&assign_hash_table
, &label
, &acc
, again
);
1243 /* .radix [b|q|d|h] */
1250 int idx
= sb_skip_white (0, ptr
);
1251 switch (ptr
->ptr
[idx
])
1270 ERROR ((stderr
, _("radix is %c must be one of b, q, d or h"), radix
));
1275 /* Parse off a .b, .w or .l */
1278 get_opsize (idx
, in
, size
)
1284 if (in
->ptr
[idx
] == '.')
1288 switch (in
->ptr
[idx
])
1306 ERROR ((stderr
, _("size must be one of b, w or l, is %c.\n"), in
->ptr
[idx
]));
1319 idx
= sb_skip_white (idx
, line
);
1321 && ISCOMMENTCHAR(line
->ptr
[idx
]))
1323 if (idx
>= line
->len
)
1328 /* .data [.b|.w|.l] <data>*
1329 or d[bwl] <data>* */
1332 do_data (idx
, in
, size
)
1338 char *opname
= ".yikes!";
1344 idx
= get_opsize (idx
, in
, &opsize
);
1363 fprintf (outfile
, "%s\t", opname
);
1365 idx
= sb_skip_white (idx
, in
);
1369 && in
->ptr
[idx
] == '"')
1372 idx
= getstring (idx
, in
, &acc
);
1373 for (i
= 0; i
< acc
.len
; i
++)
1376 fprintf(outfile
,",");
1377 fprintf (outfile
, "%d", acc
.ptr
[i
]);
1382 while (!eol (idx
, in
))
1385 idx
= exp_parse (idx
, in
, &e
);
1386 exp_string (&e
, &acc
);
1387 sb_add_char (&acc
, 0);
1388 fprintf (outfile
, "%s", acc
.ptr
);
1389 if (idx
< in
->len
&& in
->ptr
[idx
] == ',')
1391 fprintf (outfile
, ",");
1397 sb_print_at (outfile
, idx
, in
);
1398 fprintf (outfile
, "\n");
1401 /* .datab [.b|.w|.l] <repeat>,<fill> */
1412 idx
= get_opsize (idx
, in
, &opsize
);
1414 idx
= exp_get_abs (_("datab repeat must be constant.\n"), idx
, in
, &repeat
);
1415 idx
= sb_skip_comma (idx
, in
);
1416 idx
= exp_get_abs (_("datab data must be absolute.\n"), idx
, in
, &fill
);
1418 fprintf (outfile
, ".fill\t%d,%d,%d\n", repeat
, opsize
, fill
);
1428 int al
, have_fill
, fill
;
1430 idx
= exp_get_abs (_("align needs absolute expression.\n"), idx
, in
, &al
);
1431 idx
= sb_skip_white (idx
, in
);
1434 if (! eol (idx
, in
))
1436 idx
= sb_skip_comma (idx
, in
);
1437 idx
= exp_get_abs (_(".align needs absolute fill value.\n"), idx
, in
,
1442 fprintf (outfile
, ".align %d", al
);
1444 fprintf (outfile
, ",%d", fill
);
1445 fprintf (outfile
, "\n");
1448 /* .res[.b|.w|.l] <size> */
1451 do_res (idx
, in
, type
)
1459 idx
= get_opsize (idx
, in
, &size
);
1460 while (!eol(idx
, in
))
1462 idx
= sb_skip_white (idx
, in
);
1463 if (in
->ptr
[idx
] == ',')
1465 idx
= exp_get_abs (_("res needs absolute expression for fill count.\n"), idx
, in
, &count
);
1467 if (type
== 'c' || type
== 'z')
1470 fprintf (outfile
, ".space %d\n", count
* size
);
1481 fprintf (outfile
, ".global %s\n", sb_name (in
));
1484 /* .print [list] [nolist] */
1491 idx
= sb_skip_white (idx
, in
);
1492 while (idx
< in
->len
)
1494 if (strncasecmp (in
->ptr
+ idx
, "LIST", 4) == 0)
1496 fprintf (outfile
, ".list\n");
1499 else if (strncasecmp (in
->ptr
+ idx
, "NOLIST", 6) == 0)
1501 fprintf (outfile
, ".nolist\n");
1510 do_heading (idx
, in
)
1516 idx
= getstring (idx
, in
, &head
);
1517 fprintf (outfile
, ".title \"%s\"\n", sb_name (&head
));
1526 fprintf (outfile
, ".eject\n");
1529 /* .form [lin=<value>] [col=<value>] */
1537 idx
= sb_skip_white (idx
, in
);
1539 while (idx
< in
->len
)
1542 if (strncasecmp (in
->ptr
+ idx
, "LIN=", 4) == 0)
1545 idx
= exp_get_abs (_("form LIN= needs absolute expresssion.\n"), idx
, in
, &lines
);
1548 if (strncasecmp (in
->ptr
+ idx
, _("COL="), 4) == 0)
1551 idx
= exp_get_abs (_("form COL= needs absolute expresssion.\n"), idx
, in
, &columns
);
1556 fprintf (outfile
, ".psize %d,%d\n", lines
, columns
);
1561 /* Fetch string from the input stream,
1563 'Bxyx<whitespace> -> return 'Bxyza
1564 %<char> -> return string of decimal value of x
1565 "<string>" -> return string
1566 xyx<whitespace> -> return xyz
1569 get_any_string (idx
, in
, out
, expand
, pretend_quoted
)
1577 idx
= sb_skip_white (idx
, in
);
1581 if (in
->len
> 2 && in
->ptr
[idx
+1] == '\'' && ISBASE (in
->ptr
[idx
]))
1583 while (!ISSEP (in
->ptr
[idx
]))
1584 sb_add_char (out
, in
->ptr
[idx
++]);
1586 else if (in
->ptr
[idx
] == '%'
1592 /* Turns the next expression into a string */
1593 idx
= exp_get_abs (_("% operator needs absolute expression"),
1597 sprintf(buf
, "%d", val
);
1598 sb_add_string (out
, buf
);
1600 else if (in
->ptr
[idx
] == '"'
1601 || in
->ptr
[idx
] == '<'
1602 || (alternate
&& in
->ptr
[idx
] == '\''))
1604 if (alternate
&& expand
)
1606 /* Keep the quotes */
1607 sb_add_char (out
, '\"');
1609 idx
= getstring (idx
, in
, out
);
1610 sb_add_char (out
, '\"');
1614 idx
= getstring (idx
, in
, out
);
1619 while (idx
< in
->len
1620 && (in
->ptr
[idx
] == '"'
1621 || in
->ptr
[idx
] == '\''
1623 || !ISSEP (in
->ptr
[idx
])))
1625 if (in
->ptr
[idx
] == '"'
1626 || in
->ptr
[idx
] == '\'')
1628 char tchar
= in
->ptr
[idx
];
1629 sb_add_char (out
, in
->ptr
[idx
++]);
1630 while (idx
< in
->len
1631 && in
->ptr
[idx
] != tchar
)
1632 sb_add_char (out
, in
->ptr
[idx
++]);
1636 sb_add_char (out
, in
->ptr
[idx
++]);
1645 /* skip along sb in starting at idx, suck off whitespace a ( and more
1646 whitespace. return the idx of the next char */
1649 skip_openp (idx
, in
)
1653 idx
= sb_skip_white (idx
, in
);
1654 if (in
->ptr
[idx
] != '(')
1655 ERROR ((stderr
, _("misplaced ( .\n")));
1656 idx
= sb_skip_white (idx
+ 1, in
);
1660 /* skip along sb in starting at idx, suck off whitespace a ) and more
1661 whitespace. return the idx of the next char */
1664 skip_closep (idx
, in
)
1668 idx
= sb_skip_white (idx
, in
);
1669 if (in
->ptr
[idx
] != ')')
1670 ERROR ((stderr
, _("misplaced ).\n")));
1671 idx
= sb_skip_white (idx
+ 1, in
);
1678 dolen (idx
, in
, out
)
1687 sb_new (&stringout
);
1688 idx
= skip_openp (idx
, in
);
1689 idx
= get_and_process (idx
, in
, &stringout
);
1690 idx
= skip_closep (idx
, in
);
1691 sprintf (buffer
, "%d", stringout
.len
);
1692 sb_add_string (out
, buffer
);
1694 sb_kill (&stringout
);
1703 doinstr (idx
, in
, out
)
1717 idx
= skip_openp (idx
, in
);
1718 idx
= get_and_process (idx
, in
, &string
);
1719 idx
= sb_skip_comma (idx
, in
);
1720 idx
= get_and_process (idx
, in
, &search
);
1721 idx
= sb_skip_comma (idx
, in
);
1722 if (isdigit ((unsigned char) in
->ptr
[idx
]))
1724 idx
= exp_get_abs (_(".instr needs absolute expresson.\n"), idx
, in
, &start
);
1730 idx
= skip_closep (idx
, in
);
1732 for (i
= start
; i
< string
.len
; i
++)
1734 if (strncmp (string
.ptr
+ i
, search
.ptr
, search
.len
) == 0)
1740 sprintf (buffer
, "%d", res
);
1741 sb_add_string (out
, buffer
);
1749 dosubstr (idx
, in
, out
)
1759 idx
= skip_openp (idx
, in
);
1760 idx
= get_and_process (idx
, in
, &string
);
1761 idx
= sb_skip_comma (idx
, in
);
1762 idx
= exp_get_abs (_("need absolute position.\n"), idx
, in
, &pos
);
1763 idx
= sb_skip_comma (idx
, in
);
1764 idx
= exp_get_abs (_("need absolute length.\n"), idx
, in
, &len
);
1765 idx
= skip_closep (idx
, in
);
1768 if (len
< 0 || pos
< 0 ||
1770 || pos
+ len
> string
.len
)
1772 sb_add_string (out
, " ");
1776 sb_add_char (out
, '"');
1779 sb_add_char (out
, string
.ptr
[pos
++]);
1782 sb_add_char (out
, '"');
1788 /* scan line, change tokens in the hash table to their replacements */
1790 process_assigns (idx
, in
, buf
)
1795 while (idx
< in
->len
)
1798 if (in
->ptr
[idx
] == '\\'
1799 && idx
+ 1 < in
->len
1800 && in
->ptr
[idx
+ 1] == '(')
1804 sb_add_char (buf
, in
->ptr
[idx
]);
1807 while (idx
< in
->len
&& in
->ptr
[idx
- 1] != ')');
1809 else if (in
->ptr
[idx
] == '\\'
1810 && idx
+ 1 < in
->len
1811 && in
->ptr
[idx
+ 1] == '&')
1813 idx
= condass_lookup_name (in
, idx
+ 2, buf
, 1);
1815 else if (in
->ptr
[idx
] == '\\'
1816 && idx
+ 1 < in
->len
1817 && in
->ptr
[idx
+ 1] == '$')
1819 idx
= condass_lookup_name (in
, idx
+ 2, buf
, 0);
1821 else if (idx
+ 3 < in
->len
1822 && in
->ptr
[idx
] == '.'
1823 && toupper ((unsigned char) in
->ptr
[idx
+ 1]) == 'L'
1824 && toupper ((unsigned char) in
->ptr
[idx
+ 2]) == 'E'
1825 && toupper ((unsigned char) in
->ptr
[idx
+ 3]) == 'N')
1826 idx
= dolen (idx
+ 4, in
, buf
);
1827 else if (idx
+ 6 < in
->len
1828 && in
->ptr
[idx
] == '.'
1829 && toupper ((unsigned char) in
->ptr
[idx
+ 1]) == 'I'
1830 && toupper ((unsigned char) in
->ptr
[idx
+ 2]) == 'N'
1831 && toupper ((unsigned char) in
->ptr
[idx
+ 3]) == 'S'
1832 && toupper ((unsigned char) in
->ptr
[idx
+ 4]) == 'T'
1833 && toupper ((unsigned char) in
->ptr
[idx
+ 5]) == 'R')
1834 idx
= doinstr (idx
+ 6, in
, buf
);
1835 else if (idx
+ 7 < in
->len
1836 && in
->ptr
[idx
] == '.'
1837 && toupper ((unsigned char) in
->ptr
[idx
+ 1]) == 'S'
1838 && toupper ((unsigned char) in
->ptr
[idx
+ 2]) == 'U'
1839 && toupper ((unsigned char) in
->ptr
[idx
+ 3]) == 'B'
1840 && toupper ((unsigned char) in
->ptr
[idx
+ 4]) == 'S'
1841 && toupper ((unsigned char) in
->ptr
[idx
+ 5]) == 'T'
1842 && toupper ((unsigned char) in
->ptr
[idx
+ 6]) == 'R')
1843 idx
= dosubstr (idx
+ 7, in
, buf
);
1844 else if (ISFIRSTCHAR (in
->ptr
[idx
]))
1846 /* may be a simple name subsitution, see if we have a word */
1849 while (cur
< in
->len
1850 && (ISNEXTCHAR (in
->ptr
[cur
])))
1854 sb_add_buffer (&acc
, in
->ptr
+ idx
, cur
- idx
);
1855 ptr
= hash_lookup (&assign_hash_table
, &acc
);
1858 /* Found a definition for it */
1859 sb_add_sb (buf
, &ptr
->value
.s
);
1863 /* No definition, just copy the word */
1864 sb_add_sb (buf
, &acc
);
1871 sb_add_char (buf
, in
->ptr
[idx
++]);
1877 get_and_process (idx
, in
, out
)
1884 idx
= get_any_string (idx
, in
, &t
, 1, 0);
1885 process_assigns (0, &t
, out
);
1906 more
= get_line (&line
);
1909 /* Find any label and pseudo op that we're intested in */
1914 fprintf (outfile
, "\n");
1917 && (line
.ptr
[0] == '*'
1918 || line
.ptr
[0] == '!'))
1920 /* MRI line comment. */
1921 fprintf (outfile
, "%s", sb_name (&line
));
1925 l
= grab_label (&line
, &label_in
);
1928 if (line
.ptr
[l
] == ':')
1930 while (ISWHITE (line
.ptr
[l
]) && l
< line
.len
)
1937 /* Munge the label, unless this is EQU or ASSIGN. */
1940 && (line
.ptr
[l
] == '.' || alternate
|| mri
))
1944 if (line
.ptr
[lx
] == '.')
1946 if (lx
+ 3 <= line
.len
1947 && strncasecmp ("EQU", line
.ptr
+ lx
, 3) == 0
1948 && (lx
+ 3 == line
.len
1949 || ! ISFIRSTCHAR (line
.ptr
[lx
+ 3])))
1951 else if (lx
+ 6 <= line
.len
1952 && strncasecmp ("ASSIGN", line
.ptr
+ lx
, 6) == 0
1953 && (lx
+ 6 == line
.len
1954 || ! ISFIRSTCHAR (line
.ptr
[lx
+ 6])))
1959 process_assigns (0, &label_in
, &label
);
1961 sb_add_sb (&label
, &label_in
);
1966 if (process_pseudo_op (l
, &line
, &acc
))
1972 else if (condass_on ())
1974 if (macro_op (l
, &line
))
1984 fprintf (outfile
, "%s:\t", sb_name (&label
));
1987 fprintf (outfile
, "\t");
1989 process_assigns (l
, &line
, &t1
);
1991 change_base (0, &t1
, &t2
);
1992 fprintf (outfile
, "%s\n", sb_name (&t2
));
1998 /* Only a label on this line */
1999 if (label
.len
&& condass_on())
2001 fprintf (outfile
, "%s:\n", sb_name (&label
));
2009 more
= get_line (&line
);
2012 if (!had_end
&& !mri
)
2013 WARNING ((stderr
, _("END missing from end of file.\n")));
2021 free_old_entry (ptr
)
2026 if (ptr
->type
== hash_string
)
2027 sb_kill(&ptr
->value
.s
);
2031 /* name: .ASSIGNA <value> */
2034 do_assigna (idx
, in
)
2042 process_assigns (idx
, in
, &tmp
);
2043 idx
= exp_get_abs (_(".ASSIGNA needs constant expression argument.\n"), 0, &tmp
, &val
);
2047 ERROR ((stderr
, _(".ASSIGNA without label.\n")));
2051 hash_entry
*ptr
= hash_create (&vars
, &label
);
2052 free_old_entry (ptr
);
2053 ptr
->type
= hash_integer
;
2059 /* name: .ASSIGNC <string> */
2062 do_assignc (idx
, in
)
2068 idx
= getstring (idx
, in
, &acc
);
2072 ERROR ((stderr
, _(".ASSIGNS without label.\n")));
2076 hash_entry
*ptr
= hash_create (&vars
, &label
);
2077 free_old_entry (ptr
);
2078 ptr
->type
= hash_string
;
2079 sb_new (&ptr
->value
.s
);
2080 sb_add_sb (&ptr
->value
.s
, &acc
);
2086 /* name: .REG (reg) */
2093 /* remove reg stuff from inside parens */
2096 idx
= skip_openp (idx
, in
);
2098 idx
= sb_skip_white (idx
, in
);
2100 while (idx
< in
->len
2103 : in
->ptr
[idx
] != ')'))
2105 sb_add_char (&what
, in
->ptr
[idx
]);
2108 hash_add_to_string_table (&assign_hash_table
, &label
, &what
, 1);
2114 condass_lookup_name (inbuf
, idx
, out
, warn
)
2122 sb_new (&condass_acc
);
2124 while (idx
< inbuf
->len
2125 && ISNEXTCHAR (inbuf
->ptr
[idx
]))
2127 sb_add_char (&condass_acc
, inbuf
->ptr
[idx
++]);
2130 if (inbuf
->ptr
[idx
] == '\'')
2132 ptr
= hash_lookup (&vars
, &condass_acc
);
2139 WARNING ((stderr
, _("Can't find preprocessor variable %s.\n"), sb_name (&condass_acc
)));
2143 sb_add_string (out
, "0");
2148 if (ptr
->type
== hash_integer
)
2151 sprintf (buffer
, "%d", ptr
->value
.i
);
2152 sb_add_string (out
, buffer
);
2156 sb_add_sb (out
, &ptr
->value
.s
);
2159 sb_kill (&condass_acc
);
2172 whatcond (idx
, in
, val
)
2179 idx
= sb_skip_white (idx
, in
);
2181 if (idx
+ 1 < in
->len
)
2187 a
= toupper ((unsigned char) p
[0]);
2188 b
= toupper ((unsigned char) p
[1]);
2189 if (a
== 'E' && b
== 'Q')
2191 else if (a
== 'N' && b
== 'E')
2193 else if (a
== 'L' && b
== 'T')
2195 else if (a
== 'L' && b
== 'E')
2197 else if (a
== 'G' && b
== 'T')
2199 else if (a
== 'G' && b
== 'E')
2204 ERROR ((stderr
, _("Comparison operator must be one of EQ, NE, LT, LE, GT or GE.\n")));
2207 idx
= sb_skip_white (idx
+ 2, in
);
2224 idx
= sb_skip_white (idx
, in
);
2226 if (in
->ptr
[idx
] == '"')
2230 /* This is a string comparision */
2231 idx
= getstring (idx
, in
, &acc_a
);
2232 idx
= whatcond (idx
, in
, &cond
);
2233 idx
= getstring (idx
, in
, &acc_b
);
2234 same
= acc_a
.len
== acc_b
.len
&& (strncmp (acc_a
.ptr
, acc_b
.ptr
, acc_a
.len
) == 0);
2236 if (cond
!= EQ
&& cond
!= NE
)
2238 ERROR ((stderr
, _("Comparison operator for strings must be EQ or NE\n")));
2242 res
= (cond
!= EQ
) ^ same
;
2245 /* This is a numeric expression */
2250 idx
= exp_get_abs (_("Conditional operator must have absolute operands.\n"), idx
, in
, &vala
);
2251 idx
= whatcond (idx
, in
, &cond
);
2252 idx
= sb_skip_white (idx
, in
);
2253 if (in
->ptr
[idx
] == '"')
2255 WARNING ((stderr
, _("String compared against expression.\n")));
2260 idx
= exp_get_abs (_("Conditional operator must have absolute operands.\n"), idx
, in
, &valb
);
2303 if (ifi
>= IFNESTING
)
2305 FATAL ((stderr
, _("AIF nesting unreasonable.\n")));
2308 ifstack
[ifi
].on
= ifstack
[ifi
-1].on
? istrue (idx
, in
) : 0;
2309 ifstack
[ifi
].hadelse
= 0;
2317 ifstack
[ifi
].on
= ifstack
[ifi
-1].on
? !ifstack
[ifi
].on
: 0;
2318 if (ifstack
[ifi
].hadelse
)
2320 ERROR ((stderr
, _("Multiple AELSEs in AIF.\n")));
2322 ifstack
[ifi
].hadelse
= 1;
2336 ERROR ((stderr
, _("AENDI without AIF.\n")));
2343 return ifstack
[ifi
].on
;
2346 /* MRI IFEQ, IFNE, IFLT, IFLE, IFGE, IFGT. */
2349 do_if (idx
, in
, cond
)
2357 if (ifi
>= IFNESTING
)
2359 FATAL ((stderr
, _("IF nesting unreasonable.\n")));
2362 idx
= exp_get_abs (_("Conditional operator must have absolute operands.\n"),
2367 case EQ
: res
= val
== 0; break;
2368 case NE
: res
= val
!= 0; break;
2369 case LT
: res
= val
< 0; break;
2370 case LE
: res
= val
<= 0; break;
2371 case GE
: res
= val
>= 0; break;
2372 case GT
: res
= val
> 0; break;
2376 ifstack
[ifi
].on
= ifstack
[ifi
-1].on
? res
: 0;
2377 ifstack
[ifi
].hadelse
= 0;
2380 /* Get a string for the MRI IFC or IFNC pseudo-ops. */
2383 get_mri_string (idx
, in
, val
, terminator
)
2389 idx
= sb_skip_white (idx
, in
);
2392 && in
->ptr
[idx
] == '\'')
2394 sb_add_char (val
, '\'');
2395 for (++idx
; idx
< in
->len
; ++idx
)
2397 sb_add_char (val
, in
->ptr
[idx
]);
2398 if (in
->ptr
[idx
] == '\'')
2402 || in
->ptr
[idx
] != '\'')
2406 idx
= sb_skip_white (idx
, in
);
2412 while (idx
< in
->len
2413 && in
->ptr
[idx
] != terminator
)
2415 sb_add_char (val
, in
->ptr
[idx
]);
2419 while (i
>= 0 && ISWHITE (val
->ptr
[i
]))
2427 /* MRI IFC, IFNC. */
2430 do_ifc (idx
, in
, ifnc
)
2439 if (ifi
>= IFNESTING
)
2441 FATAL ((stderr
, _("IF nesting unreasonable.\n")));
2447 idx
= get_mri_string (idx
, in
, &first
, ',');
2449 if (idx
>= in
->len
|| in
->ptr
[idx
] != ',')
2451 ERROR ((stderr
, _("Bad format for IF or IFNC.\n")));
2455 idx
= get_mri_string (idx
+ 1, in
, &second
, ';');
2457 res
= (first
.len
== second
.len
2458 && strncmp (first
.ptr
, second
.ptr
, first
.len
) == 0);
2462 ifstack
[ifi
].on
= ifstack
[ifi
-1].on
? res
: 0;
2463 ifstack
[ifi
].hadelse
= 0;
2471 ERROR ((stderr
, _("AENDR without a AREPEAT.\n")));
2473 ERROR ((stderr
, _("ENDR without a REPT.\n")));
2484 int line
= linecount ();
2492 process_assigns (idx
, in
, &exp
);
2493 doit
= istrue (0, &exp
);
2495 if (! buffer_and_nest ("AWHILE", "AENDW", &sub
, get_line
))
2496 FATAL ((stderr
, _("AWHILE without a AENDW at %d.\n"), line
- 1));
2511 int index
= include_next_index ();
2515 sb_add_sb (©
, &sub
);
2516 sb_add_sb (©
, in
);
2517 sb_add_string (©
, "\n");
2518 sb_add_sb (©
, &sub
);
2519 sb_add_string (©
, "\t.AENDW\n");
2520 /* Push another WHILE */
2521 include_buf (&exp
, ©
, include_while
, index
);
2534 ERROR ((stderr
, _("AENDW without a AENDW.\n")));
2540 Pop things off the include stack until the type and index changes */
2545 include_type type
= sp
->type
;
2546 if (type
== include_repeat
2547 || type
== include_while
2548 || type
== include_macro
)
2550 int index
= sp
->index
;
2552 while (sp
->index
== index
2553 && sp
->type
== type
)
2563 do_arepeat (idx
, in
)
2567 int line
= linecount ();
2568 sb exp
; /* buffer with expression in it */
2569 sb copy
; /* expanded repeat block */
2570 sb sub
; /* contents of AREPEAT */
2578 process_assigns (idx
, in
, &exp
);
2579 idx
= exp_get_abs (_("AREPEAT must have absolute operand.\n"), 0, &exp
, &rc
);
2581 ret
= buffer_and_nest ("AREPEAT", "AENDR", &sub
, get_line
);
2583 ret
= buffer_and_nest ("REPT", "ENDR", &sub
, get_line
);
2585 FATAL ((stderr
, _("AREPEAT without a AENDR at %d.\n"), line
- 1));
2588 /* Push back the text following the repeat, and another repeat block
2599 int index
= include_next_index ();
2600 sb_add_sb (©
, &sub
);
2604 sprintf (buffer
, "\t.AREPEAT %d\n", rc
- 1);
2606 sprintf (buffer
, "\tREPT %d\n", rc
- 1);
2607 sb_add_string (©
, buffer
);
2608 sb_add_sb (©
, &sub
);
2610 sb_add_string (©
, " .AENDR\n");
2612 sb_add_string (©
, " ENDR\n");
2615 include_buf (&exp
, ©
, include_repeat
, index
);
2627 ERROR ((stderr
, _(".ENDM without a matching .MACRO.\n")));
2630 /* MRI IRP pseudo-op. */
2633 do_irp (idx
, in
, irpc
)
2643 err
= expand_irp (irpc
, idx
, in
, &out
, get_line
, comment_char
);
2645 ERROR ((stderr
, "%s\n", err
));
2647 fprintf (outfile
, "%s", sb_terminate (&out
));
2652 /* MACRO PROCESSING */
2654 /* Parse off LOCAL n1, n2,... Invent a label name for it */
2657 do_local (idx
, line
)
2658 int idx ATTRIBUTE_UNUSED
;
2659 sb
*line ATTRIBUTE_UNUSED
;
2661 ERROR ((stderr
, _("LOCAL outside of MACRO")));
2670 int line
= linecount ();
2672 err
= define_macro (idx
, in
, &label
, get_line
, (const char **) NULL
);
2674 ERROR ((stderr
, _("macro at line %d: %s\n"), line
- 1, err
));
2686 if (! macro_defined
)
2690 if (! check_macro (in
->ptr
+ idx
, &out
, comment_char
, &err
))
2694 ERROR ((stderr
, "%s\n", err
));
2697 sb_add_string (&name
, _("macro expansion"));
2699 include_buf (&name
, &out
, include_macro
, include_next_index ());
2707 /* STRING HANDLING */
2710 getstring (idx
, in
, acc
)
2715 idx
= sb_skip_white (idx
, in
);
2717 while (idx
< in
->len
2718 && (in
->ptr
[idx
] == '"'
2719 || in
->ptr
[idx
] == '<'
2720 || (in
->ptr
[idx
] == '\'' && alternate
)))
2722 if (in
->ptr
[idx
] == '<')
2724 if (alternate
|| mri
)
2728 while ((in
->ptr
[idx
] != '>' || nest
)
2731 if (in
->ptr
[idx
] == '!')
2734 sb_add_char (acc
, in
->ptr
[idx
++]);
2737 if (in
->ptr
[idx
] == '>')
2739 if (in
->ptr
[idx
] == '<')
2741 sb_add_char (acc
, in
->ptr
[idx
++]);
2749 idx
= exp_get_abs (_("Character code in string must be absolute expression.\n"),
2751 sb_add_char (acc
, code
);
2753 if (in
->ptr
[idx
] != '>')
2754 ERROR ((stderr
, _("Missing > for character code.\n")));
2758 else if (in
->ptr
[idx
] == '"' || in
->ptr
[idx
] == '\'')
2760 char tchar
= in
->ptr
[idx
];
2762 while (idx
< in
->len
)
2764 if (alternate
&& in
->ptr
[idx
] == '!')
2767 sb_add_char (acc
, in
->ptr
[idx
++]);
2770 if (in
->ptr
[idx
] == tchar
)
2773 if (idx
>= in
->len
|| in
->ptr
[idx
] != tchar
)
2776 sb_add_char (acc
, in
->ptr
[idx
]);
2786 /* .SDATA[C|Z] <string> */
2790 do_sdata (idx
, in
, type
)
2799 fprintf (outfile
, ".byte\t");
2801 while (!eol (idx
, in
))
2805 idx
= sb_skip_white (idx
, in
);
2806 while (!eol (idx
, in
))
2808 pidx
= idx
= get_any_string (idx
, in
, &acc
, 0, 1);
2813 ERROR ((stderr
, _("string for SDATAC longer than 255 characters (%d).\n"), acc
.len
));
2815 fprintf (outfile
, "%d", acc
.len
);
2819 for (i
= 0; i
< acc
.len
; i
++)
2823 fprintf (outfile
, ",");
2825 fprintf (outfile
, "%d", acc
.ptr
[i
]);
2832 fprintf (outfile
, ",");
2833 fprintf (outfile
, "0");
2835 idx
= sb_skip_comma (idx
, in
);
2836 if (idx
== pidx
) break;
2838 if (!alternate
&& in
->ptr
[idx
] != ',' && idx
!= in
->len
)
2840 fprintf (outfile
, "\n");
2841 ERROR ((stderr
, _("illegal character in SDATA line (0x%x).\n"), in
->ptr
[idx
]));
2847 fprintf (outfile
, "\n");
2850 /* .SDATAB <count> <string> */
2862 idx
= exp_get_abs (_("Must have absolute SDATAB repeat count.\n"), idx
, in
, &repeat
);
2865 ERROR ((stderr
, _("Must have positive SDATAB repeat count (%d).\n"), repeat
));
2869 idx
= sb_skip_comma (idx
, in
);
2870 idx
= getstring (idx
, in
, &acc
);
2872 for (i
= 0; i
< repeat
; i
++)
2875 fprintf (outfile
, "\t");
2876 fprintf (outfile
, ".byte\t");
2877 sb_print (outfile
, &acc
);
2878 fprintf (outfile
, "\n");
2888 FILE *newone
= fopen (name
, "r");
2892 if (isp
== MAX_INCLUDES
)
2893 FATAL ((stderr
, _("Unreasonable include depth (%ld).\n"), (long) isp
));
2896 sp
->handle
= newone
;
2899 sb_add_string (&sp
->name
, name
);
2902 sp
->pushback_index
= 0;
2903 sp
->type
= include_file
;
2905 sb_new (&sp
->pushback
);
2910 do_include (idx
, in
)
2916 include_path
*includes
;
2922 idx
= getstring (idx
, in
, &t
);
2925 idx
= sb_skip_white (idx
, in
);
2926 while (idx
< in
->len
&& ! ISWHITE (in
->ptr
[idx
]))
2928 sb_add_char (&t
, in
->ptr
[idx
]);
2933 for (includes
= paths_head
; includes
; includes
= includes
->next
)
2936 sb_add_sb (&cat
, &includes
->path
);
2937 sb_add_char (&cat
, '/');
2938 sb_add_sb (&cat
, &t
);
2939 if (new_file (sb_name (&cat
)))
2946 if (! new_file (sb_name (&t
)))
2947 FATAL ((stderr
, _("Can't open include file `%s'.\n"), sb_name (&t
)));
2956 if (sp
!= include_stack
)
2959 fclose (sp
->handle
);
2964 /* Get the next character from the include stack. If there's anything
2965 in the pushback buffer, take that first. If we're at eof, pop from
2966 the stack and try again. Keep the linecount up to date. */
2973 if (sp
->pushback
.len
!= sp
->pushback_index
)
2975 r
= (char) (sp
->pushback
.ptr
[sp
->pushback_index
++]);
2976 /* When they've all gone, reset the pointer */
2977 if (sp
->pushback_index
== sp
->pushback
.len
)
2979 sp
->pushback
.len
= 0;
2980 sp
->pushback_index
= 0;
2983 else if (sp
->handle
)
2985 r
= getc (sp
->handle
);
2990 if (r
== EOF
&& isp
)
2994 while (r
== EOF
&& isp
)
3012 return sp
->linecount
;
3016 include_next_index ()
3020 && index
> MAX_REASONABLE
)
3021 FATAL ((stderr
, _("Unreasonable expansion (-u turns off check).\n")));
3026 /* Initialize the chartype vector. */
3032 for (x
= 0; x
< 256; x
++)
3034 if (isalpha (x
) || x
== '_' || x
== '$')
3035 chartype
[x
] |= FIRSTBIT
;
3037 if (mri
&& x
== '.')
3038 chartype
[x
] |= FIRSTBIT
;
3040 if (isdigit (x
) || isalpha (x
) || x
== '_' || x
== '$')
3041 chartype
[x
] |= NEXTBIT
;
3043 if (x
== ' ' || x
== '\t' || x
== ',' || x
== '"' || x
== ';'
3044 || x
== '"' || x
== '<' || x
== '>' || x
== ')' || x
== '(')
3045 chartype
[x
] |= SEPBIT
;
3047 if (x
== 'b' || x
== 'B'
3048 || x
== 'q' || x
== 'Q'
3049 || x
== 'h' || x
== 'H'
3050 || x
== 'd' || x
== 'D')
3051 chartype
[x
] |= BASEBIT
;
3053 if (x
== ' ' || x
== '\t')
3054 chartype
[x
] |= WHITEBIT
;
3056 if (x
== comment_char
)
3057 chartype
[x
] |= COMMENTBIT
;
3063 /* What to do with all the keywords */
3064 #define PROCESS 0x1000 /* Run substitution over the line */
3065 #define LAB 0x2000 /* Spit out the label */
3067 #define K_EQU (PROCESS|1)
3068 #define K_ASSIGN (PROCESS|2)
3069 #define K_REG (PROCESS|3)
3070 #define K_ORG (PROCESS|4)
3071 #define K_RADIX (PROCESS|5)
3072 #define K_DATA (LAB|PROCESS|6)
3073 #define K_DATAB (LAB|PROCESS|7)
3074 #define K_SDATA (LAB|PROCESS|8)
3075 #define K_SDATAB (LAB|PROCESS|9)
3076 #define K_SDATAC (LAB|PROCESS|10)
3077 #define K_SDATAZ (LAB|PROCESS|11)
3078 #define K_RES (LAB|PROCESS|12)
3079 #define K_SRES (LAB|PROCESS|13)
3080 #define K_SRESC (LAB|PROCESS|14)
3081 #define K_SRESZ (LAB|PROCESS|15)
3082 #define K_EXPORT (LAB|PROCESS|16)
3083 #define K_GLOBAL (LAB|PROCESS|17)
3084 #define K_PRINT (LAB|PROCESS|19)
3085 #define K_FORM (LAB|PROCESS|20)
3086 #define K_HEADING (LAB|PROCESS|21)
3087 #define K_PAGE (LAB|PROCESS|22)
3088 #define K_IMPORT (LAB|PROCESS|23)
3089 #define K_PROGRAM (LAB|PROCESS|24)
3090 #define K_END (PROCESS|25)
3091 #define K_INCLUDE (PROCESS|26)
3092 #define K_IGNORED (PROCESS|27)
3093 #define K_ASSIGNA (PROCESS|28)
3094 #define K_ASSIGNC (29)
3095 #define K_AIF (PROCESS|30)
3096 #define K_AELSE (PROCESS|31)
3097 #define K_AENDI (PROCESS|32)
3098 #define K_AREPEAT (PROCESS|33)
3099 #define K_AENDR (PROCESS|34)
3100 #define K_AWHILE (35)
3101 #define K_AENDW (PROCESS|36)
3102 #define K_EXITM (37)
3103 #define K_MACRO (PROCESS|38)
3105 #define K_ALIGN (PROCESS|LAB|40)
3106 #define K_ALTERNATE (41)
3107 #define K_DB (LAB|PROCESS|42)
3108 #define K_DW (LAB|PROCESS|43)
3109 #define K_DL (LAB|PROCESS|44)
3110 #define K_LOCAL (45)
3111 #define K_IFEQ (PROCESS|46)
3112 #define K_IFNE (PROCESS|47)
3113 #define K_IFLT (PROCESS|48)
3114 #define K_IFLE (PROCESS|49)
3115 #define K_IFGE (PROCESS|50)
3116 #define K_IFGT (PROCESS|51)
3117 #define K_IFC (PROCESS|52)
3118 #define K_IFNC (PROCESS|53)
3119 #define K_IRP (PROCESS|54)
3120 #define K_IRPC (PROCESS|55)
3130 static struct keyword kinfo
[] =
3132 { "EQU", K_EQU
, 0 },
3133 { "ALTERNATE", K_ALTERNATE
, 0 },
3134 { "ASSIGN", K_ASSIGN
, 0 },
3135 { "REG", K_REG
, 0 },
3136 { "ORG", K_ORG
, 0 },
3137 { "RADIX", K_RADIX
, 0 },
3138 { "DATA", K_DATA
, 0 },
3142 { "DATAB", K_DATAB
, 0 },
3143 { "SDATA", K_SDATA
, 0 },
3144 { "SDATAB", K_SDATAB
, 0 },
3145 { "SDATAZ", K_SDATAZ
, 0 },
3146 { "SDATAC", K_SDATAC
, 0 },
3147 { "RES", K_RES
, 0 },
3148 { "SRES", K_SRES
, 0 },
3149 { "SRESC", K_SRESC
, 0 },
3150 { "SRESZ", K_SRESZ
, 0 },
3151 { "EXPORT", K_EXPORT
, 0 },
3152 { "GLOBAL", K_GLOBAL
, 0 },
3153 { "PRINT", K_PRINT
, 0 },
3154 { "FORM", K_FORM
, 0 },
3155 { "HEADING", K_HEADING
, 0 },
3156 { "PAGE", K_PAGE
, 0 },
3157 { "PROGRAM", K_IGNORED
, 0 },
3158 { "END", K_END
, 0 },
3159 { "INCLUDE", K_INCLUDE
, 0 },
3160 { "ASSIGNA", K_ASSIGNA
, 0 },
3161 { "ASSIGNC", K_ASSIGNC
, 0 },
3162 { "AIF", K_AIF
, 0 },
3163 { "AELSE", K_AELSE
, 0 },
3164 { "AENDI", K_AENDI
, 0 },
3165 { "AREPEAT", K_AREPEAT
, 0 },
3166 { "AENDR", K_AENDR
, 0 },
3167 { "EXITM", K_EXITM
, 0 },
3168 { "MACRO", K_MACRO
, 0 },
3169 { "ENDM", K_ENDM
, 0 },
3170 { "AWHILE", K_AWHILE
, 0 },
3171 { "ALIGN", K_ALIGN
, 0 },
3172 { "AENDW", K_AENDW
, 0 },
3173 { "ALTERNATE", K_ALTERNATE
, 0 },
3174 { "LOCAL", K_LOCAL
, 0 },
3178 /* Although the conditional operators are handled by gas, we need to
3179 handle them here as well, in case they are used in a recursive
3180 macro to end the recursion. */
3182 static struct keyword mrikinfo
[] =
3184 { "IFEQ", K_IFEQ
, 0 },
3185 { "IFNE", K_IFNE
, 0 },
3186 { "IFLT", K_IFLT
, 0 },
3187 { "IFLE", K_IFLE
, 0 },
3188 { "IFGE", K_IFGE
, 0 },
3189 { "IFGT", K_IFGT
, 0 },
3190 { "IFC", K_IFC
, 0 },
3191 { "IFNC", K_IFNC
, 0 },
3192 { "ELSEC", K_AELSE
, 0 },
3193 { "ENDC", K_AENDI
, 0 },
3194 { "MEXIT", K_EXITM
, 0 },
3195 { "REPT", K_AREPEAT
, 0 },
3196 { "IRP", K_IRP
, 0 },
3197 { "IRPC", K_IRPC
, 0 },
3198 { "ENDR", K_AENDR
, 0 },
3202 /* Look for a pseudo op on the line. If one's there then call
3206 process_pseudo_op (idx
, line
, acc
)
3213 if (line
->ptr
[idx
] == '.' || alternate
|| mri
)
3215 /* Scan forward and find pseudo name */
3221 if (line
->ptr
[idx
] == '.')
3223 in
= line
->ptr
+ idx
;
3228 while (idx
< line
->len
&& *e
&& ISFIRSTCHAR (*e
))
3230 sb_add_char (acc
, *e
);
3235 ptr
= hash_lookup (&keyword_hash_table
, acc
);
3240 /* This one causes lots of pain when trying to preprocess
3242 WARNING ((stderr
, _("Unrecognised pseudo op `%s'.\n"), sb_name (acc
)));
3246 if (ptr
->value
.i
& LAB
)
3247 { /* output the label */
3250 fprintf (outfile
, "%s:\t", sb_name (&label
));
3253 fprintf (outfile
, "\t");
3256 if (mri
&& ptr
->value
.i
== K_END
)
3261 sb_add_buffer (&t
, line
->ptr
+ oidx
, idx
- oidx
);
3262 fprintf (outfile
, "\t%s", sb_name (&t
));
3266 if (ptr
->value
.i
& PROCESS
)
3268 /* Polish the rest of the line before handling the pseudo op */
3270 strip_comments(line
);
3273 process_assigns (idx
, line
, acc
);
3275 change_base (0, acc
, line
);
3280 switch (ptr
->value
.i
)
3296 switch (ptr
->value
.i
)
3300 macro_init (1, mri
, 0, exp_get_abs
);
3309 ERROR ((stderr
, _("ORG command not allowed.\n")));
3315 do_data (idx
, line
, 1);
3318 do_data (idx
, line
, 2);
3321 do_data (idx
, line
, 4);
3324 do_data (idx
, line
, 0);
3327 do_datab (idx
, line
);
3330 do_sdata (idx
, line
, 0);
3333 do_sdatab (idx
, line
);
3336 do_sdata (idx
, line
, 'c');
3339 do_sdata (idx
, line
, 'z');
3342 do_assign (0, 0, line
);
3348 do_arepeat (idx
, line
);
3354 do_awhile (idx
, line
);
3360 do_assign (1, idx
, line
);
3363 do_align (idx
, line
);
3366 do_res (idx
, line
, 0);
3369 do_res (idx
, line
, 's');
3372 do_include (idx
, line
);
3375 do_local (idx
, line
);
3378 do_macro (idx
, line
);
3384 do_res (idx
, line
, 'c');
3387 do_print (idx
, line
);
3390 do_form (idx
, line
);
3393 do_heading (idx
, line
);
3405 do_res (idx
, line
, 'z');
3413 do_assigna (idx
, line
);
3416 do_assignc (idx
, line
);
3425 do_if (idx
, line
, EQ
);
3428 do_if (idx
, line
, NE
);
3431 do_if (idx
, line
, LT
);
3434 do_if (idx
, line
, LE
);
3437 do_if (idx
, line
, GE
);
3440 do_if (idx
, line
, GT
);
3443 do_ifc (idx
, line
, 0);
3446 do_ifc (idx
, line
, 1);
3449 do_irp (idx
, line
, 0);
3452 do_irp (idx
, line
, 1);
3462 /* Add a keyword to the hash table. */
3465 add_keyword (name
, code
)
3473 sb_add_string (&label
, name
);
3475 hash_add_to_int_table (&keyword_hash_table
, &label
, code
);
3478 for (j
= 0; name
[j
]; j
++)
3479 sb_add_char (&label
, name
[j
] - 'A' + 'a');
3480 hash_add_to_int_table (&keyword_hash_table
, &label
, code
);
3485 /* Build the keyword hash table - put each keyword in the table twice,
3486 once upper and once lower case.*/
3493 for (i
= 0; kinfo
[i
].name
; i
++)
3494 add_keyword (kinfo
[i
].name
, kinfo
[i
].code
);
3498 for (i
= 0; mrikinfo
[i
].name
; i
++)
3499 add_keyword (mrikinfo
[i
].name
, mrikinfo
[i
].code
);
3523 sb_add_char (&value
, *string
);
3526 exp_get_abs (_("Invalid expression on command line.\n"), 0, &value
, &res
);
3530 sb_add_char (&label
, *string
);
3535 ptr
= hash_create (&vars
, &label
);
3536 free_old_entry (ptr
);
3537 ptr
->type
= hash_integer
;
3543 /* The list of long options. */
3544 static struct option long_options
[] =
3546 { "alternate", no_argument
, 0, 'a' },
3547 { "include", required_argument
, 0, 'I' },
3548 { "commentchar", required_argument
, 0, 'c' },
3549 { "copysource", no_argument
, 0, 's' },
3550 { "debug", no_argument
, 0, 'd' },
3551 { "help", no_argument
, 0, 'h' },
3552 { "mri", no_argument
, 0, 'M' },
3553 { "output", required_argument
, 0, 'o' },
3554 { "print", no_argument
, 0, 'p' },
3555 { "unreasonable", no_argument
, 0, 'u' },
3556 { "version", no_argument
, 0, 'v' },
3557 { "define", required_argument
, 0, 'd' },
3558 { NULL
, no_argument
, 0, 0 }
3561 /* Show a usage message and exit. */
3563 show_usage (file
, status
)
3569 [-a] [--alternate] enter alternate macro mode\n\
3570 [-c char] [--commentchar char] change the comment character from !\n\
3571 [-d] [--debug] print some debugging info\n\
3572 [-h] [--help] print this message\n\
3573 [-M] [--mri] enter MRI compatibility mode\n\
3574 [-o out] [--output out] set the output file\n\
3575 [-p] [--print] print line numbers\n"), program_name
);
3577 [-s] [--copysource] copy source through as comments \n\
3578 [-u] [--unreasonable] allow unreasonable nesting\n\
3579 [-v] [--version] print the program version\n\
3580 [-Dname=value] create preprocessor variable called name, with value\n\
3581 [-Ipath] add to include path list\n\
3584 printf (_("\nReport bugs to bug-gnu-utils@gnu.org\n"));
3588 /* Display a help message and exit. */
3592 printf (_("%s: Gnu Assembler Macro Preprocessor\n"),
3594 show_usage (stdout
, 0);
3609 #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
3610 setlocale (LC_MESSAGES
, "");
3612 bindtextdomain (PACKAGE
, LOCALEDIR
);
3613 textdomain (PACKAGE
);
3615 program_name
= argv
[0];
3616 xmalloc_set_program_name (program_name
);
3618 hash_new_table (101, &keyword_hash_table
);
3619 hash_new_table (101, &assign_hash_table
);
3620 hash_new_table (101, &vars
);
3624 while ((opt
= getopt_long (argc
, argv
, "I:sdhavc:upo:D:M", long_options
,
3638 include_path
*p
= (include_path
*) xmalloc (sizeof (include_path
));
3641 sb_add_string (&p
->path
, optarg
);
3643 paths_tail
->next
= p
;
3650 print_line_number
= 1;
3653 comment_char
= optarg
[0];
3675 /* This output is intended to follow the GNU standards document. */
3676 printf (_("GNU assembler pre-processor %s\n"), program_version
);
3677 printf (_("Copyright 1996 Free Software Foundation, Inc.\n"));
3679 This program is free software; you may redistribute it under the terms of\n\
3680 the GNU General Public License. This program has absolutely no warranty.\n"));
3686 show_usage (stderr
, 1);
3693 macro_init (alternate
, mri
, 0, exp_get_abs
);
3696 outfile
= fopen (out_name
, "w");
3699 fprintf (stderr
, _("%s: Can't open output file `%s'.\n"),
3700 program_name
, out_name
);
3712 /* Process all the input files */
3714 while (optind
< argc
)
3716 if (new_file (argv
[optind
]))
3722 fprintf (stderr
, _("%s: Can't open input file `%s'.\n"),
3723 program_name
, argv
[optind
]);
3733 /* This function is used because an abort in some of the other files
3734 may be compiled into as_abort because they include as.h. */
3737 as_abort (file
, line
, fn
)
3738 const char *file
, *fn
;
3741 fprintf (stderr
, _("Internal error, aborting at %s line %d"), file
, line
);
3743 fprintf (stderr
, " in %s", fn
);
3744 fprintf (stderr
, _("\nPlease report this bug.\n"));