打印
[AVR单片机]

求助:GCC内嵌汇编警告

[复制链接]
1685|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
ATmega16|  楼主 | 2007-7-11 21:53 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

16位有符号数除法

div16_t divs16_s16(int16_t val0,int16_t val1)
{
div16_t result;
asm(        

        "movw    r24,%A1"            " "
        "movw    r22,%A2"            " "
        "mov    r2,r25"                " "
        "sbrc    r2,7"                " "
        "rcall    1f"                    " "
        "mov    r3,r23"                " "
        "sbrc    r3,7"                " "
        "rcall    2f"                    " "
        "call    __udivmodhi4"        " "
        "sbrc    r2,7"                " "
        "rcall    1f"                    " "
        "eor    r3,r2"                " "
        "sbrc    r3,7"                " "
        "rcall    2f"                    " "
        "rjmp    3f"                    " "    

"1:"    "com    r25"                " "
        "neg    r24"                " "
        "sbci    r25,0xff"            " "
        "ret"                        " "

"2:"    "com    r23"                " "
        "neg    r22"                " "
        "sbci    r23,0xff"            " "
        "ret"                        " "    

"3:"    "movw    %A0,r22"            " "
        "movw    %C0,r24"            " "

:"r="(result)
:"r"(val0),"r"(val1)
:"r2","r3","r22","r23","r24","r25"
    );

    return result;
}

总是产生警告,求高手指点。

相关帖子

沙发
John_Lee| | 2007-7-12 10:37 | 只看该作者

警告已经说得很明白了

1

使用特权

评论回复
板凳
ATmega16|  楼主 | 2007-7-12 16:18 | 只看该作者

低级失误

不是"r=",是"=r"

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

109

主题

229

帖子

0

粉丝