bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gas and prefix's on x86


From: Andrew Macleod
Subject: gas and prefix's on x86
Date: Thu, 25 Apr 2002 09:41:17 -0700

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));



reply via email to

[Prev in Thread] Current Thread [Next in Thread]