delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/17/13:38:30

From: frenchc AT cadvision DOT com (Calvin French)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: What is faster STOSD or MOVSD
Date: Tue, 15 Apr 1997 10:54:48 GMT
Organization: CADVision Development Corp.
Lines: 41
Message-ID: <5j16ek$lha@elmo.cadvision.com>
References: <5iu501$rqj AT nr1 DOT toronto DOT istar DOT net>
NNTP-Posting-Host: ts5ip175.cadvision.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019