From what I've read about mov
, it copies the second argument into the first argument. Then, what does this do?
movl 8(%ebp), %edx
It copies whatever is in edx to the first parameter of the function (since an offset of +8 from ebp
is a parameter)?
I feel like what this really means is moving the first parameter into the edx
register, but I read on Wikipedia that it is the other way around?
movl 8(%ebp), %edx
is in "AT&T Syntax"; in this syntax, the source comes first and the destination second. So yes, your belief is correct. Most documentation uses the "Intel Syntax", which has the reverse ordering. This is a source of considerable confusion for people new to x86 assembly.
In Intel Syntax, your instruction would be written:
mov edx, [ebp + 8]
Note the absence of %
before the register names, and the use of square brackets instead of parentheses for the address, and the lack of an l
suffix on the instruction. These are dead giveaways to know which form of assembly you are looking at.