Here is a snippet of assembly code
in AT&T Syntax
.
int foo_array[64*1024] __attribute__ ((aligned (8192)));
void
foo()
{
__asm__("movl %0,%%eax"::"r"(&foo_array));
I understood that movl
copies the data from source operand to destination operand. that is, in my case, it is moving 0 to eax
.. This is what I have understood from this link - slide 2
However, I dont understand the rest of it. Can someone please explain it so me.
You should read up on GCC inline assembly constraints .
In short, what that ::"r"(&foo_array)
says is that you want one input for your assembly code, that the input should be placed in a register, and that its value should be the address of foo_array
.
The %0
in the code is substituted with that input, so the code places the address of foo_array
in eax
.
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.