Created
July 20, 2022 19:33
-
-
Save leo60228/7cbfd90d7c807befb97150c3698d9ed2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(module | |
(global $s0 (mut i64) (i64.const 0)) | |
(global $s1 (mut i64) (i64.const 0)) | |
(global $s2 (mut i64) (i64.const 0)) | |
(global $s3 (mut i64) (i64.const 0)) | |
(func (export "seed") (param $p0 i64) (param $p1 i64) (param $p2 i64) (param $p3 i64) | |
local.get $p0 | |
global.set $s0 | |
local.get $p1 | |
global.set $s1 | |
local.get $p2 | |
global.set $s2 | |
local.get $p3 | |
global.set $s3) | |
(func (export "next") (result i64) | |
global.get $s1 ;; s[1] | |
i64.const 5 ;; s[1] 5 | |
i64.mul ;; (s[1] * 5) | |
i64.const 7 ;; (s[1] * 5) 7 | |
i64.rotl ;; rotl(s[1] * 5, 7) | |
i64.const 9 ;; rotl(s[1] * 5, 7) 9 | |
i64.mul ;; result | |
global.get $s1 ;; result s[1] | |
i64.const 17 ;; result s[1] 17 | |
i64.shl ;; result t | |
global.get $s2 ;; result t s[2] | |
global.get $s0 ;; result t s[2] s[0] | |
i64.xor ;; result t (s[2] ^ s[0]) | |
global.set $s2 ;; result t | |
global.get $s3 ;; result t s[3] | |
global.get $s1 ;; result t s[3] s[1] | |
i64.xor ;; result t (s[3] ^ s[1]) | |
global.set $s3 ;; result t | |
global.get $s1 ;; result t s[1] | |
global.get $s2 ;; result t s[1] s[2] | |
i64.xor ;; result t (s[1] ^ s[2]) | |
global.set $s1 ;; result t | |
global.get $s0 ;; result t s[0] | |
global.get $s3 ;; result t s[0] s[3] | |
i64.xor ;; result t (s[0] ^ s[3]) | |
global.set $s0 ;; result t | |
global.get $s2 ;; result t s[2] | |
i64.xor ;; result (t ^ s[2]) | |
global.set $s2 ;; result | |
global.get $s3 ;; result s[3] | |
i64.const 45 ;; result s[3] 45 | |
i64.rotl ;; result rotl(s[3], 45) | |
global.set $s3)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment