/* gasp.c - Gnu assembler preprocessor main program.
- Copyright (C) 1994, 1995 Free Software Foundation, Inc.
+ Copyright (C) 1994, 95, 96, 1997 Free Software Foundation, Inc.
Written by Steve and Judy Chamberlain of Cygnus Support,
sac@cygnus.com
char *program_version = "1.2";
+/* This is normally declared in as.h, but we don't include that. We
+ need the function because other files linked with gasp.c might call
+ it. */
+extern void as_abort PARAMS ((const char *, int, const char *));
+
#define MAX_INCLUDES 30 /* Maximum include depth */
#define MAX_REASONABLE 1000 /* Maximum number of expansions */
if (ptr->value.s.len)
{
if (!again)
- ERROR ((stderr, "redefintion not allowed"));
+ ERROR ((stderr, "redefinition not allowed\n"));
}
ptr->type = hash_string;
while (idx < in->len)
{
- if (idx < in->len - 1 && in->ptr[idx + 1] == '\'' && ! mri)
+ if (in->ptr[idx] == '\\'
+ && idx + 1 < in->len
+ && in->ptr[idx + 1] == '(')
+ {
+ idx += 2;
+ while (idx < in->len
+ && in->ptr[idx] != ')')
+ {
+ sb_add_char (out, in->ptr[idx]);
+ idx++;
+ }
+ if (idx < in->len)
+ idx++;
+ }
+ else if (idx < in->len - 1 && in->ptr[idx + 1] == '\'' && ! mri)
{
int base;
int value;
int idx;
sb *in;
{
- int al;
+ int al, have_fill, fill;
+
idx = exp_get_abs ("align needs absolute expression.\n", idx, in, &al);
+ idx = sb_skip_white (idx, in);
+ have_fill = 0;
+ fill = 0;
+ if (! eol (idx, in))
+ {
+ idx = sb_skip_comma (idx, in);
+ idx = exp_get_abs (".align needs absolute fill value.\n", idx, in,
+ &fill);
+ have_fill = 1;
+ }
if (al != 1
&& al != 2
&& al != 4)
WARNING ((stderr, "alignment must be one of 1, 2 or 4.\n"));
- fprintf (outfile, ".align %d\n", al);
+ fprintf (outfile, ".align %d", al);
+ if (have_fill)
+ fprintf (outfile, ",%d", fill);
+ fprintf (outfile, "\n");
}
/* .res[.b|.w|.l] <size> */
{
hash_entry *ptr;
if (in->ptr[idx] == '\\'
+ && idx + 1 < in->len
+ && in->ptr[idx + 1] == '(')
+ {
+ do
+ {
+ sb_add_char (buf, in->ptr[idx]);
+ idx++;
+ }
+ while (idx < in->len && in->ptr[idx - 1] != ')');
+ }
+ else if (in->ptr[idx] == '\\'
+ && idx + 1 < in->len
&& in->ptr[idx + 1] == '&')
{
idx = condass_lookup_name (in, idx + 2, buf, 1);
}
else if (in->ptr[idx] == '\\'
+ && idx + 1 < in->len
&& in->ptr[idx + 1] == '$')
{
idx = condass_lookup_name (in, idx + 2, buf, 0);
{
l = grab_label (&line, &label_in);
sb_reset (&label);
- if (label_in.len)
- {
- /* Munge any label */
-
-
- process_assigns (0, &label_in, &label);
- }
if (line.ptr[l] == ':')
l++;
while (ISWHITE (line.ptr[l]) && l < line.len)
l++;
+ if (label_in.len)
+ {
+ int do_assigns;
+
+ /* Munge the label, unless this is EQU or ASSIGN. */
+ do_assigns = 1;
+ if (l < line.len
+ && (line.ptr[l] == '.' || alternate || mri))
+ {
+ int lx = l;
+
+ if (line.ptr[lx] == '.')
+ ++lx;
+ if (lx + 3 <= line.len
+ && strncasecmp ("EQU", line.ptr + lx, 3) == 0
+ && (lx + 3 == line.len
+ || ! ISFIRSTCHAR (line.ptr[lx + 3])))
+ do_assigns = 0;
+ else if (lx + 6 <= line.len
+ && strncasecmp ("ASSIGN", line.ptr + lx, 6) == 0
+ && (lx + 6 == line.len
+ || ! ISFIRSTCHAR (line.ptr[lx + 6])))
+ do_assigns = 0;
+ }
+
+ if (do_assigns)
+ process_assigns (0, &label_in, &label);
+ else
+ sb_add_sb (&label, &label_in);
+ }
+
if (l < line.len)
{
if (process_pseudo_op (l, &line, &acc))
const char *err;
int line = linecount ();
- err = define_macro (idx, in, &label, get_line);
+ err = define_macro (idx, in, &label, get_line, (const char **) NULL);
if (err != NULL)
ERROR ((stderr, "macro at line %d: %s\n", line - 1, err));
}
{
case K_ALTERNATE:
alternate = 1;
- macro_init (1, mri, exp_get_abs);
+ macro_init (1, mri, 0, exp_get_abs);
return 1;
case K_AELSE:
do_aelse ();
do_sdata (idx, line, 'z');
return 1;
case K_ASSIGN:
- do_assign (1, 0, line);
+ do_assign (0, 0, line);
return 1;
case K_AIF:
do_aif (idx, line);
do_aendr ();
return 1;
case K_EQU:
- do_assign (0, idx, line);
+ do_assign (1, idx, line);
return 1;
case K_ALIGN:
do_align (idx, line);
[-h] [--help] print this message\n\
[-M] [--mri] enter MRI compatibility mode\n\
[-o out] [--output out] set the output file\n\
- [-p] [--print] print line numbers\n\
+ [-p] [--print] print line numbers\n", program_name);
+ fprintf (file, "\
[-s] [--copysource] copy source through as comments \n\
[-u] [--unreasonable] allow unreasonable nesting\n\
[-v] [--version] print the program version\n\
[-Dname=value] create preprocessor variable called name, with value\n\
[-Ipath] add to include path list\n\
- [in-file]\n", program_name);
+ [in-file]\n");
+ if (status == 0)
+ printf ("\nReport bugs to bug-gnu-utils@prep.ai.mit.edu\n");
exit (status);
}
show_help ();
/*NOTREACHED*/
case 'v':
- printf ("GNU %s version %s\n", program_name, program_version);
+ /* This output is intended to follow the GNU standards document. */
+ printf ("GNU assembler pre-processor %s\n", program_version);
+ printf ("Copyright 1996 Free Software Foundation, Inc.\n");
+ printf ("\
+This program is free software; you may redistribute it under the terms of\n\
+the GNU General Public License. This program has absolutely no warranty.\n");
exit (0);
/*NOTREACHED*/
case 0:
process_init ();
- macro_init (alternate, mri, exp_get_abs);
+ macro_init (alternate, mri, 0, exp_get_abs);
if (out_name) {
outfile = fopen (out_name, "w");