another idea is to approach it as a set of cases
we might select the "major" case set based on which dword the first null is found
case0_0 db 0 ;invalid case, but we should probably return 0
case0_1 db '1',0
case0_2 db '12',0
case0_3 db '123',0
case1_4 db '1234',0
case1_5 db '12345',0
case1_6 db '123456',0
case1_7 db '1234567',0
case2_8 db '12345678',0
case2_9 db '123456789',0
case2_0 db '1234567890',0
case2_x db '12345678901' ;illegal case
then, we can use the "fast null finder" algo....
mov ecx,[edx]
and ecx,7F7F7F7Fh
sub ecx,01010101h
and ecx,80808080h
jnz test_one_of_the_bytes_is_null_or_80h
that algo is fast because it assumes that 80h is rare in the string
that particularly applies in this application, because valid string characters are never 80h
now, we want to process 0 to 4 decimal chars at a time
i.e., 5 "sub-cases" - one of which is "we are done"