x86 Assembly

Moderators: None (Apply to moderate this forum)
Number of threads: 4556
Number of posts: 16011

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Optimization Posted by Atex on 7 Apr 2009 at 8:38 AM
Looking purely at speed ( clock ticks ) which code executes faster ?
mov eax,gs:[edi+4]   

-or-

add edi,4
mov eax,gs:[edi]

Report
Re: Optimization Posted by anthrax11 on 7 Apr 2009 at 12:29 PM
I'd say the second one is slower, because the addition is a read-modify-write operation, so edi will be tied up for several uops. This is bad, since the second instruction depends on edi. Also, the first one takes less space, so it fits into cache better.

However, the second code may improve performance if you insert some other instruction between add and mov. If that instruction doesn't use edi, then it could be fed into another pipeline and executed in parallel.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.