The MASM Forum

General => The Campus => Topic started by: masterori on March 02, 2016, 04:17:43 PM

Title: Nevermind...
Post by: masterori on March 02, 2016, 04:17:43 PM
Nevermind... Please delete
Title: Re: How to add values in registers of different sizes
Post by: dedndave on March 02, 2016, 04:31:47 PM
i don't know how efficient this is, but....

you could use EDX as an "accumulator"

    mov     esi,offset numeric_string
    xor     eax,eax
    xor     edx,edx

top_of_loop:
    mov     al,[esi]
    cmp     al,"9"
    ja      not_valid

    cmp     al,"0"
    jb      test_end

    imul    edx,10
    inc     esi
    lea     edx,[edx+eax-30]
    jmp     top_of_loop

test_end:
    or      al,al
    jz      end_of_valid_string

not_valid:

;code for set error exit

end_of_valid_string:

;code for valid exit