[LLVMdev] ASM appears to be incorrect from llc

Gordon Keiser gkeiser at arxan.com
Wed Feb 15 18:42:03 PST 2012


Then you had some old assemblers  that were REALLY silly: 
mov WORD PTR [Buffer + bp], dx

Let's make sure that we all know that we're placing a 16 bit register into a 16 bit location.  Thankfully it took care of defaulting the segment register to ds.  The miracles of automation.  ;-)

-Gordon

-----Original Message-----
From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Charles Davis
Sent: Wednesday, February 15, 2012 8:06 PM
To: Matthew Huck
Cc: llvmdev
Subject: Re: [LLVMdev] ASM appears to be incorrect from llc

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.

Chip


_______________________________________________
LLVM Developers mailing list
LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list