我在一个小程序中包含了一些示例ASM代码来执行测试。C程序中的ASM代码导致分段错误
我的计划是:
#include <stdio.h>
static inline
unsigned char inb (int port) {
unsigned char data;
asm volatile("inb %w1,%0" : "=a" (data) : "d" (port));
return data;
}
int main()
{
printf("hello world %d\n", inb(22));
return 0;
}
当我运行程序时,它在执行ASM代码时崩溃段故障。 有人能告诉我这个小程序有什么问题吗?非常感谢。
这是什么编译器? – Ben 2012-04-26 09:36:31
我在linux上使用gcc – mike 2012-04-26 09:46:17