mov instruction in x86 assembly

大城市里の小女人 提交于 2019-12-09 02:37:59

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/5890724/mov-instruction-in-x86-assembly

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!