简体   繁体   English

汇编cmp指令

[英]Assembly cmp instruction

The following cmp instruction is confusing me: 以下cmp指令使我感到困惑:

%eax,0x18(%esp,%ebx,4) %eax中,为0x18(%ESP,%EB​​X,4)

I know it's comparing arg1 to arg2, but what exactly is going on in arg2 with the stuff in parenthesis? 我知道它正在将arg1与arg2进行比较,但是arg2和括号中的内容到底发生了什么?

Thanks 谢谢

It calculates the address of a memory location based on the values of esp and ebx. 它根据esp和ebx的值计算内存位置的地址。 You didn't specify the assembly notation used, so I can just guess it's esp + 4*ebx + 0x18. 您没有指定使用的汇编符号,所以我只能猜测它是esp + 4 * ebx + 0x18。

That's an effective address in at&t syntax. 这是at&t语法中的有效地址。 The general form is displacement(base, index, scale) where displacement is a number (address), base and index are registers, and scale is a factor of 1 , 2 , 4 or 8 . 一般形式是displacement(base, index, scale) ,其中displacement是一个数字(地址), baseindex是寄存器,和scale是一个因子1248 The resulting address is calculated as displacement + base + index * scale . 计算得出的地址为displacement + base + index * scale Components may be omitted. 组件可以省略。

By the way, you can switch gnu tools into intel syntax mode if you like that better. 顺便说一句,如果您愿意,可以将gnu工具切换到intel语法模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM