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

  1. / memcmp.s (emx+gcc) -- Copyright (c) 1990-1993 by Eberhard Mattes
  2.  
  3.         .globl _memcmp
  4.  
  5. / int memcmp (const void *s1, const void *s2, size_t n)
  6. / {
  7. /   size_t i;
  8. /   int d;
  9. /     
  10. /   for (i = 0; i < n; ++i)
  11. /     {
  12. /       d = (int)((unsigned char *)s1)[i] - (int)((unsigned char *)s2)[i];
  13. /       if (d != 0)
  14. /         return (d);
  15. /     }
  16. /   return (0);
  17. / }
  18.  
  19. / assumes ds=es!
  20.  
  21.         .text
  22.  
  23.         .align  2, 0x90
  24.  
  25. _memcmp:
  26.         pushl   %esi
  27.         pushl   %edi
  28.         movl    3*4(%esp), %edi         / s1
  29.         movl    4*4(%esp), %esi         / s2
  30.         movl    5*4(%esp), %ecx         / n
  31.         xorl    %eax, %eax
  32.         jecxz   1f
  33.         repe
  34.         cmpsb
  35.         movb    -1(%edi), %al
  36.         subb    -1(%esi), %al
  37.         movsbl  %al, %eax
  38. 1:      popl    %edi
  39.         popl    %esi
  40.         ret
  41.