base:small_fast_16-bit_prng
16-bit PRNG
by White Flame
See Small, fast 8-bit PRNG for details of the algorithm. This should randomly iterate over a full 0000-ffff range, instead of the 0001-ffff range that the more common Galois LFSR covers.
Code is not well tested, though.
lda seed beq lowZero ; $0000 and $8000 are special values to test for ; Do a normal shift asl seed lda seed+1 rol bcc noEor doEor: ; high byte is in .A eor #>magic sta seed+1 lda seed eor #<magic sta seed rts lowZero: lda seed+1 beq doEor ; High byte is also zero, so apply the EOR ; For speed, you could store 'magic' into 'seed' directly ; instead of running the EORs ; wasn't zero, check for $8000 asl beq noEor ; if $00 is left after the shift, then it was $80 bcs doEor ; else, do the EOR based on the carry bit as usual noEor: sta seed+1 rts
All 2048 magic EOR numbers that give a 16-bit PRNG of period 65536:
$002d $0039 $003f $0053 $00bd $00d7 $012f $013d $014f $015d $0197 $01a1 $01ad $01bf $01c7 $0215 $0219 $0225 $022f $025d $026d $0285 $0291 $02a1 $02e5 $031d $034b $0369 $0371 $0387 $038d $039f $03a3 $03dd $03f9 $0429 $0457 $0467 $0483 $0489 $0491 $04bf $04c1 $0533 $0547 $0569 $0587 $05c3 $05dd $05eb $0641 $064b $0653 $068b $06c3 $076b $076d $0779 $0783 $07f1 $080d $0861 $08bf $08d5 $08df $08e3 $08f1 $08fb $0939 $097d $098b $09a5 $09af $09c3 $09c5 $09e7 $09f3 $0a7d $0a81 $0abb $0ac5 $0b01 $0b13 $0b15 $0b51 $0b5d $0bcd $0bd3 $0be5 $0c0f $0c1d $0c21 $0c69 $0c71 $0c7b $0c8d $0c95 $0ca3 $0caf $0cf3 $0d43 $0d83 $0d8f $0dd3 $0de5 $0e45 $0e85 $0e9d $0ea7 $0f05 $0f09 $0f1b $0f69 $0f77 $0f87 $0f95 $0fb1 $0fcf $0fdb $100b $1043 $104f $105d $107f $1083 $1085 $1097 $111d $116f $11c9 $11db $11f3 $1241 $1253 $1263 $1277 $1281 $128b $12af $12c5 $12db $12ed $12f3 $133b $133d $1375 $1379 $139d $1409 $141b $144d $1487 $1493 $14af $14c9 $14d1 $14ed $14f9 $1507 $158f $15a1 $15ab $15d5 $15fb $161f $1637 $163d $1643 $1651 $169b $16ab $16d9 $16fd $173f $1747 $1753 $1799 $17a3 $17a9 $17d7 $186f $188d $1893 $18a9 $18bb $18f9 $18ff $1923 $1925 $196b $1975 $1979 $19b3 $19e5 $19fd $1a07 $1a57 $1a6b $1a89 $1ae3 $1ae5 $1b09 $1b2b $1b47 $1b4b $1baf $1bbb $1bbd $1bc3 $1bd7 $1be1 $1c29 $1c61 $1c85 $1c9d $1cb5 $1ccb $1ccd $1ce9 $1cef $1cf1 $1d17 $1d3f $1d53 $1d59 $1d5f $1d65 $1d77 $1d81 $1d87 $1dff $1e21 $1e3f $1e5f $1e71 $1e7b $1e99 $1e9f $1ec3 $1ecf $1ee7 $1ef3 $1f29 $1f3b $1f57 $1f75 $1f83 $1f9b $1fb9 $1fbf $1fc1 $203d $2051 $208f $209b $20b9 $20c7 $2105 $2187 $2195 $21a9 $21b1 $21e1 $2227 $2235 $2241 $2253 $228b $2293 $22af $22b1 $2329 $2345 $2357 $236d $23e3 $240f $242d $2439 $244b $2499 $249f $24e7 $24ff $2515 $2557 $255d $2573 $2579 $259b $25e5 $2607 $2615 $2623 $263d $2651 $267f $2683 $26fb $2711 $2739 $2759 $2763 $2787 $27a5 $27c5 $27ed $281d $2841 $2871 $287b $28a9 $28c5 $28f5 $290b $2919 $2943 $2945 $2983 $2989 $299d $29b9 $29c7 $29d5 $29f1 $2a25 $2a29 $2a31 $2a3b $2a7f $2a85 $2aa7 $2acd $2ad9 $2b09 $2b27 $2b53 $2b7b $2b7d $2b99 $2bd1 $2bdb $2c1f $2c3b $2c4f $2c5d $2c61 $2c6b $2c73 $2c79 $2cb9 $2ce3 $2cf7 $2cfb $2d35 $2d41 $2d65 $2d81 $2ddb $2de1 $2e0f $2e47 $2e4b $2e4d $2e71 $2ec5 $2ef9 $2eff $2f3d $2f43 $2f5b $2f67 $2fa7 $2fd3 $3017 $3027 $3077 $3081 $30af $30c3 $30dd $30ed $30f5 $3107 $310d $3129 $3173 $31a7 $31ab $31cd $31d9 $322f $3237 $323d $3249 $3257 $325b $3275 $329d $32b5 $32d9 $32ef $32f1 $3305 $331b $3339 $339f $33a9 $33c5 $33d1 $33f3 $3415 $3425 $349b $34fd $3505 $351d $354b $3571 $357d $35a3 $35c9 $35d7 $361b $3635 $366f $3699 $36a9 $36c3 $36d1 $36ed $3707 $370b $3719 $3743 $37cd $37e3 $3801 $380d $381f $3837 $3849 $385d $386d $38c7 $38cb $38df $38fb $3921 $393f $394d $3953 $395f $3965 $3999 $39b7 $39bd $39c9 $39ff $3a09 $3a1b $3a55 $3a65 $3a69 $3a77 $3abd $3acf $3af3 $3b29 $3b45 $3b5b $3b9d $3bcb $3bd3 $3bef $3bf1 $3c47 $3c4b $3c69 $3c6f $3c93 $3d07 $3d13 $3d23 $3d31 $3d3d $3d43 $3d49 $3d67 $3d6b $3d83 $3d91 $3db3 $3dc1 $3dcd $3e31 $3e43 $3e45 $3e51 $3e57 $3e8f $3ed3 $3edf $3ee9 $3efb $3f1d $3f81 $3fa5 $3fc5 $4075 $409d $40cd $4109 $413f $414b $4153 $4159 $4193 $4199 $41af $41bb $41bd $41e1 $41e7 $41f3 $41ff $4203 $4211 $424b $4271 $4281 $42a9 $42cf $42e1 $42ed $430b $4343 $437f $4383 $43bf $43ef $43fb $440f $4447 $4477 $4495 $449f $44a3 $44bb $44c5 $44e1 $44f9 $450b $4529 $4537 $4573 $4589 $458f $459b $459d $45b5 $45b9 $45f7 $45fd $4629 $4645 $465d $4673 $4691 $46a1 $46cb $46d5 $46df $46e9 $46fd $4721 $477d $4793 $4799 $47c3 $47c9 $47f9 $481d $4835 $483f $4859 $4881 $48a9 $48c3 $48db $48ff $490b $4915 $492f $4931 $49df $49e5 $49fb $4a13 $4a15 $4a2f $4a6d $4a75 $4aad $4ab5 $4acb $4adf $4af7 $4afb $4b21 $4b4d $4b63 $4b7d $4bb7 $4bc9 $4bcf $4bdd $4bf3 $4bf9 $4bff $4c1f $4c67 $4c73 $4ca7 $4cb9 $4cc7 $4cf7 $4cfd $4d0f $4d39 $4d4d $4d5f $4d69 $4d71 $4d8b $4d8d $4de7 $4deb $4df3 $4e4b $4e6f $4e81 $4e87 $4ea3 $4eaf $4eb1 $4eeb $4ef5 $4f25 $4f31 $4f49 $4f57 $4f5b $4f61 $4f6d $4f8f $4fa1 $4fe3 $5003 $500f $5059 $5081 $50a5 $50b7 $50bb $50c9 $50d7 $50eb $5107 $5125 $5149 $515d $516d $51a1 $51a7 $51d3 $51df $520b $5245 $525d $5261 $5297 $5309 $5327 $5363 $5377 $53e1 $5457 $545b $547f $5483 $54b5 $54b9 $54df $5527 $552d $554b $5593 $55af $55f5 $5621 $562b $562d $5647 $569f $56c5 $56f5 $5729 $5751 $57ab $5807 $5825 $583d $5889 $58b3 $58d3 $58d9 $58df $592b $594b $594d $5969 $598d $5993 $599f $59a3 $59cf $59d7 $59ff $5a55 $5a71 $5a7d $5a99 $5aa5 $5ab7 $5ad7 $5b45 $5b4f $5b57 $5bab $5bc7 $5bdf $5c05 $5c99 $5ca3 $5ca5 $5ceb $5d07 $5d31 $5d37 $5d3b $5d7f $5d91 $5dab $5dc7 $5df1 $5dfd $5e0b $5e19 $5e29 $5e37 $5e57 $5e67 $5eab $5ed5 $5ee5 $5f55 $5f8d $5fbd $6021 $6039 $6063 $6077 $609f $60dd $610b $6119 $613d $6143 $6167 $617f $61ad $61d3 $6213 $6231 $623b $6261 $626b $6273 $628f $6297 $632d $6333 $6335 $6353 $6365 $637b $6381 $63ed $63f5 $6407 $641f $643b $6443 $6451 $6497 $649b $64e9 $64f7 $650f $652b $6535 $6539 $653f $6565 $6593 $65a5 $65e7 $65f3 $6605 $6671 $66a9 $66bb $66d7 $6707 $6719 $676b $6779 $67a1 $67bf $67d9 $67df $67f7 $6801 $680b $681f $6849 $689d $68cb $68d3 $68d5 $6917 $6947 $6955 $698d $69af $69cf $69d7 $6a77 $6aa5 $6ae7 $6b01 $6b0d $6b23 $6b57 $6b6b $6b8f $6b9d $6bab $6bc7 $6bfb $6c03 $6c1d $6c39 $6c6f $6c81 $6c93 $6ca5 $6ce7 $6d15 $6d3b $6d43 $6d89 $6d9d $6db3 $6dbf $6dc1 $6de5 $6e19 $6e51 $6e5d $6e67 $6e7f $6e85 $6e91 $6e97 $6e9b $6ed9 $6efd $6f47 $6f8d $6fc9 $6fdb $6fff $7025 $7029 $7057 $705b $7061 $706b $706d $709d $70b3 $70fd $7111 $7159 $715f $716f $7181 $71c3 $71dd $71f9 $7205 $721d $722d $725f $7263 $7271 $7299 $72a3 $72af $72cf $72dd $72e1 $7329 $7345 $736d $7391 $739b $73ad $73b9 $7411 $7439 $7469 $747d $7481 $7487 $7495 $74b7 $74c5 $74d7 $74ed $7501 $7515 $7523 $7549 $7583 $759b $75a1 $75a7 $760d $7619 $763b $763d $7643 $7657 $769d $76c7 $76df $771b $771d $7741 $774b $7781 $77a5 $77b7 $7809 $7835 $783f $7899 $78c9 $78d1 $78db $78dd $78eb $7901 $790d $7979 $797f $7991 $7997 $79e9 $79ef $7a01 $7a1f $7aa7 $7aab $7ab9 $7af7 $7b05 $7b39 $7b63 $7bb1 $7bbb $7bf5 $7c37 $7c4f $7c5d $7ca1 $7cb5 $7cbf $7ccb $7cd3 $7d21 $7d47 $7d59 $7d87 $7da5 $7da9 $7dc5 $7dd7 $7e1d $7e2b $7e4b $7e59 $7e65 $7e8b $7e93 $7eaf $7ebb $7ec5 $7ed1 $7eed $7f0b $7f2f $7f31 $7f45 $7f75 $7fb3 $7fc7 $7fd3 $8013 $8015 $806d $8085 $80f7 $8117 $812b $81b7 $8211 $821b $8241 $8255 $828b $8293 $829f $82bb $82c9 $82f3 $82ff $8307 $8329 $8357 $835d $8361 $8379 $8385 $83bf $83c1 $83df $83f1 $8411 $841b $8433 $844d $846f $84af $84cf $84d1 $84dd $84f9 $850d $8513 $8529 $8537 $8561 $856d $8579 $857f $8585 $85c7 $85d9 $85e9 $85fb $860b $8619 $8625 $8637 $86ab $86c1 $86d9 $86f1 $86f7 $870f $871d $8721 $8733 $8741 $8753 $87af $87b1 $87c5 $8833 $885f $8863 $88c9 $892f $8931 $895d $8979 $897f $899b $89a7 $89ad $89ef $89fb $8a45 $8a61 $8a67 $8a73 $8a75 $8a9d $8ae5 $8b35 $8b59 $8b63 $8b81 $8bb7 $8bd1 $8bdb $8c0d $8c23 $8c91 $8c97 $8c9d $8ccb $8cef $8d27 $8d95 $8da3 $8da5 $8dbd $8dc9 $8de7 $8e21 $8e47 $8e69 $8eb1 $8f57 $8f89 $8fd3 $8fd9 $8fe5 $8fef $9003 $900f $901b $9027 $9047 $908d $90a5 $90e7 $911f $9143 $916b $9179 $919b $91a1 $9231 $9251 $926d $9279 $9283 $9289 $92a7 $92fd $9305 $9317 $9327 $9335 $934d $9355 $939f $93c5 $93db $93eb $93f3 $9401 $943b $9473 $9489 $9491 $94a7 $94c1 $9505 $951b $952b $9539 $9547 $9571 $958b $958d $95a9 $95c3 $95d1 $962d $9635 $965f $9677 $967d $96b7 $96db $96f9 $970d $9715 $971f $9761 $97a1 $97ab $97b9 $97e3 $97e9 $97fd $980b $9823 $982f $9843 $990f $992b $9941 $9947 $998b $998d $99c3 $99ff $9a0f $9a1d $9a35 $9a6f $9ad7 $9b31 $9b37 $9b5b $9b6d $9b79 $9b7f $9bcb $9bdf $9bef $9bfd $9c53 $9c65 $9c69 $9c8d $9ca3 $9cc5 $9d19 $9d45 $9d49 $9d8f $9df7 $9e07 $9e4f $9e57 $9e61 $9e83 $9e91 $9ea7 $9eb9 $9ec7 $9edf $9ef1 $9f05 $9f11 $9f21 $9f4d $9f65 $9f7b $9f93 $9f99 $9fa5 $9fb7 $a011 $a02d $a033 $a06f $a07b $a095 $a0c3 $a0cf $a0f5 $a107 $a10d $a125 $a129 $a137 $a145 $a185 $a1d9 $a1fd $a23b $a283 $a289 $a291 $a2bf $a2c1 $a2fd $a31b $a321 $a32b $a333 $a353 $a365 $a3cf $a449 $a44f $a467 $a479 $a485 $a4bf $a4c1 $a4cb $a4e5 $a4e9 $a4fd $a505 $a517 $a527 $a52b $a535 $a555 $a559 $a581 $a5b1 $a5b7 $a5bb $a5dd $a62d $a639 $a64b $a663 $a671 $a67d $a6a5 $a6b7 $a6c5 $a71f $a767 $a797 $a7b3 $a7b9 $a7bf $a83b $a8d5 $a8df $a8fd $a903 $a933 $a935 $a94b $a94d $a953 $a98b $a9af $a9b1 $a9e7 $aa77 $aa9f $aabd $aac3 $aad1 $aaf5 $ab19 $ab1f $ab51 $ab57 $ab75 $aba7 $abad $abb5 $abd3 $abd5 $ac1d $ac27 $ac5f $ac69 $ac8d $acb1 $accf $ad13 $ad31 $ad4f $ad5b $ad79 $adad $adc1 $adcd $adfb $ae15 $ae3d $ae75 $ae97 $ae9b $aedf $aee5 $af41 $af65 $af93 $afaf $afff $b013 $b03b $b043 $b051 $b05b $b07f $b083 $b09b $b0b9 $b0c7 $b0d9 $b0ef $b153 $b177 $b18b $b199 $b1bb $b1dd $b1e1 $b1e7 $b209 $b21b $b24d $b259 $b287 $b2d1 $b2db $b2eb $b2ed $b313 $b323 $b345 $b349 $b34f $b35d $b37f $b38f $b39d $b3f1 $b40f $b41b $b41d $b455 $b46f $b499 $b53b $b56b $b5b3 $b5b9 $b5bf $b5c7 $b5e5 $b5e9 $b625 $b63d $b64f $b691 $b69b $b6d3 $b6ef $b711 $b769 $b76f $b793 $b7a3 $b7a9 $b7d7 $b7e1 $b7ed $b81b $b82b $b84d $b853 $b869 $b88b $b88d $b8a9 $b8dd $b8e7 $b92f $b95b $b96d $b975 $b991 $b9f1 $b9f7 $ba15 $ba31 $ba45 $ba57 $ba83 $ba97 $baa1 $bacd $bafd $bb05 $bb1b $bb27 $bb3f $bb4b $bb6f $bbb1 $bbbd $bbcf $bc07 $bc0b $bc29 $bc61 $bc67 $bcf1 $bcf7 $bd8d $bda9 $bdaf $bdf3 $be17 $be21 $be39 $be5f $be69 $bea5 $bec9 $bef9 $bf23 $bf25 $bf2f $bf37 $bf43 $bf51 $bf6b $bf85 $bfa7 $bfad $bfdf $c035 $c04d $c07b $c0b1 $c0c9 $c0cf $c0f3 $c10b $c115 $c119 $c137 $c151 $c175 $c179 $c183 $c1cd $c1d9 $c251 $c25d $c267 $c29b $c2df $c2e5 $c309 $c341 $c371 $c37d $c381 $c39f $c3b7 $c3c9 $c3e1 $c413 $c445 $c479 $c4d5 $c4e3 $c4e9 $c52d $c533 $c541 $c553 $c577 $c57d $c5b1 $c5b7 $c5d1 $c5ed $c609 $c61b $c639 $c665 $c6dd $c6f3 $c701 $c729 $c743 $c75b $c775 $c7ad $c7b5 $c7fd $c813 $c819 $c837 $c867 $c86b $c889 $c8df $c94b $c955 $c95f $c963 $c96f $c993 $c995 $c9a9 $c9bb $ca53 $ca65 $ca93 $caa9 $cabd $cae1 $cae7 $caf3 $cb15 $cb19 $cb1f $cb23 $cb5d $cbab $cbe9 $cbfb $cc27 $cc41 $cc4b $cc65 $cc6f $cc7b $cc87 $cca3 $cced $ccf5 $cd0d $cd37 $cd57 $cd79 $cdcb $cde9 $ce13 $ce3b $ce49 $ce57 $ce6d $cea7 $cead $cebf $cef1 $cf05 $cf1b $cf21 $cf2b $cf4d $cf63 $cf65 $d019 $d0fb $d103 $d10f $d12d $d14b $d171 $d193 $d19f $d1d7 $d211 $d24d $d263 $d28d $d295 $d2bb $d2eb $d2ed $d301 $d33d $d3cb $d3ef $d41d $d441 $d455 $d499 $d4b1 $d4bb $d4dd $d4e7 $d4f3 $d4f5 $d4f9 $d52f $d549 $d567 $d583 $d589 $d5ab $d5ad $d5b5 $d5bf $d5e3 $d5e5 $d5ef $d5f1 $d5f7 $d601 $d615 $d65d $d6b3 $d6b5 $d6cd $d717 $d72d $d735 $d759 $d75f $d77d $d7b1 $d7b7 $d7d1 $d7db $d80f $d827 $d839 $d87d $d899 $d8c3 $d8d1 $d8f5 $d907 $d90b $d91f $d943 $d945 $d94f $d967 $d975 $d9b3 $d9f7 $d9fb $da15 $da5d $dab5 $dacb $dad3 $db03 $db0f $db39 $db47 $db4b $db87 $dba3 $dba5 $dbd7 $dbdd $dbf3 $dc0d $dc19 $dc2f $dc45 $dc91 $dcab $dcad $dcb9 $dcd3 $dd1b $dd47 $dd71 $dd95 $dde1 $de03 $de4d $de65 $de69 $de7b $dea5 $debd $dec3 $df37 $df3b $df45 $df57 $df73 $dfcd $dfef $e013 $e015 $e037 $e045 $e049 $e05b $e061 $e07f $e0b3 $e0df $e0e9 $e117 $e133 $e14d $e165 $e1b7 $e1c3 $e209 $e25f $e28d $e2f9 $e345 $e351 $e361 $e373 $e39b $e3ad $e3e5 $e411 $e44b $e469 $e47d $e4db $e4f3 $e501 $e537 $e56b $e59b $e5b5 $e5df $e607 $e60b $e62f $e643 $e66b $e685 $e69d $e6b9 $e6f1 $e72d $e735 $e78b $e79f $e7a5 $e7af $e7bb $e7e1 $e833 $e86f $e877 $e881 $e899 $e8a5 $e8cf $e901 $e923 $e925 $e93b $e957 $e9fb $e9fd $ea19 $ea1f $ea43 $ea51 $ea61 $ea89 $ea91 $ea9d $eae5 $eaef $eafd $eb05 $eb21 $eb2b $eb2d $eb55 $eb7b $eb9f $ebb1 $ebc3 $ebcf $ebeb $ec0b $ec2f $ec31 $ec43 $ec5b $ec67 $ec6d $ec79 $ecb3 $ecd9 $ece5 $ed11 $ed1d $ed27 $edbb $eddb $ee1b $ee63 $ee71 $ee99 $eeaf $eedb $ef23 $ef3d $ef57 $ef85 $ef97 $efb3 $efb9 $efdf $efe3 $eff7 $f02d $f039 $f04d $f05f $f065 $f069 $f0af $f0bd $f0d1 $f113 $f137 $f1a7 $f1ab $f1cb $f1d3 $f20d $f245 $f249 $f27f $f283 $f2ab $f2d5 $f2df $f2f1 $f317 $f335 $f381 $f387 $f393 $f399 $f3af $f3cf $f41f $f423 $f46b $f48f $f49d $f4d3 $f4f1 $f4fb $f51d $f527 $f539 $f565 $f571 $f5d7 $f60f $f621 $f627 $f62b $f635 $f639 $f655 $f687 $f69f $f6a5 $f6c5 $f6dd $f6eb $f6f3 $f6f9 $f715 $f725 $f74f $f783 $f7b3 $f7b5 $f7cd $f7ef $f7fb $f801 $f825 $f83d $f8f1 $f905 $f939 $f94d $f971 $f9bb $f9d1 $fa21 $fa41 $fa4b $fa7d $fa8b $fae7 $fb01 $fb57 $fb5b $fb6d $fb7f $fb83 $fb85 $fbcb $fbcd $fbf1 $fc0f $fc11 $fc1b $fc55 $fc9f $fca9 $fcc9 $fced $fd0d $fd23 $fd3d $fd43 $fd75 $fd85 $fd9b $fdb3 $fdbf $fe25 $fe31 $fe49 $fe83 $fee9 $ff05 $ff33 $ff35 $ff39 $ff71 $ffa5 $ffeb $ffed
base/small_fast_16-bit_prng.txt · Last modified: 2017-10-26 07:26 by white_flame