Here's an implementation in 3 instructions with _rndj fixed at 1. _rndk can take the values 3, 4, 6, 7, 15, 22, 60 or 63 depending on the period required. With _rndk = 4 and coresize 8000, the period is 31200.
For more variations, see the Wikipedia article on Lagged Fibonacci generators.
_rndk equ 4
random mov.a >rdata, random_out
mod.ab #_rndk, rdata
add.a *stack, @rdata
rdata dat 3711, 0
dat 1674, 0
dat 4323, 0
dat 7835, 0
No comments:
Post a Comment