I've code that should parse String format to int but it changes f.e. 0 to 658688 and I don't know what to do with it. Is the lodsd command correct here?
toparse DB 128 dup(?)
mov toparse, "0"
atoi proc uses esi edx inputBuff:DWORD
mov esi, inputBuff
xor edx, edx
.Repeat
lodsd
.Break .if !eax
imul edx, edx, 10
sub eax, "0"
add edx, eax
.Until 0
mov EAX, EDX
ret
atoi endp
it returns 658688
lodsdmay be correct, if your string encoding is UTF-32 or other 4 byte encoding. It probably is not, as domov toparse, "0". Did you check in debugger, what is happening? It's difficult to read your source, as it's not pure assembly, I think there are some macros or something... or are those "todo" comments maybe.lodsdis wrong. It loads a double-word (DWORD), but your characters are obviously byte-sized, since you've declared a string array usingDB(Declare Byte). You probably wantlodsb.0x0A0D00, so the good news is your code works (the low byte is0, as intended). I bet the other two bytes came from your input routine: the Enter that you ended it with. So if you are going to adjust for a loop, either test for the of end your input string, or check each character to see it's a digit, in this routine.