home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / EMXLIB8F.ZIP / EMX / LIB / STR / BCOPY.S < prev    next >
Encoding:
Text File  |  1993-01-02  |  1.3 KB  |  61 lines

  1. / bcopy.s (emx+gcc) -- Copyright (c) 1990-1993 by Eberhard Mattes
  2.  
  3.         .globl _bcopy
  4.  
  5. / void bcopy (const void *s1, void *s2, size_t n)
  6. / {
  7. /   size_t i;
  8. /   if ((size_t)s1 < (size_t)s2)
  9. /     for (i = n; i > 0; --i)
  10. /       ((char *)s2)[i-1] = ((char *)s1)[i-1];
  11. /   else
  12. /     for (i = 0; i < n; ++i)
  13. /       ((char *)s2)[i] = ((char *)s1)[i];
  14. / }
  15.  
  16. / assumes ds=es!
  17.  
  18.         .text
  19.  
  20.         .align  2, 0x90
  21.  
  22. _bcopy:
  23.         pushl   %esi
  24.         pushl   %edi
  25.         movl    3*4(%esp), %esi         / s1
  26.         movl    4*4(%esp), %edi         / s2
  27.         movl    5*4(%esp), %ecx         / n
  28.         jecxz   9f
  29.         cmpl    %edi, %esi
  30.         jb      2f
  31.         shrl    $2, %ecx
  32.         rep
  33.         movsl
  34.         movl    5*4(%esp), %ecx         / n
  35.         andl    $3, %ecx
  36.         rep
  37.         movsb
  38.         jmp     9f
  39.  
  40.         .align  2, 0x90
  41.  
  42. 2:      addl    %ecx, %esi
  43.         addl    %ecx, %edi
  44.         subl    $4, %esi
  45.         subl    $4, %edi
  46.         std
  47.         shrl    $2, %ecx
  48.         rep
  49.         movsl
  50.         addl    $3, %esi
  51.         addl    $3, %edi
  52.         movl    5*4(%esp), %ecx         / n
  53.         andl    $3, %ecx
  54.         rep
  55.         movsb
  56.         cld
  57. 9:      popl    %edi
  58.         popl    %esi
  59.         ret
  60.