Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Checking to confirm if a string is numeric

armond114armond114 Member Posts: 1
How would i go about checking characters in a string to confirm if it contains only numbers (0-9) or begins with (0-9, +, -)? I'm doing this in .386 with a flat model using MASM assembler


  • 3y3ty3y3ty Member Posts: 15
    you could cross check the one byte of the string
    with every digit, to see if it is a digit.
    Once it is equal to one of the digits simply jump to
    some other place.

    jmp start
    mydig db '0123456789',0
    mystr db '1256',0

    mov al,[mystr+esi]
    loop: ; compares each digit with byte in al
    mov bl,[mydig+edi]
    cmp bl,0
    je exit
    cmp bl,al
    je inv ; if equal to one of the digits we're done!
    inc edi
    jmp loop
    jmp otherplace

Sign In or Register to comment.