flat assembler
Message board for the users of flat assembler.
Index
> Windows > GameDev Random Number Generator |
Author |
|
lilljocke 19 May 2005, 10:40
i have done a simple but a working radnom generator
This is MASM CODE: lea esi,lpBuffer mov edi,esi mov ebx,[edi] mov ecx,4 Loop1: lods Byte Ptr [esi] rol ebx,1 add eax,ebx ror edx,cl add ah,dl xor al,bh stos Byte Ptr [edi] loopd Loop1 invoke wsprintf,ADDR lpBuffer,ADDR Format,[lpBuffer] invoke SetDlgItemText,Handle,1005,ADDR lpBuffer Ret you set lpBuffer a number like the handle of the window you have and then run the loop and you have the random number in lpBuffer after the loop |
|||
19 May 2005, 10:40 |
|
HarryTuttle 19 May 2005, 11:59
and how to set a range?
_________________ Microsoft: brings power of yesterday to computers of today. |
|||
19 May 2005, 11:59 |
|
lilljocke 19 May 2005, 12:15
in ecx? you can set how many times i should do the loop.
but you can not do more than 4bytes now so you can modify it to the range you want to have or i can do it. |
|||
19 May 2005, 12:15 |
|
Matrix 19 May 2005, 14:53
well basically i think random number generator is the same for all os es, only the parameter passing differs,
that's why i was thinking about moving random number generators from dos to main, but because of the slight difference and the moderate size of the threads it seemed inneccesary. here are 2 threads about random number generators Small random integer generator in Main Rando number generator in DOS |
|||
19 May 2005, 14:53 |
|
madmatt 24 May 2005, 17:36
Here is a link to agner fogs random number generator page. Here you'll find different types of random number generators, both integer and floating point, along with explanations as to how they work. Some are in C, some use assembly (MASM).
HTTP: http://www.agner.org/random/ |
|||
24 May 2005, 17:36 |
|
Nikolay Petrov 26 May 2005, 21:59
"rdtsc" mnemonic return 64 bits value and ticking only 6-11 times(it's contingent from processor). I don't know is it possible to return a random value faster. If you want how I use it - look at:
http://board.flatassembler.net/download.php?id=1480 |
|||
26 May 2005, 21:59 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.