strstr.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:1k
- #include <linux/string.h>
- char * strstr(const char * cs,const char * ct)
- {
- int d0, d1;
- register char * __res;
- __asm__ __volatile__(
- "movl %6,%%edint"
- "repnent"
- "scasbnt"
- "notl %%ecxnt"
- "decl %%ecxnt" /* NOTE! This also sets Z if searchstring='' */
- "movl %%ecx,%%edxn"
- "1:tmovl %6,%%edint"
- "movl %%esi,%%eaxnt"
- "movl %%edx,%%ecxnt"
- "repent"
- "cmpsbnt"
- "je 2fnt" /* also works for empty string, see above */
- "xchgl %%eax,%%esint"
- "incl %%esint"
- "cmpb $0,-1(%%eax)nt"
- "jne 1bnt"
- "xorl %%eax,%%eaxnt"
- "2:"
- :"=a" (__res), "=&c" (d0), "=&S" (d1)
- :"0" (0), "1" (0xffffffff), "2" (cs), "g" (ct)
- :"dx", "di");
- return __res;
- }