Search code examples
cfunctiondebuggingassemblyinline-assembly

C Inline Assembly Unordered?


In C I have:

__asm__ (   
            "mov    $0x2,%rax;"
            "mov    $0x6000dd,%rdi;"
            "mov    $0x0,%rsi;"
            "syscall;"
        );

But when I comppile it in the assembly file I see:

# 12 "mine.cxx" 1
mov    $0x2,%rax;mov    $0x6000dd,%rdi;mov    $0x0,%rsi;syscall;

why they are in 1 line like this How to separate them?


Solution

  • You should add \n to separate lines.

    __asm__ (   
                "mov    $0x2,%rax;\n"
                "mov    $0x6000dd,%rdi;\n"
                "mov    $0x0,%rsi;\n"
                "syscall;\n"
            );