[cfe-dev] assembly syntax

Reid Kleckner rnk at google.com
Sun Aug 10 13:07:15 PDT 2014


The assembly support in LLVM is all oriented around gas-compatibility. We
have some support for Intel syntax assembly, but even in that area, we can
only parse gas style directives.


On Sun, Aug 10, 2014 at 6:46 AM, Thiago Farina <tfransosi at gmail.com> wrote:

> On Sun, Aug 10, 2014 at 9:21 AM, Anton Korobeynikov
> <anton at korobeynikov.info> wrote:
> >> How can I change the syntax used by clang, so yasm accepts it without
> >> having to pass -p gas?
> > No way. yasm uses nasm syntax by default.
> >
> So the solution seems to be use 'as'.
>
> This worked for me:
>
> $ clang -S -O0 -masm=intel add.c -o add-intel.s
> $ cat add-intel.s
> .globl add
> add:
> push rbp
> mov rbp, rsp
> mov dword ptr [rbp - 4], edi
> mov dword ptr [rbp - 8], esi
> mov esi, dword ptr [rbp - 4]
> add esi, dword ptr [rbp - 8]
> mov eax, esi
> pop rbp
> ret
>
> $ as -mnaked-reg -msyntax=intel add-intel.s -o add_def.o
>
> Simpler, this also worked:
>
> $ clang -S -O0 add.c -o add-att.s
> $ cat add-att.s
> .globl add
> add:
> pushq %rbp
> movq %rsp, %rbp
> movl %edi, -4(%rbp)
> movl %esi, -8(%rbp)
> movl -4(%rbp), %esi
> addl -8(%rbp), %esi
> movl %esi, %eax
> popq %rbp
> retq
> $ as add-att.s -o add_def.o
>
> --
> Thiago
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140810/d27650d0/attachment.html>


More information about the cfe-dev mailing list