Mail Archives: djgpp/1997/04/17/13:38:30
Jeff Weeks <pweeks AT execulink DOT com> wrote:
>Which is faster?
>rep stosd or
>rep movsd
>I've seen a few people currently using the later, which leads me to
>believe that it's faster, but my TASM book says that the former is
>faster.
>Please enlighten me, which is faster, and why? They both perform
>essentially the same function right?
No, they do different things. rep stosd performs the rough equivalent
of (in old, non AT&T asm.. sorry guys, haven't done any djgpp asm yet
:( )
@loop_top:
mov [es:edi],eax
inc edi
loop @loop_top
whereas rep movsd does:
@loop_top:
mov eax,[ds:esi]
mov [es:edi],eax
inc esi
inc edi
loop @loop_top
Which is faster of the two? stosd, since it only STOres the contents
of eax (requiring only a write to memory) whereas movsw MOVes a block
of memory.
... BUT, it is actually faster on a 486 to unroll the loop as above,
than to use the string instructions, if I am not mistaken.
- Calvin -
- Raw text -