title: Find the length of a null terminated string (Assembly language)
body: <p>I am trying to write a procedure to find the length of a null-terminated string and store the length in <code>eax</code>. The start address of the string is stored in <code>edx</code> before calling the procedure.</p>
  <p>Here's my code, I don't know what's wrong:</p>
  <pre><code>.386
  .model flat,stdcall
  .stack 4096
  ExitProcess PROTO, dwExitCode:DWORD
  
  .data
  myString BYTE &quot;Hello programmers&quot;, 0
  
  
  strLength PROC
  mov eax , 0
  mov ebx , '/0'
  mov esi , 0
  Condition:
  movzx ecx , myString[esi]
  cmp ebx , ecx
  je ExitLoop
  inc esi
  inc eax
  jmp Condition
  ExitLoop:
  ret
  StrLength ENDP
  
  
  
  main PROC
  lea edx, myString
  call strLength 
  
  INVOKE ExitProcess,0
  main ENDP
  END main
  </code></pre>
  <p>Here's the error message I'm getting:</p>
  <p><a href="https://i.stack.imgur.com/RnEI6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RnEI6.png" alt="error" /></a></p>
  <p>Line 14 is : Condition<br />
  Line 21 is : ExitLoop:<br />
  Line 17 is : je ExitLoop<br />
  Line 20 is : jmp Condition<br />
  Line 29 is : call strLength<br />
  Line 38 is : INVOKE ExitProcess,0<br />
  and line 70 doesn't exist</p>