[英]Can I use output operand as an input inside ARM inline assembly?
I have an inline assembly code with two small lines. 我有一个带有两行小的内联汇编代码。 I want to use the output operand which retrieved from first line as an input operand in my second line.
我想使用从第一行检索的输出操作数作为第二行的输入操作数。 I was wondering if it is possible or not.
我想知道是否有可能。 Here is my code:
这是我的代码:
asm volatile( "umull %0, %1, %3, %4; \n\t"
"adds %2, %5, %0; \n\t"
:"=r"(mullo2), "=r"(mulhi2), "=r"(temp)
:"r"(A), "r"(B->uint32[6]), "r"(mulhi1)
:"cc");
As you can see here, I need mullo2
operand to be the one of my input in the second instruction. 如您在这里看到的,我需要
mullo2
操作数成为第二条指令中的输入之一。 Compiler doesn't complain about it, but somehow I don't get correct results. 编译器没有抱怨,但是以某种方式我没有得到正确的结果。
The output operands might be allocated to the same registers as inputs, unless you use early-clobber. 除非您使用Early-Clobber,否则输出操作数可能会分配给与输入相同的寄存器。 In your case
%5
may be the same as %0
or %1
and since those are destroyed by the first instruction, your second one would use wrong value. 在您的情况下,
%5
可能与%0
或%1
相同,并且由于它们被第一条指令销毁,因此您的第二条指令将使用错误的值。 Thus, you should use early-clobber modifier on those two output operands, such as "=&r"(mullo2)
因此,您应该在这两个输出操作数上使用Early-Clobber修饰符,例如
"=&r"(mullo2)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.