title: strlen in assembly
body: <p>I made my own implementation of strlen in assembly, but it doesn't return the correct value. It returns the string length + 4. Consequently. I don't see why.. and I hope any of you do...
  <br /><br />Assembly source:</p>
  
  <pre><code>section .text
      [GLOBAL stringlen:] ; C function
  
  stringlen:  
      push ebp
      mov ebp, esp        ; setup the stack frame
  
      mov ecx, [ebp+8]
  
      xor eax, eax        ; loop counter
  
  
  startLoop:
      xor edx, edx
      mov edx, [ecx+eax]
      inc eax
  
      cmp edx, 0x0 ; null byte    
      jne startLoop
  end:    
      pop ebp
  
      ret
  </code></pre>
  
  <p>And the main routine:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  extern int stringlen(char *);
  
  int main(void)
  {
    printf("%d", stringlen("h"));
  
    return 0;
  }
  </code></pre>
  
  <p><b>Thanks</b></p>