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

  1. / memcount.s (emx+gcc) -- Copyright (c) 1992-1993 by Eberhard Mattes
  2.  
  3.         .globl __memcount
  4.  
  5. / size_t _memcount (const void *mem, int c, size_t n)
  6. /     {
  7. /     size_t i;
  8. /     i = 0;
  9. /     while (n > 0)
  10. /         {
  11. /         if (*mem == c) ++i;
  12. /         ++mem; --n;
  13. /         }
  14. /     return (i);
  15. /     }
  16.  
  17. / assumes ds=es!
  18.  
  19.         .text
  20.  
  21.         .align  2, 0x90
  22.  
  23. __memcount:
  24.         pushl   %edi
  25.         movl    2*4(%esp), %edi         / mem
  26.         movl    3*4(%esp), %eax         / c
  27.         movl    4*4(%esp), %ecx         / n
  28.         xorl    %edx, %edx
  29.         jecxz   9f
  30.         .align  2, 0x90
  31. 1:      repne
  32.         scasb
  33.         jne     9f
  34.         incl    %edx
  35.         orl     %ecx, %ecx
  36.         jne     1b
  37. 9:      movl    %edx, %eax
  38.         popl    %edi
  39.         ret
  40.