This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: as doesn't recognize "# line file"
Hi Jun,
> > > echo \
> > > '# 1 file.S
> > > movw %al, %al' > file.s
> > > gcc file.s
> > > file.s: Assembler messages:
> > > file.s:2: Error: `%al' not allowed with `movw'
> > >
> > > Is this how it's supposed to behave?
> >
> > Yes. Try removing the '# 1 file.S' line and just assembling the movw
> > line. You will still get the same error message.
>
> Seems like I'm misunderstood here...(sorry if the point wasn't clear)
> What I meant was that I *am* getting the (exact) same error message with
> and without '# 1 file.S', and that's the problem. I was expecting as to
> report a file name with an uppercase S instead of a lowercase (the error
> itself is intentional):
>
> file.S:2: Error: `%al' not allowed with `movw'
>
> The manual says that as processes the `# line file' output from cpp, and
> on subsequent output, reports file & line specified with it. (The first
> line in e.g.2 was meant to emulate a part of cpp's output)
> So, again, is this how as is supposed to behave, to ignore '# line file'?
OK, now I understand. There are two bugs here, one in your test case
(and possibly the output of your C pre-processor) and one in the
assembler itself. The bug in the assembler was that the '#' character
was not set up to indicate the start of a line comment. Only a '#' as
a line comment character can trigger the assembler's code to interpret
#-line directives. The patch below fixes this for the i386 port
(which I assume is what you are using).
The second bug is that the #-line directive is only interpreted by the
assembler if the file name is enclosed in double quotes. So if you
apply the patch below and change your test case to:
echo \
'# 1 "file.S"
movw %al, %al' > file.s
then everything should work.
Cheers
Nick
PS. The assembler documentation does say that this feature is
deprecated, so do not rely upon it being present in future releases.
2003-01-29 Nick Clifton <nickc@redhat.com>
* config/tc-i386.c (line_comment_chars): Add '#'. This makes the
assembler's handling of # <linenum> "<filename>" directives work.
Index: gas/config/tc-i386.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-i386.c,v
retrieving revision 1.137
diff -c -3 -p -w -r1.137 tc-i386.c
*** gas/config/tc-i386.c 23 Jan 2003 12:51:04 -0000 1.137
--- gas/config/tc-i386.c 29 Jan 2003 09:54:15 -0000
*************** const char comment_chars[] = "#/";
*** 207,213 ****
#NO_APP at the beginning of its output.
Also note that comments started like this one will always work if
'/' isn't otherwise defined. */
! const char line_comment_chars[] = "";
#else
/* Putting '/' here makes it impossible to use the divide operator.
--- 207,213 ----
#NO_APP at the beginning of its output.
Also note that comments started like this one will always work if
'/' isn't otherwise defined. */
! const char line_comment_chars[] = "#";
#else
/* Putting '/' here makes it impossible to use the divide operator.
*************** const char line_comment_chars[] = "";
*** 215,221 ****
const char comment_chars[] = "#";
#define PREFIX_SEPARATOR '/'
! const char line_comment_chars[] = "/";
#endif
const char line_separator_chars[] = ";";
--- 215,221 ----
const char comment_chars[] = "#";
#define PREFIX_SEPARATOR '/'
! const char line_comment_chars[] = "/#";
#endif
const char line_separator_chars[] = ";";