Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. char *strstr(const char *cs, const char *ct)
  3. {
  4.     int d0, d1;
  5.     register char *__res;
  6.     __asm__ __volatile__(
  7.     "movl %6,%%edi\n\t"
  8.     "repne\n\t"
  9.     "scasb\n\t"
  10.     "notl %%ecx\n\t"
  11.     "decl %%ecx\n\t"        /* NOTE! This also sets Z if searchstring='' */
  12.     "movl %%ecx,%%edx\n"
  13.     "1:\tmovl %6,%%edi\n\t"
  14.     "movl %%esi,%%eax\n\t"
  15.     "movl %%edx,%%ecx\n\t"
  16.     "repe\n\t"
  17.     "cmpsb\n\t"
  18.     "je 2f\n\t"             /* also works for empty string, see above */
  19.     "xchgl %%eax,%%esi\n\t"
  20.     "incl %%esi\n\t"
  21.     "cmpb $0,-1(%%eax)\n\t"
  22.     "jne 1b\n\t"
  23.     "xorl %%eax,%%eax\n\t"
  24.     "2:"
  25.     : "=a" (__res), "=&c" (d0), "=&S" (d1)
  26.     : "0" (0), "1" (0xffffffff), "2" (cs), "g" (ct)
  27.     : "dx", "di");
  28.     return __res;
  29. }
  30.  
  31.