When i use win32asm program
I want use some functions like randmize and rand. However i not found in msdn
hope you can help me
Thank you
I want use some functions like randmize and rand. However i not found in msdn
hope you can help me
Thank you
You can use the C lib's rand. There's a function nrandom in masm32.lib, maybe you can use it.
Use the 'Search' function and you will find a variety of code and techniques with their pros and cons.
Regards, P1 8)
Regards, P1 8)
Here is an example :
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\msvcrt.lib
printf PROTO C :VARARG
rand PROTO C
.data
output db 'Random number: %d',13,10,0
counter dd 10
.code
start:
call init
@@:
invoke rand
xor edx,edx
mov ecx,20
div ecx
invoke printf,ADDR output,edx
dec counter
jnz @b
invoke ExitProcess,0
init PROC
local _st:SYSTEMTIME
local temp:DWORD
invoke GetSystemTime,ADDR _st
xor eax,eax
mov ax,_st.wMilliseconds
push eax
pop temp
@@:
invoke rand
dec temp
jnz @b
ret
init ENDP
END start
Checkout http://www.asmcommunity.net/board/index.php?topic=21695.msg164351#msg164351, where I've posted the code for a random number generator.
Haqa...
Haqa...
Thank you everybody