Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; input: pointer to 32-bit seed
- ; output: random value between [0, 65535]
- Xoroshiro32PlusPlus:
- ldrh r3, [r0]
- push {r4, r5, lr}
- movs r4, r3
- ldrh r2, [r0, #2]
- lsls r5, r3, #13
- lsrs r1, r3, #3
- eors r4, r2
- orrs r1, r5
- eors r1, r4
- lsls r5, r4, #5
- eors r1, r5
- strh r1, [r0]
- lsrs r1, r4, #6
- lsls r4, r4, #10
- adds r2, r3, r2
- orrs r4, r1
- strh r4, [r0, #2]
- lsls r0, r2, #16
- lsrs r0, r0, #23
- lsls r2, r2, #9
- orrs r0, r2
- subs r3, r3, #1
- adds r0, r0, r3
- lsls r0, r0, #16
- lsrs r0, r0, #16
- pop {r4, r5, pc}
- ; Compiled from:
- ; #include <stdint.h>
- ;
- ; const uint16_t a = 13;
- ; const uint16_t b = 5;
- ; const uint16_t c = 10;
- ; const uint16_t d = 9;
- ;
- ; static inline uint16_t rol(uint16_t x, uint16_t k)
- ; {
- ; return (x << k) | (x >> ((sizeof(x) * 8) - k));
- ; }
- ;
- ; uint16_t Xoroshiro32PlusPlus(uint16_t * seed) {
- ; uint16_t result = rol(seed[0] + seed[1], d) + seed[0];
- ;
- ; seed[1] ^= seed[0];
- ; seed[0] = rol(seed[0], a) ^ seed[1] ^ (seed[1] << b);
- ; seed[1] = rol(seed[1], c);
- ;
- ;
- ; return result - 1;
- ; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement