I am doing a project that must convert each string in X to an integer and save it in the corresponding location in Y. A dollar sign is used to mark the end of a string. I have 90% of the code, but it only works for the first string value. How can I step through this so that it does all the strings in the array.
include irvine32.inc
.data
X byte "12345$", "-12345$", "99999$", "-99999$" ;Strings to be converted.
Y sdword 4 dup (?)
.code
start:
mov esi, offset X
cmp byte ptr [esi],'-'
je negative ;if X ='s a - then jump to negative.
mov ch, 0 ;ch=0, a flag for positive
jmp convert ; if positive then jump to convert.
negative:
mov ch,1 ;ch =1, a flag for negative
inc esi ; esi -> the first digit char
convert:
mov al,[esi] ;al = first digit char
sub al,48 ; subtracts al by 48 first digit
movzx eax,al ;al=>eax, unsigned
mov ebx,10 ;ebx=>10, the multiplier
next:
inc esi ;what's next?
cmp byte ptr [esi],'$' ;end of string
je fin ; if finished store result in Y
mul ebx ;else, eax*ebx==>edx eax
mov dl,[esi] ;dl = next byte
sub dl,48 ;dl=next digit
movzx edx,dl ;dl => edx, unsigned
add eax,edx
jmp next
fin:
cmp ch, 1 ; a negative number?
je changeToNeg
jmp storeResult
changeToNeg:
neg eax
storeResult:
mov y,eax
invoke exitProcess,0
end start
Thank you Very much for any help