Back to index

glibc  2.9
memcopy.h
Go to the documentation of this file.
00001 /* memcopy.h -- definitions for memory copy functions.  Pentium version.
00002    Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
00003    Contributed by Torbjorn Granlund (tege@sics.se).
00004    This file is part of the GNU C Library.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 /* Get the i386 definitions.  We will override some of them below.  */
00022 #include <sysdeps/i386/memcopy.h>
00023 
00024 /* Written like this, the Pentium pipeline can execute the loop at a
00025    sustained rate of 2 instructions/clock, or asymptotically 480
00026    Mbytes/second at 60Mhz.  */
00027 
00028 #undef WORD_COPY_FWD
00029 #define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes)            \
00030   do                                                           \
00031     {                                                          \
00032       asm volatile ("subl   $32,%2\n"                          \
00033                   "js              2f\n"                              \
00034                   "movl     0(%0),%%edx\n"       /* alloc dest line */       \
00035                   "1:\n"                                       \
00036                   "movl     28(%0),%%eax\n"      /* alloc dest line */       \
00037                   "subl     $32,%2\n"     /* decr loop count */       \
00038                   "movl     0(%1),%%eax\n"       /* U pipe */         \
00039                   "movl     4(%1),%%edx\n"       /* V pipe */         \
00040                   "movl     %%eax,0(%0)\n"       /* U pipe */         \
00041                   "movl     %%edx,4(%0)\n"       /* V pipe */         \
00042                   "movl     8(%1),%%eax\n"                            \
00043                   "movl     12(%1),%%edx\n"                           \
00044                   "movl     %%eax,8(%0)\n"                            \
00045                   "movl     %%edx,12(%0)\n"                           \
00046                   "movl     16(%1),%%eax\n"                           \
00047                   "movl     20(%1),%%edx\n"                           \
00048                   "movl     %%eax,16(%0)\n"                           \
00049                   "movl     %%edx,20(%0)\n"                           \
00050                   "movl     24(%1),%%eax\n"                           \
00051                   "movl     28(%1),%%edx\n"                           \
00052                   "movl     %%eax,24(%0)\n"                           \
00053                   "movl     %%edx,28(%0)\n"                           \
00054                   "leal     32(%1),%1\n"  /* update src ptr */ \
00055                   "leal     32(%0),%0\n"  /* update dst ptr */ \
00056                   "jns      1b\n"                              \
00057                   "2: addl  $32,%2" :                          \
00058                   "=r" (dst_bp), "=r" (src_bp), "=r" (nbytes_left) :  \
00059                   "0" (dst_bp), "1" (src_bp), "2" (nbytes) :          \
00060                   "ax", "dx");                                 \
00061     } while (0)
00062 
00063 #undef WORD_COPY_BWD
00064 #define WORD_COPY_BWD(dst_ep, src_ep, nbytes_left, nbytes)            \
00065   do                                                           \
00066     {                                                          \
00067       asm volatile ("subl   $32,%2\n"                          \
00068                   "js              2f\n"                              \
00069                   "movl     -4(%0),%%edx\n"                           \
00070                   "1:\n"                                       \
00071                   "movl     -32(%0),%%eax\n"                   \
00072                   "subl     $32,%2\n"                          \
00073                   "movl     -4(%1),%%eax\n"                           \
00074                   "movl     -8(%1),%%edx\n"                           \
00075                   "movl     %%eax,-4(%0)\n"                           \
00076                   "movl     %%edx,-8(%0)\n"                           \
00077                   "movl     -12(%1),%%eax\n"                   \
00078                   "movl     -16(%1),%%edx\n"                   \
00079                   "movl     %%eax,-12(%0)\n"                   \
00080                   "movl     %%edx,-16(%0)\n"                   \
00081                   "movl     -20(%1),%%eax\n"                   \
00082                   "movl     -24(%1),%%edx\n"                   \
00083                   "movl     %%eax,-20(%0)\n"                   \
00084                   "movl     %%edx,-24(%0)\n"                   \
00085                   "movl     -28(%1),%%eax\n"                   \
00086                   "movl     -32(%1),%%edx\n"                   \
00087                   "movl     %%eax,-28(%0)\n"                   \
00088                   "movl     %%edx,-32(%0)\n"                   \
00089                   "leal     -32(%1),%1\n"                      \
00090                   "leal     -32(%0),%0\n"                      \
00091                   "jns      1b\n"                              \
00092                   "2: addl  $32,%2" :                          \
00093                   "=r" (dst_ep), "=r" (src_ep), "=r" (nbytes_left) :  \
00094                   "0" (dst_ep), "1" (src_ep), "2" (nbytes) :          \
00095                   "ax", "dx");                                 \
00096     } while (0)