LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 756|回复: 2

大家帮我看看这段汇编内联代码,我怎么老编译不过.

[复制链接]
发表于 2005-9-1 14:29:20 | 显示全部楼层 |阅读模式
#include <stdio.h>

int main(void) {
        int foo=10,bar=15;
       
        __asm__ __volatile__ ("addl         %%ebxx,%%eax"
                : "=eax"(foo)                 // ouput
                : "eax"(foo), "ebx"(bar)// input
                : "eax"                        // modify
        );
        printf("foo+bar=%d\n", foo);
        return 0;
}

出错提示为
asmasm.c:6: error: impossible constraint in `asm'
请问怎么解决亚????? :ask  :ask  :ask  :ask  :ask  :ask
发表于 2005-9-1 15:36:35 | 显示全部楼层
__volatile__ --> volatile
回复 支持 反对

使用道具 举报

发表于 2005-9-1 22:52:08 | 显示全部楼层
0x4012ba <main+42>:     movl   $0xa,0xfffffffc(%ebp)
0x4012c1 <main+49>:     movl   $0xf,0xfffffff8(%ebp)
0x4012c8 <main+56>:     mov    0xfffffff8(%ebp),%edx
0x4012cb <main+59>:     lea    0xfffffffc(%ebp),%eax
0x4012ce <main+62>:     add    %edx,(%eax)
0x4012d0 <main+64>:     mov    0xfffffffc(%ebp),%eax
0x4012d3 <main+67>:     mov    %eax,0x4(%esp,1)
0x4012d7 <main+71>:     movl   $0x403000,(%esp,1)
0x4012de <main+78>:     call   0x401820 <printf>
0x4012e3 <main+83>:     mov    $0x0,%eax
0x4012e8 <main+88>:     leave  
0x4012e9 <main+89>:     ret   

参考参考。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表