Created
November 28, 2012 22:00
-
-
Save tuttlem/4164970 to your computer and use it in GitHub Desktop.
PRNG - routine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PrngGet PROC range:DWORD | |
; count the number of cycles since | |
; the machine has been reset | |
rdtsc | |
; accumulate the value in eax and manage | |
; any carry-spill into the x state var | |
adc eax, edx | |
adc eax, prng_x | |
; multiply this calculation by the seed | |
mul prng_a | |
; manage the spill into the x state var | |
adc eax, edx | |
mov prng_x, eax | |
; put the calculation in range of what | |
; was requested | |
mul range | |
; ranged-random value in eax | |
mov eax, edx | |
ret | |
PrngGet ENDP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment