Howdy, Stranger!


Sign In with Facebook Sign In with Google Sign In with OpenID




AtexAtex Posts: 268Member
Looking purely at speed ( clock ticks ) which code executes faster ?[code][color=Blue]mov eax,gs:[edi+4]


add edi,4
mov eax,gs:[edi][/color][/code]


  • anthrax11anthrax11 Posts: 511Member
    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.
Sign In or Register to comment.