'문자열길이계산함수'에 해당되는 글 1건

방법은 많겠지만 가장 무난한 방법이 scas 를 이용하는게 아닐까 생각합니다.

코드:

int mzstring_Length(const char *s_String)
{
#if DEF_USE_ASM == (1)
int s_Size;
__asm__ volatile(기
  "orl %1, %1\n\t"
  "jz 0f\n\t"
  "cld\n\t"
  "repnz scasb %%es:(%1), %%al\n\t"
  "notl %2\n\t"
  "subl %3, %2\n\t"
  "decl %2\n\t"
  "0:\n\t"
  : "=a"(s_Size)
  : "D"(s_String), "a"(0), "c"(0xffffffff)
);
return(s_Size);
#else
if(s_String == (const char *)0)return(0);
return((int)strlen(s_String));
#endif
}
크리에이티브 커먼즈 라이센스
Creative Commons License
Posted by minzkn

트랙백 주소 :: http://blog.minzkn.com/trackback/40

댓글을 달아 주세요