about summary refs log tree commit diff stats
path: root/517random.mu
blob: 0e907442981fb82142d10df22d412fb6235df89a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
fn next-random prev: int -> _/edi: int {
  # https://en.wikipedia.org/wiki/Linear_congruential_generator#Parameters_in_common_use
  var a/ecx: int <- copy 0x4b/75
  var c/edx: int <- copy 0x4a/74
  var m/ebx: int <- copy 0x10001
  var next/eax: int <- copy prev
  next <- multiply a
  next <- add c
  next <- remainder next, m
  return next
}