www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/03/22/04:56:57

Subject: Re: A quick way to copy n bytes
To: turnbull AT shako DOT sk DOT tsukuba DOT ac DOT jp (Stephen Turnbull)
Date: Wed, 22 Mar 1995 09:05:48 +0100 (MET)
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu (user alias)
From: Christoph Kukulies <kuku AT gilberto DOT physik DOT rwth-aachen DOT de>
Reply-To: Christoph Kukulies <kuku AT gilberto DOT physik DOT rwth-aachen DOT de>

> 
>    From: "A.Appleyard" <A DOT APPLEYARD AT fs2 DOT mt DOT umist DOT ac DOT uk>
> 
>    /*-----*//* fast move s[0:n-1]=t[0:n-1] */
>    void str_cpy(void*s,void*t,int n){
>    asm("pushl %esi"); asm("pushl %edi"); asm("cld");
>    asm("movl 8(%ebp),%edi"); asm("movl 12(%ebp),%esi");
>    asm("movl 16(%ebp),%ecx"); asm("rep"); asm("movsb"); asm("popl %edi");
>    asm("popl %esi");}
>    /*-----*/
>    /* This has given me good service and should run a bit quicker than a C */
>    /* version, as it uses the `rep' repeat instruction */
> 
> This looks remarkably like memcpy.s in the standard DJGPP library, but
> it doesn't take advantage of a couple of optimizations included in the
> DJGPP distribution version.  Why are we reinventing the wheel?

And could be written much cleaner :
void
str_cpy(void*s,void*t,int n) {
 asm("pushl %esi
      pushl %edi
      cld
      movl 8(%ebp),%edi
      movl 12(%ebp),%esi
      movl 16(%ebp),%ecx
      rep
      movsb
      popl %edi
      popl %esi");
}

> 
> -- 
> Stephen Turnbull  /  Yaseppochi-gumi  /  <turnbull AT shako DOT sk DOT tsukuba DOT ac DOT jp>
> http://turnbull.sk.tsukuba.ac.jp/      anon FTP: turnbull.sk.tsukuba.ac.jp
> Check out Kansai-WWW, too ------------> http://pclsp2.kuicr.kyoto-u.ac.jp/
> 

--Chris Christoph P. U. Kukulies kuku AT gil DOT physik DOT rwth-aachen DOT de
FreeBSD blues 2.1.0-Development FreeBSD 2.1.0-Development #0: Sun Mar 19
17:20:44  1995     root AT blues:/usr/src/sys/compile/BLUESGUS  i386

- Raw text -


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