閱讀259 返回首頁    go 小米 go 小米6


用匯編寫特殊要求的strlen

題目:

不允許調用庫函數,也不允許使用任何全局或局部變量編寫 int strlen(char *strDest);

用匯編的實現:
  1. int strlen(const char *s)
  2. {
  3.     __asm__ __volatile__("movl %%esi,%%eax;0:testb $0xFF,(%%eax);"
  4.                         "jz 1f;inc %%eax;jmp 0b;"
  5.                         "1:subl %%esi,%%eax;"::"S"(s));
  6. }
(gcc 3.3.1)

最後更新:2017-04-02 00:06:38

  上一篇:go SuperRuntimeLibrary.TextVoice 發布,支持文本到語音 文本到.wav
  下一篇:go MSSQL查詢優化