CMP in x86 with parentheses and address

断了今生、忘了曾经 提交于 2019-11-26 18:35:15

问题


I have the following line in x86 Assembly language that I don't know what it does...

cmp %eax,0x80498d4(,%ebx,4)

I know it's comparing the two halves of the statement but I don't know what the address does in it and what the parentheses do either. Some clarification would be much appreciated!


回答1:


In AT&T syntax this form represents

OFFSET(BASE REGISTER, INDEX REGISTER, INDEX SCALE)

so the address represented is the value of BASE REGISTER (if present) + INDEX * SCALE (if present) + OFFSET, so

EBX*4 + 0x80498d4 in your case.




回答2:


That is AT&T syntax:

cmp %eax,0x80498d4(,%ebx,4)

The equivalent in Intel syntax is:

cmp [080498D4H + EBX*4],EAX

It means that it compares the DWORD content at the address [0x80498D4 + 4*EBX] with the content of the EAX register and sets the processor flags as if these two values were subtracted from each other. After that, you can use these flags to do, for instance, a conditional jump.



来源:https://stackoverflow.com/questions/26289472/cmp-in-x86-with-parentheses-and-address

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