I am trying to write a procedure to find the length of a null-terminated string and store the length in eax
. The start address of the string is stored in edx
before calling the procedure.
Here's my code, I don't know what's wrong:
.386
.model flat,stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:DWORD
.data
myString BYTE "Hello programmers", 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
Here's the error message I'm getting:
Line 14 is : Condition
Line 21 is : ExitLoop:
Line 17 is : je ExitLoop
Line 20 is : jmp Condition
Line 29 is : call strLength
Line 38 is : INVOKE ExitProcess,0
and line 70 doesn't exist