Hello
I'm a beginer. I dont know to use exact nrandom function in masm32.lib. I did do as following:
386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
include \masm32\m32lib\masm32.inc
includelib \masm32\m32lib\masm32.lib
.data
MsgBoxCaption db "Iczelion Tutorial No.00",0
zz db '%4X',0
buffer dd 128 dup (0)
.code
start:
INVOKE GetTickCount
invoke nrandom,eax
invoke wsprintf,addr buffer,offset zz, eax
invoke MessageBox, NULL, addr buffer, addr MsgBoxCaption, MB_OK
invoke ExitProcess, NULL
end start
Exact?????
please help me.
Other than small syntax items,
.386 instead of 386
and some .data items db instead of dd
.data
zz db "%6X",0 ; took 6 chars + 0 in all tests
buffer db 128 dup (0)
.code
start:
by not invoking nseed, eax before invoking nrandom,eax
invoke GetTickCount
invoke nrandom,eax
becomes essentially
invoke GetTickCount
mov ecx, eax
mov edx, 0
mov eax, 1335380034 ; 4F984842h the result of 12345678 as seed
div ecx
mov eax,edx
should probably do
invoke GetTickCount
invoke nseed,eax
invoke nrandom,eax
hmmmmm,
It may help to read the help file where the procedure is documented.
Quote
nrandom
nrandom proc base:DWORD
Description
A Park Miller random algorithm written by Jaymeson Trudgen (NaN) and optimised by Rickey Bowers Jr. (bitRAKE).
Parameter
1. base Zero based range for random output.
Return Value
Random number within range set in "base" in EAX.
Comments
The seed for the random algorithm is set as a variable of GLOBAL scope in a seperate procedure atached to the library module. The variable is nrandom_seed and this variable should be set with a DWORD size number prior to the use of this algorithm.
Also, if you are generating a sequence of numbers, reseeding the generator with the tick count before each call will destroy the randomness of the generated sequence.
smallboy,
Welcome to MASMforum! :U
Read around the different areas and get a feel for the place. :dazzled:
Read the help files and tutorials of MASM32. It's best, if you download the most recent MASM32 package and install it.
'Search' & Google are your friends for programming. Then ask your questions.
Regards, P1 :8)