Minimal opcode size x86-64 strlen implementation
问题 I'm investigating a minimal opcode size x86-64 strlen implementation for my code golfing / binary executable that is not supposed to exceed some size (think of demoscene for simplicity). General idea comes from here, size optimization ideas from here and here. Input string address is in rdi , max length should be not bigger than Int32 xor eax,eax ; 2 bytes or ecx,-1 ; 3 bytes repne scasb ; 2 bytes not ecx ; 2 bytes dec ecx ; 2 bytes Final result is in ecx in 11 bytes total. The question is