<div>Hi,</div>  It doesn't compile with yasm, or nasm (reports invalid combination of opcode and operands), and <div><br></div><div>mov _x,EAX </div><div><br></div><div>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</div>
<div><br></div><div>mov 0x12341234, EAX </div><div><br></div><div>Now, my asm skills are not that great, so I'm prepared to be told I'm talking bollocks, but that's how I have interpreted everything I've read today.</div>
<div><br></div><div>Cheers</div><div><br></div><div>Matthew</div><div><br></div><div><br><div class="gmail_quote">On Thu, Feb 16, 2012 at 1:11 PM, Eli Friedman <span dir="ltr"><<a href="mailto:eli.friedman@gmail.com">eli.friedman@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Wed, Feb 15, 2012 at 3:36 PM, Matthew Huck <<a href="mailto:matthew.huck@gmail.com">matthew.huck@gmail.com</a>> wrote:<br>

> Hi,<br>
>   I'm trying to compile an intermediate representation file to ASM (intel<br>
> style), and I believe that the resultant ASM is invalid. The IR is:<br>
><br>
> ; ModuleID = 'test.u'<br>
><br>
> %vec2 = type { float, float }<br>
> @t = global %vec2 zeroinitializer<br>
> @x = global i32 0<br>
><br>
> define i32 @main__i__v() nounwind {<br>
> locals:<br>
>   %0 = load float* getelementptr inbounds (%vec2* @t, i32 0, i32 0)<br>
>   %1 = fptosi float %0 to i64<br>
>   %2 = trunc i64 %1 to i32<br>
>   store i32 %2, i32* @x<br>
>   ret i32 0<br>
> }<br>
><br>
><br>
><br>
> Now, I know no memory is allocated for t (ignore that), we'll just expect<br>
> the final program to crash<br>
><br>
> Running this through<br>
> llvm-as.exe test.trunk.ll -f -o test.bc<br>
> and then<br>
> llc -x86-asm-syntax=intel -o test.trunk.S test.bc<br>
><br>
> yields:<br>
><br>
> .def _main__i__v;<br>
> .scl 2;<br>
> .type 32;<br>
> .endef<br>
> .text<br>
> .globl _main__i__v<br>
> .align 16, 0x90<br>
> _main__i__v:                            # @main__i__v<br>
> # BB#0:                                 # %locals<br>
> sub ESP, 20<br>
> movss XMM0, DWORD PTR [_t]<br>
> movss DWORD PTR [ESP + 8], XMM0<br>
> fld DWORD PTR [ESP + 8]<br>
> fisttp QWORD PTR [ESP]<br>
> mov EAX, DWORD PTR [ESP]<br>
> mov _x, EAX<br>
> xor EAX, EAX<br>
> add ESP, 20<br>
> ret<br>
><br>
> .data<br>
> .globl _t                      # @t<br>
> .align 8<br>
> _t:<br>
> .zero 8<br>
><br>
> .globl _x                      # @x<br>
> .align 4<br>
> _x:<br>
> .long 0                       # 0x0<br>
><br>
><br>
><br>
><br>
> Now, the bit I think is wrong is<br>
> mov _x,EAX<br>
><br>
> I think it should be<br>
> mov [_x], eax<br>
><br>
> Thoughts?<br>
<br>
</div></div>What makes you think it's wrong?<br>
<span class="HOEnZb"><font color="#888888"><br>
-Eli<br>
</font></span></blockquote></div><br></div>