【发布时间】:2017-01-12 06:37:46
【问题描述】:
我在cygwin 64位windows下编译这个程序,没有输出,编译正确
#include <unistd.h>
int main(void)
{
const char hello[] = "Hello World!\n";
const size_t hello_size = sizeof(hello);
ssize_t ret;
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"
);
return 0;
}
【问题讨论】:
-
您使用的
syscall适用于 64 位 Linux,而不适用于 Windows/Cygwin -
@MichaelPetch 你应该把这个作为答案。
标签: windows gcc cygwin x86-64 inline-assembly