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. :(
I know something is off because the max is 250 and entering FA gives an error. :(
mov ebx, dword ; 2nd arg
loop:
mov al, byte
cmp al, "0"
jl erronR1Value
cmp al, "9"
jg checkletters
jmp wasdigit
checkletters:
cmp al, "A"
jl erronR1Value
cmp al, "F"
jg checklower
jmp wasupper
checklower:
cmp al, "a"
jl erronR1Value
cmp al, "f"
jg erronR1Value
sub al, 61h
add al, 10
jmp convloop
wasdigit:
sub al, 30h
jmp convloop
wasupper:
sub al, 41h
add al, 10
jmp convloop
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
Nevermind. got it! I'd delete this, but I don't know how. :(
Only staff can remove posts - the reason is so that others can learn from your stumble - so post how you did it!