I created this function for converting a string taken from standard input to an integer:
str2int:
mov rax, 0
L2:
cmp byte [input + r10], 0
je done2
add al, [input + r10]
sub rax, '0'
imul rax, 10
inc r10
jmp L2
done2:
ret
but when i use it, it adds an extra 0 at the end of the number (example: a 1 gets turned into a 10, a 30 into a 300 and so), what is the problem with it?
Even I, who haven’t looked at asy for very many years, and when I did I was no asy programmer, can see the problem.
I don’t want to do homework so not posting the answer but my top tip for discovering the bug is to step through your code on paper…