I have the following code to convert a command line argument (null terminated string) to integer from hex. I have trouble finding the correct algorithm to implement this. I know it's a sloppy code, but it helps me understand. Any pointers?
I know something is off because the max is 250 and entering FA gives an error. :(

mov ebx, dword ; 2nd arg


mov al, byte

cmp al, "0"

jl erronR1Value

cmp al, "9"

jg checkletters

jmp wasdigit


cmp al, "A"

jl erronR1Value

cmp al, "F"

jg checklower

jmp wasupper


cmp al, "a"

jl erronR1Value

cmp al, "f"

jg erronR1Value

sub al, 61h

add al, 10

jmp convloop


sub al, 30h

jmp convloop


sub al, 41h

add al, 10

jmp convloop


mov edx, dword ; radius 1 address. must store int value in .

shl , 4 ; multiply by 16

add , al

inc ecx

add ebx, 1

cmp byte, NULL

jne loop

Posted on 2011-10-20 22:33:32 by s0526
Nevermind. got it! I'd delete this, but I don't know how. :(
Posted on 2011-10-21 01:01:57 by s0526
Only staff can remove posts - the reason is so that others can learn from your stumble - so post how you did it!
Posted on 2011-10-21 09:54:38 by Homer