+2004-08-13 Jan Beulich <jbeulich@novell.com>
+ Nick Clifton <nickc@redhat.com>
+
+ * as.c: Add and handle new --alternate command line option.
+ * macro.c (macro_set_alternate): New.
+ * macro.h (macro_set_alternate): Declare.
+ * read.c: Add and handle new .altmacro and .noaltmacro directives.
+ * doc/as.texinfo: Document new command line option and pseudo-ops
+ as well as insert documentation originating from gasp about
+ alternate macro syntax.
+ * NEWS: Mention new command line option and pseudo-ops.
+
2004-08-10 Mark Mitchell <mark@codesourcery.com>
* expr.c (operand): Handle the "~", "-", and "!" operators applied
* Support for ColdFire EMAC instructions added and Motorola syntax for MAC/EMAC
instrucitons.
+* New command line option --alternate and pseudo-ops .altmacro and .noaltmacro
+ added to enter (and leave) alternate macro syntax mode.
+
Changes in 2.15:
* The MIPS -membedded-pic option (Embedded-PIC code generation) is
static long start_time;
+static int flag_macro_alternate;
+
\f
#ifdef USE_EMULATIONS
#define EMULATION_ENVIRON "AS_EMULATION"
=FILE list to FILE (must be last sub-option)\n"));
fprintf (stream, _("\
+ --alternate initially turn on alternate macro syntax\n"));
+ fprintf (stream, _("\
-D produce assembler debugging messages\n"));
fprintf (stream, _("\
--defsym SYM=VAL define symbol SYM to given value\n"));
OPTION_TARGET_HELP,
OPTION_EXECSTACK,
OPTION_NOEXECSTACK,
+ OPTION_ALTERNATE,
OPTION_WARN_FATAL
};
{"execstack", no_argument, NULL, OPTION_EXECSTACK},
{"noexecstack", no_argument, NULL, OPTION_NOEXECSTACK},
#endif
+ {"alternate", no_argument, NULL, OPTION_ALTERNATE},
{"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL}
/* When you add options here, check that they do not collide with
OPTION_MD_BASE. See as.h. */
flag_always_generate_output = 1;
break;
+ case OPTION_ALTERNATE:
+ optarg = old_argv [optind - 1];
+ while (* optarg == '-')
+ optarg ++;
+
+ if (strcmp (optarg, "alternate") == 0)
+ {
+ flag_macro_alternate = 1;
+ break;
+ }
+ optarg ++;
+ /* Fall through. */
+
case 'a':
if (optarg)
{
int
main (int argc, char ** argv)
{
- int macro_alternate;
int macro_strip_at;
int keep_it;
if (flag_print_statistics)
xatexit (dump_statistics);
- macro_alternate = 0;
macro_strip_at = 0;
#ifdef TC_I960
macro_strip_at = flag_mri;
#ifdef TC_A29K
/* For compatibility with the AMD 29K family macro assembler
specification. */
- macro_alternate = 1;
+ flag_macro_alternate = 1;
macro_strip_at = 1;
#endif
- macro_init (macro_alternate, flag_mri, macro_strip_at, macro_expr);
+ macro_init (flag_macro_alternate, flag_mri, macro_strip_at, macro_expr);
PROGRESS (1);
@c to be limited to one line for the header.
@smallexample
@c man begin SYNOPSIS
-@value{AS} [@b{-a}[@b{cdhlns}][=@var{file}]] [@b{-D}] [@b{--defsym} @var{sym}=@var{val}]
- [@b{-f}] [@b{--gstabs}] [@b{--gstabs+}] [@b{--gdwarf2}] [@b{--help}]
- [@b{-I} @var{dir}] [@b{-J}] [@b{-K}] [@b{-L}]
+@value{AS} [@b{-a}[@b{cdhlns}][=@var{file}]] [@b{--alternate}] [@b{-D}]
+ [@b{--defsym} @var{sym}=@var{val}] [@b{-f}] [@b{--gstabs}] [@b{--gstabs+}]
+ [@b{--gdwarf2}] [@b{--help}] [@b{-I} @var{dir}] [@b{-J}] [@b{-K}] [@b{-L}]
[@b{--listing-lhs-width}=@var{NUM}] [@b{--listing-lhs-width2}=@var{NUM}]
[@b{--listing-rhs-width}=@var{NUM}] [@b{--listing-cont-lines}=@var{NUM}]
[@b{--keep-locals}] [@b{-o} @var{objfile}] [@b{-R}] [@b{--statistics}] [@b{-v}]
listing without forms processing. The @samp{=file} option, if used, must be
the last one. By itself, @samp{-a} defaults to @samp{-ahls}.
+@item --alternate
+Begin in alternate macro mode, see @ref{Altmacro,,@code{.altmacro}}.
+
@item -D
Ignored. This option is accepted for script compatibility with calls to
other assemblers.
@menu
* a:: -a[cdhlns] enable listings
+* alternate:: --alternate enable alternate macro syntax
* D:: -D for compatibility
* f:: -f to work faster
* I:: -I for .include search path
stdin only after they have been preprocessed by the assembler. This reduces
memory usage and makes the code more efficient.
+@node alternate
+@section @option{--alternate}
+
+@kindex --alternate
+Begin in alternate macro mode, see @ref{Altmacro,,@code{.altmacro}}.
+
@node D
@section @option{-D}
@end ifset
* Align:: @code{.align @var{abs-expr} , @var{abs-expr}}
+* Altmacro:: @code{.altmacro}
* Ascii:: @code{.ascii "@var{string}"}@dots{}
* Asciz:: @code{.asciz "@var{string}"}@dots{}
* Balign:: @code{.balign @var{abs-expr} , @var{abs-expr}}
* Macro:: @code{.macro @var{name} @var{args}}@dots{}
* MRI:: @code{.mri @var{val}}
+* Noaltmacro:: @code{.noaltmacro}
* Nolist:: @code{.nolist}
* Octa:: @code{.octa @var{bignums}}
* Org:: @code{.org @var{new-lc} , @var{fill}}
executed in this pseudo-variable; you can copy that number to your
output with @samp{\@@}, but @emph{only within a macro definition}.
-@ignore
@item LOCAL @var{name} [ , @dots{} ]
@emph{Warning: @code{LOCAL} is only available if you select ``alternate
-macro syntax'' with @samp{-a} or @samp{--alternate}.} @xref{Alternate,,
-Alternate macro syntax}.
+macro syntax'' with @samp{--alternate} or @code{.altmacro}.}
+@xref{Altmacro,,@code{.altmacro}}.
+@end ftable
-Generate a string replacement for each of the @var{name} arguments, and
+@node Altmacro
+@section @code{.altmacro}
+Enable alternate macro mode, enabling:
+
+@ftable @code
+@item LOCAL @var{name} [ , @dots{} ]
+One additional directive, @code{LOCAL}, is available. It is used to
+generate a string replacement for each of the @var{name} arguments, and
replace any instances of @var{name} in each macro expansion. The
replacement string is unique in the assembly, and different for each
separate macro expansion. @code{LOCAL} allows you to write macros that
define symbols, without fear of conflict between separate macro expansions.
-@end ignore
+
+@item String delimiters
+You can write strings delimited in these other ways besides
+@code{"@var{string}"}:
+
+@table @code
+@item '@var{string}'
+You can delimit strings with single-quote charaters.
+
+@item <@var{string}>
+You can delimit strings with matching angle brackets.
+@end table
+
+@item single-character string escape
+To include any single character literally in a string (even if the
+character would otherwise have some special meaning), you can prefix the
+character with @samp{!} (an exclamation mark). For example, you can
+write @samp{<4.3 !> 5.4!!>} to get the literal text @samp{4.3 > 5.4!}.
+
+@item Expression results as strings
+You can write @samp{%@var{expr}} to evaluate the expression @var{expr}
+and use the result as a string.
@end ftable
+@node Noaltmacro
+@section @code{.noaltmacro}
+Disable alternate macro mode. @ref{Altmacro}
+
@node Nolist
@section @code{.nolist}
macro_expr = expr;
}
+/* Switch in and out of alternate mode on the fly. */
+
+void
+macro_set_alternate(alternate)
+ int alternate;
+{
+ macro_alternate = alternate;
+}
+
/* Switch in and out of MRI mode on the fly. */
void
extern int buffer_and_nest (const char *, const char *, sb *, int (*) (sb *));
extern void macro_init
(int, int, int, int (*) (const char *, int, sb *, int *));
+extern void macro_set_alternate (int);
extern void macro_mri_mode (int);
extern const char *define_macro
(int, sb *, sb *, int (*) (sb *), const char **);
static void do_align (int, char *, int, int);
static void s_align (int, int);
+static void s_altmacro (int);
static int hex_float (int, char *);
static segT get_known_segmented_expression (expressionS * expP);
static void pobegin (void);
static const pseudo_typeS potable[] = {
{"abort", s_abort, 0},
{"align", s_align_ptwo, 0},
+ {"altmacro", s_altmacro, 1},
{"ascii", stringer, 0},
{"asciz", stringer, 1},
{"balign", s_align_bytes, 0},
{"mri", s_mri, 0},
{".mri", s_mri, 0}, /* Special case so .mri works in MRI mode. */
{"name", s_ignore, 0},
+ {"noaltmacro", s_altmacro, 0},
{"noformat", s_ignore, 0},
{"nolist", listing_list, 0}, /* Turn listing off. */
{"nopage", listing_nopage, 0},
s_align (arg, 0);
}
+/* Switch in and out of alternate macro mode. */
+
+void
+s_altmacro (int on)
+{
+ demand_empty_rest_of_line ();
+ macro_set_alternate (on);
+}
+
symbolS *
s_comm_internal (int param,
symbolS *(*comm_parse_extra) (int, symbolS *, addressT))
+2004-08-13 Jan Beulich <jbeulich@novell.com>
+
+ * gas/all/altmacro.[sd]: New test.
+ * gas/all/gas.exp: Run the new test.
+
2004-08-10 Mark Mitchell <mark@codesourcery.com>
* gas/arm/bignum1.s: New test.
--- /dev/null
+#as: --alternate
+#objdump: -s -j .data
+#name: alternate macro syntax
+
+# Test the alternate macro syntax.
+
+.*: .*
+
+Contents of section .data:
+ 0000 01020912 61626331 32332121 3c3e2721 .*
+ 0010 3c3e273e 3c21 .*
--- /dev/null
+.macro m1 v1, v2
+ LOCAL l1, l2
+label&v1:
+l1: .byte v1
+label&v2:
+l2: .byte v2
+.endm
+
+.macro m2 v1, v2
+ m1 %v1, %(v2-v1)
+.endm
+
+.macro m3 str
+ .ascii &str
+.endm
+
+ .data
+
+m2 1, 3
+m2 9, 27
+
+m3 "abc"
+m3 <123>
+
+ .noaltmacro
+
+.macro m4 str
+ .ascii "&str"
+.endm
+
+m4 "!!<>'"
+
+ .altmacro
+
+m3 "!!<>'"
+m3 <!>!<!!>
}
}
+run_dump_test altmacro
+
# This test is for any COFF target.
# We omit m88k COFF because it uses weird pseudo-op names.
# We omit the ARM toolchains because they define locals to