gas: 2004-08-03 Jan Beulich * 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. gas/testsuite: 2004-08-03 Jan Beulich * gas/all/altmacro.[sd]: New test. * gas/all/gas.exp: Run the new test. diff -N'aprux*.gmo' -xsid /home/jbeulich/src/binutils/mainline/2004-08-02.10.53/gas/as.c 2004-08-02.10.53-altmacro/gas/as.c --- /home/jbeulich/src/binutils/mainline/2004-08-02.10.53/gas/as.c 2003-10-27 13:45:17.000000000 +0100 +++ 2004-08-02.10.53-altmacro/gas/as.c 2004-08-03 15:32:26.990700504 +0200 @@ -123,6 +123,8 @@ static struct itbl_file_list *itbl_files static long start_time; +static int flag_macro_alternate; + #ifdef USE_EMULATIONS #define EMULATION_ENVIRON "AS_EMULATION" @@ -245,6 +247,8 @@ Options:\n\ =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")); @@ -414,6 +418,7 @@ parse_args (int * pargc, char *** pargv) OPTION_TARGET_HELP, OPTION_EXECSTACK, OPTION_NOEXECSTACK, + OPTION_ALTERNATE, OPTION_WARN_FATAL }; @@ -457,6 +462,7 @@ parse_args (int * pargc, char *** pargv) {"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. */ @@ -731,6 +737,19 @@ the GNU General Public License. This pr 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) { @@ -981,7 +1000,6 @@ perform_an_assembly_pass (int argc, char int main (int argc, char ** argv) { - int macro_alternate; int macro_strip_at; int keep_it; @@ -1036,7 +1054,6 @@ main (int argc, char ** argv) if (flag_print_statistics) xatexit (dump_statistics); - macro_alternate = 0; macro_strip_at = 0; #ifdef TC_I960 macro_strip_at = flag_mri; @@ -1044,11 +1061,11 @@ main (int argc, char ** argv) #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); diff -N'aprux*.gmo' -xsid /home/jbeulich/src/binutils/mainline/2004-08-02.10.53/gas/doc/as.texinfo 2004-08-02.10.53-altmacro/gas/doc/as.texinfo --- /home/jbeulich/src/binutils/mainline/2004-08-02.10.53/gas/doc/as.texinfo 2004-08-02 10:52:09.000000000 +0200 +++ 2004-08-02.10.53-altmacro/gas/doc/as.texinfo 2004-08-03 11:38:43.000000000 +0200 @@ -226,9 +226,9 @@ gcc(1), ld(1), and the Info entries for @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}] @@ -463,6 +463,9 @@ You may combine these options; for examp 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. @@ -1457,6 +1460,7 @@ assembler.) @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 @@ -1529,6 +1533,12 @@ directives. This is because the listing 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} @@ -3677,6 +3687,7 @@ Some machine configurations provide addi @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}} @@ -3753,6 +3764,7 @@ Some machine configurations provide addi * 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}} @@ -4847,20 +4859,52 @@ Exit early from the current macro defini 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 + +@node Altmacro +@section @code{.altmacro} +Enable alternate macro mode, enabling: -Generate a string replacement for each of the @var{name} arguments, and +@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} diff -N'aprux*.gmo' -xsid /home/jbeulich/src/binutils/mainline/2004-08-02.10.53/gas/macro.c 2004-08-02.10.53-altmacro/gas/macro.c --- /home/jbeulich/src/binutils/mainline/2004-08-02.10.53/gas/macro.c 2003-11-24 18:52:33.000000000 +0100 +++ 2004-08-02.10.53-altmacro/gas/macro.c 2004-05-26 13:52:01.000000000 +0200 @@ -132,6 +132,15 @@ macro_init (int alternate, int mri, int 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 diff -N'aprux*.gmo' -xsid /home/jbeulich/src/binutils/mainline/2004-08-02.10.53/gas/macro.h 2004-08-02.10.53-altmacro/gas/macro.h --- /home/jbeulich/src/binutils/mainline/2004-08-02.10.53/gas/macro.h 2003-11-24 18:52:33.000000000 +0100 +++ 2004-08-02.10.53-altmacro/gas/macro.h 2004-05-26 14:05:27.000000000 +0200 @@ -73,6 +73,7 @@ extern int macro_nest; 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 **); diff -N'aprux*.gmo' -xsid /home/jbeulich/src/binutils/mainline/2004-08-02.10.53/gas/NEWS 2004-08-02.10.53-altmacro/gas/NEWS --- /home/jbeulich/src/binutils/mainline/2004-08-02.10.53/gas/NEWS 2004-07-22 11:48:33.000000000 +0200 +++ 2004-08-02.10.53-altmacro/gas/NEWS 2004-08-03 15:30:38.813145992 +0200 @@ -12,6 +12,9 @@ * 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 diff -N'aprux*.gmo' -xsid /home/jbeulich/src/binutils/mainline/2004-08-02.10.53/gas/read.c 2004-08-02.10.53-altmacro/gas/read.c --- /home/jbeulich/src/binutils/mainline/2004-08-02.10.53/gas/read.c 2004-04-19 11:32:55.000000000 +0200 +++ 2004-08-02.10.53-altmacro/gas/read.c 2004-08-02 13:48:48.000000000 +0200 @@ -216,6 +216,7 @@ static int dwarf_file_string; 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); @@ -251,6 +252,7 @@ static struct hash_control *po_hash; 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}, @@ -351,6 +353,7 @@ static const pseudo_typeS potable[] = { {"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}, @@ -1320,6 +1323,15 @@ s_align_ptwo (int arg) 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)) diff -N'aprux*.gmo' -xsid /home/jbeulich/src/binutils/mainline/2004-08-02.10.53/gas/testsuite/gas/all/altmacro.d 2004-08-02.10.53-altmacro/gas/testsuite/gas/all/altmacro.d --- /home/jbeulich/src/binutils/mainline/2004-08-02.10.53/gas/testsuite/gas/all/altmacro.d 1970-01-01 01:00:00.000000000 +0100 +++ 2004-08-02.10.53-altmacro/gas/testsuite/gas/all/altmacro.d 2004-08-03 11:45:35.000000000 +0200 @@ -0,0 +1,11 @@ +#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 .* diff -N'aprux*.gmo' -xsid /home/jbeulich/src/binutils/mainline/2004-08-02.10.53/gas/testsuite/gas/all/altmacro.s 2004-08-02.10.53-altmacro/gas/testsuite/gas/all/altmacro.s --- /home/jbeulich/src/binutils/mainline/2004-08-02.10.53/gas/testsuite/gas/all/altmacro.s 1970-01-01 01:00:00.000000000 +0100 +++ 2004-08-02.10.53-altmacro/gas/testsuite/gas/all/altmacro.s 2004-08-02 16:29:17.000000000 +0200 @@ -0,0 +1,36 @@ +.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 ! diff -N'aprux*.gmo' -xsid /home/jbeulich/src/binutils/mainline/2004-08-02.10.53/gas/testsuite/gas/all/gas.exp 2004-08-02.10.53-altmacro/gas/testsuite/gas/all/gas.exp --- /home/jbeulich/src/binutils/mainline/2004-08-02.10.53/gas/testsuite/gas/all/gas.exp 2004-08-02 10:52:10.000000000 +0200 +++ 2004-08-02.10.53-altmacro/gas/testsuite/gas/all/gas.exp 2004-08-02 15:29:10.000000000 +0200 @@ -114,6 +114,8 @@ case $target_triplet in { } } +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