[cfe-dev] assembly syntax

Thiago Farina tfransosi at gmail.com
Sat Aug 9 21:31:29 PDT 2014


Hi clangers,

I'm not sure but looks like the default syntax used by clang when it
outputs assembly is AT&T. Is that right?

For this simple program:

$ cat add.c
int add(int a, int b) {
  return a + b;
}

$ clang -S add.c
$ cat add.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

But yasm does not seem to like that syntax. What is the default syntax
used by yasm? Sorry for the ignorance here, I swear I tried to find
this info in my preferred search engine.

$ cp add.s add.asm
$ yasm -f elf64 add.asm -o add.o
add.asm:1: warning: no non-local label before `.globl'
add.asm:2: error: unexpected `:' after instruction
add.asm:3: error: instruction expected after label
add.asm:4: error: unexpected `%' after instruction
add.asm:5: error: instruction expected after label
add.asm:6: error: instruction expected after label
add.asm:7: error: instruction expected after label
add.asm:8: error: instruction expected after label
add.asm:9: error: instruction expected after label
add.asm:10: error: instruction expected after label

If I pass -p gas it works:

$ yasm -f elf64 -p gas add.asm -o add_def.o
# works!

How can I change the syntax used by clang, so yasm accepts it without
having to pass -p gas?

$ uname -p
x86_64

Linux Ubuntu 12.04 in case someone wants to ask.

--
Thiago



More information about the cfe-dev mailing list