Do any of you have a good assembly routine for converting a number into a string and back again?

Example:
age db '0018',24h
num dw 0
; convert age => num
add ,2
; convert num => age
; write 'age' (='0020' or only '20') to screen

Note! Not hex-numbers... ;)

Thanks! Regards, Viking
Posted on 2002-12-07 08:20:30 by POW
This is the 64643562523 time that someone asked this question...

Look into the FAQ or search for "atodw" and "dwtoa".
Posted on 2002-12-07 08:23:27 by bazik
Sorry! But thank you anyway...
Posted on 2002-12-07 10:53:09 by POW
Maybe, this proc?

proc dec2bin,pstrdec
enter
mov ecx,
xor eax,eax ; result register
cdq ; loadable register
.loop:
lea eax,
lea eax, ; eax <- (eax*10+dl)
mov dl,
inc ecx ; dl <- (-'0')
sub dl,'0' ; ANSI to bin
cmp dl,9
jbe .loop ; continue if 0<dl<9
return eax

and reverse:
stdcall ,...

Thanks.
Posted on 2002-12-08 07:49:33 by tserk