This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
[patch] gas -- @ Character in macro expansion
- To: binutils at sourceware dot cygnus dot com
- Subject: [patch] gas -- @ Character in macro expansion
- From: Catherine Moore <clm at cygnus dot com>
- Date: Fri, 28 Apr 2000 13:16:19 -0700
- cc: clm at cygnus dot com
This patch addresses a problem that I am seeing with the
expansion of the @ character in macros. The doc says that
the @ character will expand to the number of times the macro
was invoked. We are currently prepending leading zeroes to this
number. So for this test case:
.macro def_sym sym_name
.equ \sym_name,\@
.endm
def_sym sym1
def_sym sym2
def_sym sym3
def_sym sym4
def_sym sym5
def_sym sy6
def_sym sym7
def_sym sym8
def_sym sym9
We will expand to:
.equ sym1, 00001
.equ sym2, 00002
.equ sym3, 00003
.equ sym4, 00004
.equ sym5, 00005
.equ sym6, 00006
.equ sym7, 00007
.equ sym8, 00008
.equ sym9, 00009
The parser thinks that we are processing octal numbers (due to the
leading zeroes) and rejects values 00008 and 00009. I would
like to change the macro expander so that it no longer prepends the
zeroes. What do others think?
Fri Apr 28 12:33:54 2000 Catherine Moore <clm@cygnus.com>
* macro.s (macro_expand_body): Don't prepend zeroes to
the macro number.
Index: macro.c
===================================================================
RCS file: /cvs/src/src/gas/macro.c,v
retrieving revision 1.6
diff -p -r1.6 macro.c
*** macro.c 2000/03/26 14:47:33 1.6
- --- macro.c 2000/04/28 17:37:47
*************** macro_expand_body (in, out, formals, for
*** 700,706 ****
char buffer[10];
src++;
! sprintf (buffer, "%05d", macro_number);
sb_add_string (out, buffer);
}
else if (in->ptr[src] == '&')
- --- 700,706 ----
char buffer[10];
src++;
! sprintf (buffer, "%d", macro_number);
sb_add_string (out, buffer);
}
else if (in->ptr[src] == '&')