Asm code containing% 0, what does this mean?

My knowledge of asm is so limited, I need to know the following codes:

movl %%esp %0

Does it provide a %0register, memory address or something else? What does it mean %0?

+3
source share
1 answer

It is an I / O operand. It allows you to use your C variables in your assembler. This page contains some nice examples.

%0- this is only the first I / O operand defined in your code. In practice, it can be a stack variable, a heap variable, or a register, depending on how the compiler generated the compiler code.

For instance:

int a=10, b;
asm ("movl %1, %%eax; 
      movl %%eax, %0;"
     :"=r"(b)        /* output */
     :"r"(a)         /* input */
     :"%eax"         /* clobbered register */
     );

%0in this case b, a %1- a.

+5
source

All Articles