DEV Community

Cover image for Running inline assembly code in C
Talles L
Talles L

Posted on

Running inline assembly code in C

#include <stdio.h>

void main() {
    const char *hello = "Hello, World!\n";

    asm(
        "mov $1, %%rax\n"
        "mov $1, %%rdi\n"
        "mov %0, %%rsi\n"
        "mov $14, %%rdx\n"
        "syscall\n"
        :
        : "r"(hello)
        : "%rax", "%rdi", "%rsi", "%rdx"
    );
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)