mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-18 08:06:32 +00:00
🆕 增加了memset函数(汇编实现)
This commit is contained in:
@ -112,3 +112,27 @@ static inline int strlen(char *s)
|
||||
return __res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline void *memset(void *dst, unsigned char C, ul Count)
|
||||
{
|
||||
int d0, d1;
|
||||
unsigned long tmp = C * 0x0101010101010101UL;
|
||||
__asm__ __volatile__("cld \n\t"
|
||||
"rep \n\t"
|
||||
"stosq \n\t"
|
||||
"testb $4, %b3 \n\t"
|
||||
"je 1f \n\t"
|
||||
"stosl \n\t"
|
||||
"1:\ttestb $2, %b3 \n\t"
|
||||
"je 2f\n\t"
|
||||
"stosw \n\t"
|
||||
"2:\ttestb $1, %b3 \n\t"
|
||||
"je 3f \n\t"
|
||||
"stosb \n\t"
|
||||
"3: \n\t"
|
||||
: "=&c"(d0), "=&D"(d1)
|
||||
: "a"(tmp), "q"(Count), "0"(Count / 8), "1"(dst)
|
||||
: "memory");
|
||||
return dst;
|
||||
}
|
||||
|
Reference in New Issue
Block a user