user16255957
user16255957

Reputation:

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?

Upvotes: 0

Views: 63

Answers (2)

moto
moto

Reputation: 38

Adding \n will be helpful for you.

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

Upvotes: 0

MikeCAT
MikeCAT

Reputation: 75062

You should add \n to separate lines.

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

Upvotes: 1

Related Questions