[Bug c/63318] Hello World C program using inline assembly to invoke write(2) on amd64 Linux fails to print Hello World

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Sep 20 19:34:00 GMT 2014


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63318

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
    asm volatile
    (
        "movl $1, %%eax\n\t"
        "movl $1, %%edi\n\t"
        "movq %1, %%rsi\n\t"
        "movl %2, %%edx\n\t"
        "syscall"
        : "=a"(ret)
        : "g"(hello), "g"(hello_size), "m"(*string)
        : "%rdi", "%rsi", "%rdx", "%rcx", "%r11"
    );

Or
    asm volatile
    (
        "movl $1, %%eax\n\t"
        "movl $1, %%edi\n\t"
        "movq %1, %%rsi\n\t"
        "movl %2, %%edx\n\t"
        "syscall"
        : "=a"(ret)
        : "g"(hello), "g"(hello_size)
        : "%rdi", "%rsi", "%rdx", "%rcx", "%r11", "memory"
    );



More information about the Gcc-bugs mailing list