I am new to assembly language. To be clear, this is homework. The problem is given a char *list, how can I find which character is the end of the string? So I have
xor ecx, ecx; //counter
loop1:
mov esi, list;
mov eax, [esi + ecx];
cmp eax, 0x00; //check if the character is null
je end;
inc ecx;
jmp loop1;
end:
however, the loop does not terminate when it reaches the end of the string. I wonder what I have done wrong. I have been finding solution in books and online, but they all look like what I did. Any help will be appreciated!
EDIT: yes, counter should be outside of the loop.
Putting all of this together we get
mov esi, list
mov ecx, -1
loop1:
inc ecx
cmp byte [esi + ecx], 0x00; //check if the character is null
jne loop1;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With