Calculates next 64-bits pseudo-random number using an adaptation of Marsaglia’s XOR-shift+ 128 algorithm to a 64-bits state, using 8-9-23 sequence.
u32 cpct_nextRandom_mxorplus_u32 (u8* seed64b) __z88dk_fastcall;
| (2B HL) *seed64b* | Pointer to a 8-bytes (64-bits) vector containing the seed to be used for calculating next random. This seed will be overwritten with next 64-bits random value. |
call cpct_nextRandom_mxorplus_u32_asm
uint32_t s[2] = { 0x12348765, 0xA325BC98 }; // 64-bits non-zero seed
uint32_t xorshift64plus() {
uint32_t x = s[0];
uint32_t const y = s[1];
s[0] = y;
x ^= x << 8;
x ^= x >> 9;
x ^= y ^ (y >> 23);
s[1] = x;
return x + y;
}[ d ][ e ][ h ][ l ] 1) XOR [ e ][ h ][ l ] ==> Produces d', e', h' 2) XOR [ d' ][ e' ][ h' ] ==> Produces h'', l'' (Check notes on e'') 3) XOR [ h'' ][ l' ] ==> Produces d'', e'' ----------------------------------------------- Result [ d'' ][ e'' ][ h'' ][ l' ]
AF, BC, DE, HL
-- bytes
Case | microSecs (us) | CPU Cycles ----------------------------------------- Any | -- | --- -----------------------------------------