- 论坛徽章:
- 0
|
程序如下:
#include<stdio.h>
int strCmp(char *cs,char *ct,int count)
{
int _res;
_asm_("cld\n"
"1:\n"
"decl %3\n"
"js 2f\n"
"lodsb\n"
"scasb\n"
"jne 3f\n"
"testb %%al,%%al\n"
"jne 1b\n"
"2:\n"
"xorl %%eax,%%eax\n"
"jmp 4f\n"
"3:\n"
"movl $1,%%eax\n"
"jl 4f\n"
"negl %%eax\n"
"4:"
:"=a" (_res) :"D"(cs),"S"(ct),"c"(count) :"si","di","cx");
return _res;
}
main()
{
char*p="1234";
char*q="4321";
char*r="1234";
printf("input:%s,%s.we get output:%d\n",p,q,strCmp(p,q,4));
printf("input:%s,%s.we get output:%d\n",q,p,strCmp(q,p,4));
printf("input:%s,%s.we get output:%d\n",p,r,strCmp(p,r,4));
return 0;
}
错误如下:
zh.c: 在函数‘strCmp’中:
zh.c:22:13: 错误: expected ‘)’ before ‘:’ token
请高手指教! |
|