Skip to content

Instantly share code, notes, and snippets.

@tuttlem
Created November 28, 2012 22:00
Show Gist options
  • Save tuttlem/4164970 to your computer and use it in GitHub Desktop.
Save tuttlem/4164970 to your computer and use it in GitHub Desktop.
PRNG - routine
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