This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
gas and prefix's on x86
- From: Andrew Macleod <amacleod at cygnus dot com>
- To: binutils at sources dot redhat dot com, bug-binutils at gnu dot org
- Date: Thu, 25 Apr 2002 09:41:17 -0700
- Subject: gas and prefix's on x86
I've run into a problem using prefix's in the assembler on an x86 target
It looks like the initial processing of a line to be assembled strips out
all the spaces after the first mnemonic. So the line
lock incw [eax]x
get compressed to
lock incw[eax]x
before its passed to md_assemble(). When it is handled there, a '['
character is not expected to by jammed up against the instruction
like that (it seems to still be expecting a space), so we issue an
error saying the '[' is invalid. It does accept the lock prefix if
its on a seperate line by itself. ie
lock
incw [eax]x
works fine. However, we can't issue that from the asm statement in
the conmpiler. The original source code looks like:
main()
int x;
asm {
lock incw [eax]x;
}
}
and its invalid to specify it as
asm {
lock
incw [eax]x;
}
Is this patch OK? I've tried to make it so that we won't accept incw[eax]x
by itself on a line. Are there other characters other than a '[' that
we need to concern ourselves with? Or should the space after incw simply
not have been removed at all?
Andrew
* config/tc-i386.c (md_assemble): An instruction with a prefix can
be followed by a ']' character, as in 'lock incw [eax]x'
Index: gas/config/tc-i386.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gas/config/tc-i386.c,v
retrieving revision 1.172.12.1
diff -c -p -r1.172.12.1 tc-i386.c
*** gas/config/tc-i386.c 2001/12/10 22:39:04 1.172.12.1
--- gas/config/tc-i386.c 2002/04/25 16:24:40
*************** md_assemble (line)
*** 1269,1275 ****
if (!is_space_char (*l)
&& *l != END_OF_INSN
&& *l != PREFIX_SEPARATOR
! && *l != ',')
{
as_bad (_("invalid character %s in mnemonic"),
output_invalid (*l));
--- 1269,1280 ----
if (!is_space_char (*l)
&& *l != END_OF_INSN
&& *l != PREFIX_SEPARATOR
! && *l != ','
! /* If a prefix is present, there may be no space between the
! instruction and its operands, so we must allow certain other
! seperators if the instruction is not the first thing
! on this line. */
! && (!(*l == '[' && (token_start != line))))
{
as_bad (_("invalid character %s in mnemonic"),
output_invalid (*l));