1
2
3
4
5
6
7
8
9
10
11
12 #include <asm/asmmacro.h>
13
14 #define a r2
15 #define m r3
16 #define lo r8
17 #define hi r9
18 #define t0 r16
19 #define t1 r17
20 #define seed r32
21
22 GLOBAL_ENTRY(carta_random32)
23 movl a = (16807 << 16) | 16807
24 ;;
25 pmpyshr2.u t0 = a, seed, 0
26 pmpyshr2.u t1 = a, seed, 16
27 ;;
28 unpack2.l t0 = t1, t0
29 dep m = -1, r0, 0, 31
30 ;;
31 zxt4 lo = t0
32 shr.u hi = t0, 32
33 ;;
34 dep t0 = 0, hi, 15, 49
35 ;;
36 shl t0 = t0, 16
37 shr t1 = hi, 15
38 ;;
39 add lo = lo, t0
40 ;;
41 cmp.gtu p6, p0 = lo, m
42 ;;
43 (p6) and lo = lo, m
44 ;;
45 (p6) add lo = 1, lo
46 ;;
47 add lo = lo, t1
48 ;;
49 cmp.gtu p6, p0 = lo, m
50 ;;
51 (p6) and lo = lo, m
52 ;;
53 (p6) add lo = 1, lo
54 br.ret.sptk.many rp
55 END(carta_random32)