[LLVMdev] Intel vs. AT&T Assembly.

Ralph Corderoy ralph at inputplus.co.uk
Mon May 1 04:39:55 PDT 2006


Hi Chris,

> The LLVM X86 backend started out emitting intel mode for use with GAS
> and it's "intel syntax mode" (which does use registers with %'s).
> Unfortunately GAS has (or commonly available versions have) a number
> of bugs in intel syntax mode (e.g. you can't define a function named
> 'dword'), so we switched to using AT&T syntax.

Ah, OK.  The current gas manual says Intel register operands are
undelimeted, i.e. no `%'.  Perhaps they've changed.

    http://www.gnu.org/software/binutils/manual/gas-2.9.1/html_chapter/as_16.html#IDX585

> Intel syntax mode was retained because it's nicer to read :), and
> because it may be useful in the future.  As Jeff says, patches are
> welcome to make it do something useful, e.g. be assemblable with MASM
> or NASM.

NASM might be the nicer target since it's GNU LGPL and runs on multiple
OS.  Its home page is broken at the moment, but the manual pages work.

    http://nasm.sourceforge.net/doc/html/nasmdoc0.html

You went onto write:
> > Let's see.  Ralph correctly points out that LLVM isn't producing
> > anything like Intel syntax.   ...

"Oh, no I didn't".  :-)  It was me that was saying llc's att and intel
are already very different but both happen to have `%'.

> This is not true.  LLVM produces something very close to what GAS
> accepts in intel mode: that is, we produce fully intel syntax (e.g.
> "DWORD PTR", no opcode size suffixes, etc)  but we prepend % onto
> registers.  This is what GAS expects (i.e., it's gas intel mode).  I
> believe there is a GAS option to turn off the % prefix, but we never
> used it because it had other bugs.

OK, looks like they may have made that the default now.

> As was independently pointed out, we're quite close to supporting MASM
> (or whatever) intel syntax.  Removing the %'s, for example, is
> trivial.  Anyone who wants to do so is welcome to.  The current
> -x86-asm-syntax=intel support is not currently compatible with any
> assembler that I know of.  Patches to make it useful are welcome.

OK.  Thanks for clarifying.

Cheers,


Ralph.





More information about the llvm-dev mailing list