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

  1. / memdif.s (emx+gcc) -- Copyright (c) 1993 by Eberhard Mattes
  2.  
  3.         .globl __memdif
  4.  
  5. / size_t _memdif (const void *mem1, const void *mem2, size_t n)
  6. / {
  7. /   size_t i;
  8. /     
  9. /   for (i = 0; i < n; ++i)
  10. /     {
  11. /       if (((char *)mem1)[i] != ((char *)mem2)[i])
  12. /         return (i);
  13. /     }
  14. /   return (_MEMDIF_EQ);
  15. / }
  16.  
  17. / assumes ds=es!
  18.  
  19.         .text
  20.  
  21.         .align  2, 0x90
  22.  
  23. __memdif:
  24.         pushl   %esi
  25.         pushl   %edi
  26.         movl    3*4(%esp), %edi         / mem1
  27.         movl    4*4(%esp), %esi         / mem2
  28.         movl    5*4(%esp), %ecx         / n
  29.         xorl    %eax, %eax
  30.         jecxz   1f
  31.         repe
  32.         cmpsb
  33.         je      1f
  34.         decl    %edi
  35.         subl    3*4(%esp), %edi
  36.         movl    %edi, %eax
  37.         jmp     9f
  38.  
  39. 1:      movl    $-1, %eax               / _MEMDIF_EQ
  40. 9:      popl    %edi
  41.         popl    %esi
  42.         ret
  43.