[LLVMdev] ASM appears to be incorrect from llc

Charles Davis cdavis at mymail.mines.edu
Wed Feb 15 17:05:52 PST 2012

Hi Matthew,

On Feb 15, 2012, at 5:42 PM, Matthew Huck wrote:

> Hi,
>   It doesn't compile with yasm, or nasm
Where did you get the idea that "Intel syntax" means NASM? LLVM actually produces assembly files that can be fed to GAS, or to LLVM's MC framework. (In fact, it's missing a .intel_syntax directive so GAS knows it needs to assemble instructions according to Intel syntax.)
> (reports invalid combination of opcode and operands), and 
> mov _x,EAX 
> is meaningless as _x is just a label (an numeric constant that happens to be an address), so it would have to be dereferenced to get to the memory at that address, otherwise it's like saying
> mov 0x12341234, EAX 
That's only true of NASM/YASM.

x86 assembly is sort of like the Chinese language. There's a traditional variant--the one devised by Intel themselves and used in Intel's and Microsoft's assemblers; and a simplified variant--the one devised by the NASM developers based on Intel's variant. (Then there's the AT&T variant, which is really different from either Intel or NASM.) One of the key differences is that in traditional syntax, labels automatically get dereferenced. If you want the offset, you have to use the 'offset' operator. In simplified syntax, on the other hand, labels are not automatically dereferenced, and you don't need the 'offset' operator; you do, however, need to use square brackets to dereference the label.

Hope that helps clear this up.


More information about the llvm-dev mailing list