我需要一个伪随机数生成器算法在课程指派一个汇编程序,我想preFER一个简单的算法。但是,我不能用一个外部库。
I need a pseudorandom number generator algorithm for a assembler program assigned in a course, and I would prefer a simple algorithm. However, I cannot use an external library.
什么是好的,简单的伪随机数生成器算法进行装配?
What is a good, simple pseudorandom number generator algorithm for assembly?
易一是只选择两个大素数的相对a和b,然后继续被乘以你的随机数和添加B。使用模运算符,以保持低的位作为随机数,并保持充分的价值为下一次迭代。
Easy one is to just choose two big relative primes a and b, then keep multiplying your random number by a and adding b. Use the modulo operator to keep the low bits as your random number and keep the full value for the next iteration.
这个算法是被称为线性同余发生器。