开发者

How to interpret this assembly?

开发者 https://www.devze.com 2023-02-20 10:32 出处:网络
lea(%edx,%eax,1),%eax Anyone knows the us开发者_如何转开发age of(%edx,%eax,1)?(%edx,%eax,1) is an operand address corresponding to edx+eax*1
lea    (%edx,%eax,1),%eax

Anyone knows the us开发者_如何转开发age of (%edx,%eax,1)?


(%edx,%eax,1) is an operand address corresponding to edx+eax*1

In other words, the instruction being lea, this is simply an add statement equivalent to eax += edx


Take a look at GAS address operand syntax, it seems to be what you're looking for.


The lea instruction (Load Effective Address) is used to calculate an address in the same manner as indirect addressing and to save the resulting address instead of reading what is in the address. In the case of AT&T syntax, (%edx, %eax, 1) means (%edx + %eax * 1). In this case it is, as Laurent G stated, the equivalent of add %edx, %eax. However, by using other factors (a displacement before the parenthesis and a number other than 1) you can do slightly more complicated math.

This type of addressing is typically used to handle arrays, but the lea instruction does not validate that the resulting address is valid, so you can use this as a short circuit way to do a calculation that would take multiple instructions.

0

精彩评论

暂无评论...
验证码 换一张
取 消