title: Minimal opcode size x86-64 strlen implementation
body: <p>I'm investigating a minimal opcode size <strong>x86-64</strong> <strong>strlen</strong> implementation for my code golfing / binary executable that is not supposed to exceed some size (think of demoscene for simplicity).<br />
  General idea comes from <a href="http://www.int80h.org/strlen/" rel="noreferrer">here</a>, size optimization ideas from <a href="https://stackoverflow.com/a/33668295/5329717">here</a> and <a href="https://codegolf.stackexchange.com/a/132985">here</a>.</p>
  <p>Input string address is in <code>rdi</code> , max length should be not bigger than <code>Int32</code></p>
  <pre><code>xor   eax,eax ; 2 bytes
  or    ecx,-1  ; 3 bytes
  repne scasb   ; 2 bytes
  not   ecx     ; 2 bytes
  dec   ecx     ; 2 bytes
  </code></pre>
  <p>Final result is in <code>ecx</code> in <strong>11 bytes</strong> total.</p>
  <p>The question is about setting <code>ecx</code> to <code>-1</code></p>
  <p>Option 1 already stated</p>
  <pre><code>or ecx,-1 ; 3 bytes
  </code></pre>
  <p>Option 2</p>
  <pre><code>lea ecx,[rax-1] ; 3 bytes 
  </code></pre>
  <p>Option 3</p>
  <pre><code>stc         ; 1 byte
  sbb ecx,ecx ; 2 bytes
  </code></pre>
  <p>Option 4 , probably the slowest one</p>
  <pre><code>push -1 ; 2 bytes
  pop rcx ; 1 byte
  </code></pre>
  <p>I understand that:<br />
  Option 1 has dependency on previous <code>ecx</code> value<br />
  Option 2 has dependency on previous <code>rax</code> value<br />
  Option 3 I'm not sure if it has dependency on previous <code>ecx</code> value?<br />
  Option 4 is the slowest one?</p>
  <p>Is there a clear winner here?<br />
  The criteria is to keep the <strong>opcodes size as small as possible</strong> and choose the best one performance wise.<br />
  I'm fully aware there are implementations using modern cpu instructions, but this legacy approach seems the smallest one.</p>