gcc - GNU assembly Inline: what do %1 and %0 mean? -
i new gnu assembly inlining, have read multiple write ups still not understand going on. understanding:
movl %eax, %ebx\n\t
move whatever in %eax
ebx
, not add contents each other
addl %eax, %ebx\n\t
add contents of %eax
ebx
, keep @ right register
addl %1, %0\n\t
confused, adding 1 , 0? why need have %0
there?
the whole asm inline block looks like:
asm [volatile] ( assemblertemplate : outputoperands [ : inputoperands [ : clobbers ] ])
or
asm [volatile] ( assemblertemplate : outputoperands)
in assemblertemplate assembly code, , in output/inputoperands, can pass variable between c , asm.
then in asm, %0 refers first variable passed outputoperand or inputoperand, %1 second, etc.
example:
int32_t = 10; int32_t b; asm volatile ("movl %1, %0" : "=r"(b) : "r"(a) : );
this asm code equivalent "b = a;"
a more detailed explanation here: https://gcc.gnu.org/onlinedocs/gcc/extended-asm.html
Comments
Post a Comment