This is my second week of assembly programming.
I am writing an inline asm function that converts a base 16 string to base 2, 8, 10, or 16 string.
I am able to convert the string into a base 10 integer and
I know how to convert to the desired base but I can't figure out how to append each succesive character.
This is what i am doing:[tt]
;eax contains a base 10 integer like 23
;all registers have been pushed onto stack & xor'd
;out_str is where I want to store my converted string
;in this case the result would be "10111"
mov bx, base ;desired base
lea ecx, out_str ;is this right??
conv_loop:
div bx ;convert to desired base
add dx, 48 ;convert from int to char
cmp dx, 57 ;check for hex
ja fix_for_hex ;fix hex number
return_:
mov [ecx+esi],dl ;shot in dark.no work
inc esi ;inc counter
xor edx, edx ;clear edx
cmp ax, bx ;<= 0?
jae conv_loop ;loop
fix_for_hex:
add dx, 7
jmp return_[/tt]
thanks
I am writing an inline asm function that converts a base 16 string to base 2, 8, 10, or 16 string.
I am able to convert the string into a base 10 integer and
I know how to convert to the desired base but I can't figure out how to append each succesive character.
This is what i am doing:[tt]
;eax contains a base 10 integer like 23
;all registers have been pushed onto stack & xor'd
;out_str is where I want to store my converted string
;in this case the result would be "10111"
mov bx, base ;desired base
lea ecx, out_str ;is this right??
conv_loop:
div bx ;convert to desired base
add dx, 48 ;convert from int to char
cmp dx, 57 ;check for hex
ja fix_for_hex ;fix hex number
return_:
mov [ecx+esi],dl ;shot in dark.no work
inc esi ;inc counter
xor edx, edx ;clear edx
cmp ax, bx ;<= 0?
jae conv_loop ;loop
fix_for_hex:
add dx, 7
jmp return_[/tt]
thanks