flat assembler
Message board for the users of flat assembler.

Index > Main > ESP and EBP addressing question

Author
Thread Post new topic Reply to topic
IronFelix



Joined: 09 Dec 2004
Posts: 141
Location: Russia, Murmansk region
IronFelix 13 Jan 2009, 09:26
Hi all!
The question is - is there any difference in takts with using ESP or EBP addressing.
Some example:
Code:
 mov eax,[ebp + 8]    

and
Code:
 mov eax,[esp + 4]    

Second one is 1 byte longer, but what about takts? The question comes from fact, that some functions can avoid using stack frames by using ESP instead of EBP, beacause push ebp/mov ebp,esp/leave = 4 bytes, and if leave replaced by mov esp,ebp/pop ebp - 6 bytes. As a result - smaller size.
Please, tell your opinion.
Thanks.

_________________
Flat Assembler is the best!
Post 13 Jan 2009, 09:26
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 13 Jan 2009, 09:30
Regardless of what they may tell you "size doesn't matter".

But, seriously, yes, you can use ESP addressing. But it has some problems also. I would recommend that you limit use to leaf procedures only that don't use push/pop inside.

Search this very forum for some other discussions about using ESP to access stack parameters.
Post 13 Jan 2009, 09:30
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4020
Location: vpcmpistri
bitRAKE 13 Jan 2009, 16:16
The instruction dispatcher is limited in the bytes and instructions processed. So, size will have an impact in optimization, but having another register usually proves more advantageous. The stack frame is only needed in situations of local dynamic allocation.

x64 is another matter, imho. The calling convension requires some stack massaging and there are plenty of registers.
Post 13 Jan 2009, 16:16
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 13 Jan 2009, 16:38
I suggest you to google and read some links on "stack frame", there is lot of it online and explains what you seek to understand.
Post 13 Jan 2009, 16:38
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
IronFelix



Joined: 09 Dec 2004
Posts: 141
Location: Russia, Murmansk region
IronFelix 13 Jan 2009, 17:20
Thanks a lot. Thats quite enough for me to understand.
Post 13 Jan 2009, 17:20
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.