简体   繁体   中英

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. 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. 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. Thus, you should use early-clobber modifier on those two output operands, such as "=&r"(mullo2)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM