Reputation: 2456
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.
Upvotes: 0
Views: 107
Reputation: 58497
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
.
Upvotes: 3