Search code examples
assemblyx86binarynasm

How to detect if a binary number has a 0 in Decimal


I have a binary number and I need to know if that binary number has a 0 anywhere in the number when I represent it as Decimal.

So, I can't convert it to a String or something like that.

I need some way to treat it just like a binary and detect it from there.

for instance

10111100101 = 1509
101111001011 = 3019

I need to detect those 0

ThankS!


Solution

  • The only method I know is to partially convert the number to decimal, without remembering the results. Something like this:

    ; number is in eax
        mov  ecx, 10
    loop:
        cdq
        div  ecx
        test edx, edx
        jnz  loop
        test eax, eax
        jnz  zero_found
    
    ; zero not found
    
        ret
    
    zero_found:
    
        ret