Re: syntax of asm

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 14, 2021 at 5:27 AM Peng Yu via Gcc-help
<gcc-help@xxxxxxxxxxx> wrote:
>
> https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html
>
> I see things like "=r", "r", "=a", "=X" and "cc". I don't quite
it's constraints for asm operands,

"r" means
 A register operand is allowed provided that it is in a general register.

"=" is an operand modifier which
Means that this operand is written to by this instruction: the
previous value is discarded and replaced by new data.

Refer to https://gcc.gnu.org/onlinedocs/gcc/Constraints.html#Constraints


> understand what they mean. Could anybody help me understand them?
>
> #include <stdio.h>
>
> int main() {
>         int src = 1;
>         int dst;
>
>         asm ("mov %1, %0\n\t"
>                         "add $1, %0"
>                         : "=r" (dst)
>                         : "r" (src));
>         printf("%d\n", dst);
>         return 0;
> }
>
> --
> Regards,
> Peng



-- 
BR,
Hongtao



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux