mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-08 18:26:48 +00:00
🆕 增加strcmp
This commit is contained in:
parent
9b382dab60
commit
2467367e05
@ -231,6 +231,38 @@ void *memcpy(void *dst, void *src, long Num)
|
||||
: "memory");
|
||||
return dst;
|
||||
}
|
||||
|
||||
/*
|
||||
比较字符串 FirstPart and SecondPart
|
||||
FirstPart = SecondPart => 0
|
||||
FirstPart > SecondPart => 1
|
||||
FirstPart < SecondPart => -1
|
||||
*/
|
||||
|
||||
int strcmp(char * FirstPart,char * SecondPart)
|
||||
{
|
||||
register int __res;
|
||||
__asm__ __volatile__ ( "cld \n\t"
|
||||
"1: \n\t"
|
||||
"lodsb \n\t"
|
||||
"scasb \n\t"
|
||||
"jne 2f \n\t"
|
||||
"testb %%al, %%al \n\t"
|
||||
"jne 1b \n\t"
|
||||
"xorl %%eax, %%eax \n\t"
|
||||
"jmp 3f \n\t"
|
||||
"2: \n\t"
|
||||
"movl $1, %%eax \n\t"
|
||||
"jl 3f \n\t"
|
||||
"negl %%eax \n\t"
|
||||
"3: \n\t"
|
||||
:"=a"(__res)
|
||||
:"D"(FirstPart),"S"(SecondPart)
|
||||
:
|
||||
);
|
||||
return __res;
|
||||
}
|
||||
|
||||
void *memset_c(void *dst, unsigned char c, ul n)
|
||||
{
|
||||
unsigned char *s = (unsigned char *)dst;
|
||||
|
Loading…
x
Reference in New Issue
Block a user