dialer/random.jrt

24 lines
513 B
Plaintext
Executable File

( https://codebase64.org/doku.php?id=base:16bit_xorshift_random_generator )
1 var, prngstate
:asm rand
MOV AX prngstate @+
MOV BX AX
RCR BX 1 #
XOR AH BL ( high part of x ^= x << 7 )
MOV BH AH
RCR BH 1 # ( BH now has x >> 9 and high bit comes from low byte )
XOR AL BH ( x ^= x >> 9 and the low part of x ^= x << 7 done )
XOR AH AL ( x ^= x << 8 )
MOV prngstate @+ AX
PUSH AX
NEXT
:asm ticks
XOR AX AX
INT 0x1a #
PUSH DX
NEXT
: reseed! ticks prngstate ! ;