"内联汇编程序指令没有唯一的大小" ARM Thumb-2 IAR

时间:2014-05-21 15:58:08

标签: arm inline-assembly iar

我遇到了使用ARM,Cortex-M4的IAR编译器进行内联汇编的问题。这是我的问题的一个简单例子;将以下代码放在一个文件中,比如名为test.c

void irqrestore(int flags)
{
  asm volatile(
      "tst    %0, #1\n"
      "bne    1f\n"
      "cpsie  i\n"
      "1:\n"
      :
      : "r" (flags)
      : "memory");
}

现在尝试使用IAR编译器进行编译:

$ iccarm --thumb test.c

   IAR ANSI C/C++ Compiler V6.40.2.53884/W32 for ARM
   Copyright 1999-2012 IAR Systems AB.

    asm volatile(
    ^
"C:\home\NuttX\nuttx\test.c",6  Error[Og010]: Inline assembler instruction
          does not have a unique size: "        bne    ?1_0"

Errors: 1
Warnings: none

任何想法出了什么问题?如果我改变了" bne 1f \ n"编译1&n",它编译得很好,但我不确定它是否正确。

1 个答案:

答案 0 :(得分:3)

答案:从IAR,我被告知(并且已经确认)以下是正确的语法:

  "bne.n  1f\n"

或者在上下文中:

void irqrestore(int flags)
{
  asm volatile(
      "tst    %0, #1\n"
      "bne.n    1f\n"
      "cpsie  i\n"
      "1:\n"
      :
      : "r" (flags)
      : "memory");
}
相关问题