Hello,
I am learning ASM and I am trying to solve a problem which involves to store a 8 digit randomly generated decimal number (1 to 99999999) as 8 ASCII characters at memory address ptrString (i.e. number 452346 should be stored as " 452346" and 12345678 as "12345678").
I think I have managed to generate the random number:
.data?
lpszNumber db 2 dup (?)
.code invoke GetTickCount
invoke nseed, eax
invoke nrandom, 100000000
invoke dwtoa, eax, offset lpszNumber
invoke atob, eax, offset lpszNumber
move dword ptr[ptrString], lpszNumber
But from here an on I am lost. I have read many man pages and forum but I haven't been able to find a way to store in the ptrString address the ASCII codes for the string representing the number in decimal.
I would really appreciate your help. Any suggestion how to proceed?
Regards
The single line,
dwtoa proc dwValue:DWORD, lpBuffer:DWORD
Will do it for you.
The dwValue is what you get from the random number generator, lpBuffer is the memory address where the result is written.
The random number you will generate will be 0 (zero) to 99999999.