免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2556 | 回复: 0
打印 上一主题 下一主题

[C] c调用汇编编译错误 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2017-11-22 17:58 |只看该作者 |倒序浏览
c调用汇编,编译出错,汇编看不懂呀,有哪位大神可以帮忙看一下,谢谢啦!
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>

static inline unsigned long long m_atomic64_add_return(long long int *v, long long int inc)
{
    long ret;

    asm volatile(
            "\n\tlwsync\n"
            "1: ldarx %[ret],0,%[cnt]\n"
            "add %[ret],%[inc],%[ret]\n"
            "stdcx. %[ret],0,%[cnt]\n"
            "bne- 1b\n"
            "isync\n"
            : [ret] "=&r" (ret)
            : [inc] "r" (inc), [cnt] "r" (v)
            : "cc", "memory";

    return ret;
}

void main()
{
    long long int x = 5;
    long long int y = m_atomic64_add_return(&x, 1);
    printf("x = %lld, y = %lld\n", x, y);
}


编译错误如下:
atomic.c: Assembler messages:
atomic.c:11: Error: no such instruction: `lwsync'
atomic.c:12: Error: no such instruction: `ldarx %rax,0,%rcx'
atomic.c:13: Error: number of operands mismatch for `add'
atomic.c:14: Error: no such instruction: `stdcx. %rax,0,%rcx'
atomic.c:15: Error: no such instruction: `bne- 1b'
atomic.c:16: Error: no such instruction: `isync'
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP