[PATCH] add directive to enter/leave alternate macro mode
Jan Beulich
JBeulich@novell.com
Mon Aug 2 15:43:00 GMT 2004
>>> Ian Lance Taylor <ian@wasabisystems.com> 08.06.04 17:30:49 >>>
>"Jan Beulich" <JBeulich@novell.com> writes:
>
>> And, I'm at once trying to find out why it's undocumented. If it's
for
>> a reason (and not just because non-one got to write proper
>> documentation), then it wouldn't seem appropriate to document the
>> directive. Oth, if it's just an unintended omission, then perhaps
it
>> might be a good idea to actually add the supposed command line
option
>> and enable (and complete) the documentation (it's on another page
>> whether I'll be able to figure how these .texinfo files need to be
>> modified consistently without a lot of effort, which is one of the
>> reasons I didn't really consider writing documentation for this in
the
>> first place).
>
>I think the documentation would be an unintentional omission. Does
>anybody else know?
So here's an update to the previously posted patch, this time including
both documentation and a new command line option to allow to also enable
alternate macro mode that way.
gas:
2004-08-02 Jan Beulich <jbeulich@novell.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 directive.
* doc/as.texinfo:
gas/testsuite:
2004-08-02 Jan Beulich <jbeulich@novell.com>
* 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-02 15:43:41.473959952
+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
mode\n"));
+ fprintf (stream, _("\
-D produce assembler debugging messages\n"));
fprintf (stream, _("\
--defsym SYM=VAL define symbol SYM to given value\n"));
@@ -399,6 +403,7 @@ parse_args (int * pargc, char *** pargv)
OPTION_VERBOSE,
OPTION_EMULATION,
OPTION_DEFSYM,
+ OPTION_ALTERNATE,
OPTION_INSTTBL,
OPTION_LISTING_LHS_WIDTH,
OPTION_LISTING_LHS_WIDTH2,
@@ -433,6 +438,7 @@ parse_args (int * pargc, char *** pargv)
{"verbose", no_argument, NULL, OPTION_VERBOSE},
{"emulation", required_argument, NULL, OPTION_EMULATION},
{"defsym", required_argument, NULL, OPTION_DEFSYM},
+ {"Alternate", no_argument, NULL, OPTION_ALTERNATE},
/* New option for extending instruction set (see also -t above).
The "-t file" or "--itbl file" option extends the basic set of
valid instructions by reading "file", a text file containing a
@@ -615,6 +621,10 @@ the GNU General Public License. This pr
}
break;
+ case OPTION_ALTERNATE:
+ flag_macro_alternate = 1;
+ break;
+
case OPTION_INSTTBL:
case 't':
{
@@ -981,7 +991,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 +1045,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 +1052,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-02
15:45:19.913994792 +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/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.308880328 +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-02
16:34:01.454853072 +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.213064392 +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.565358184 +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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: binutils-mainline-macro-alternate.patch
Type: application/octet-stream
Size: 13357 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20040802/ad3bd68d/attachment.obj>
More information about the Binutils
mailing list