arm Inline assembly in gcc

孤人 提交于 2019-12-04 09:56:16

The problem would seem to be that you specify w0 as an INPUT operand, when it actually should be a read-write OUTPUT operand, like sum. In addition, you need to specify that it clobbers v1 and v2 as you use those registers (otherwise, gcc might put some other var into these regs and expect them to be preserved.)

So you should have:

asm volatile (
      "ldmia %[w0]!, {v1, v2}\n\t"
      "adds %[sum], %[sum], v1\n\t"
      "adcs %[sum], %[sum], v2\n\t"
      "adcs %[sum], %[sum], #0"
      : [sum] "+r" (sum) , [w0] "+r" (w0) : : "v1", "v2"
      );

that is, two read-write input/output operands, no exclusively input operands, and two register clobbers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!