用汇编语言比较两个字符串

来源:百度知道 编辑:UC知道 时间:2024/05/15 15:14:00
比较两个字符串,找出其中第一个不相等字符的地址。如果两字符串全部相同则转到ALL_MATCH进行处理。这两个字符串长度均为20,首地址分别为
STRING1和STRING2。请简要注释!

做出来加20分!还有万分感谢!!!
用汇编语言!!!!!!!!!!!!!!!

参考:

/* Search N bytes of S for C. */
#define _HAVE_STRING_ARCH_memchr 1
#ifndef _FORCE_INLINES
__STRING_INLINE int
strcmp (__const char *__s1, __const char *__s2)
{
char *__p1, *__p2;
int __ret;

__p1 = (char *) __s1;
__p2 = (char *) __s2;
__asm__ __volatile__ (" slr 0,0\n"
"0: clst %1,%2\n"
" jo 0b\n"
" ipm %0\n"
" srl %0,28"
: "=d" (__ret), "+&a" (__p1), "+&a" (__p2) :
: "cc", "0" );
__ret = (__ret == 0) ? 0 : (__ret == 1) ? -1 : 1;
return __ret;
}
#endif

glibc-2.2.4/sysdeps/s390/bits/string.h from
http://ftp.gnu.org/gnu/glibc/glibc-2.2.4.tar.gz