开发者

What is the lea instruction before a method call doing?

开发者 https://www.devze.com 2023-03-24 22:19 出处:网络
In looking at my disassembled code I see a lot of the following: 00B442E9push4 00B442EBpush3 00B442EDl开发者_如何学Ceaecx,[ebp-24h]

In looking at my disassembled code I see a lot of the following:

00B442E9  push        4  
00B442EB  push        3  
00B442ED  l开发者_如何学Cea         ecx,[ebp-24h]  
00B442F0  call        Foo::Bar (0B41127h)  

I understand pushing the parameters before the call, but what's the lea doing here?


In the thiscall calling convention used by Visual C++ for x86, the this pointer is passed in the ecx register. This lea instruction copies the this pointer into the ecx register before calling the member function.

You can read all about the lea instruction in the Stack Overflow question "What's the purpose of the LEA instruction?"


I think it's just an optimized form of

mov ecx, ebp
sub ecx, 24h
0

精彩评论

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