Subversion Repositories Kolibri OS

Rev

Rev 8793 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
  2. #include <string.h>
  3.  
  4. int strncmp(const char* s1, const char* s2, size_t n)
  5. {
  6.     register int __res;
  7.     int d0, d1, d2;
  8.     __asm__ __volatile__(
  9.         "1:\tdecl %3\n\t"
  10.         "js 2f\n\t"
  11.         "lodsb\n\t"
  12.         "scasb\n\t"
  13.         "jne 3f\n\t"
  14.         "testb %%al,%%al\n\t"
  15.         "jne 1b\n"
  16.         "2:\txorl %%eax,%%eax\n\t"
  17.         "jmp 4f\n"
  18.         "3:\tsbbl %%eax,%%eax\n\t"
  19.         "orb $1,%%al\n"
  20.         "4:"
  21.         : "=a"(__res), "=&S"(d0), "=&D"(d1), "=&c"(d2)
  22.         : "1"(s1), "2"(s2), "3"(n));
  23.     return __res;
  24. }
  25.