• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "const.h"
2 
3 #define TEST1(instruction, offset, mem)        \
4 {                                              \
5    unsigned long out = 0;                      \
6    __asm__ __volatile__(                       \
7       "move        $t0, %1"        "\n\t"      \
8       "move        $t1, %2"        "\n\t"      \
9       "daddu       $t0, $t0, $t1"  "\n\t"      \
10       "move        $t1, $zero"     "\n\t"      \
11       instruction" $t1, 0($t0)"    "\n\t"      \
12       "move        %0,  $t1"       "\n\t"      \
13       : "=r" (out)                             \
14       : "r" (mem), "r" (offset)                \
15       : "t0", "t1"                             \
16    );                                          \
17    printf("%s :: offset: 0x%x, out: 0x%lx\n",  \
18           instruction, offset, out);           \
19 }
20 
21 #define TEST2(instruction, offset)                           \
22 {                                                            \
23    unsigned long out = 0;                                    \
24    unsigned long outHI = 0;                                  \
25    __asm__ __volatile__(                                     \
26       "move        $t0, %2"          "\n\t"                  \
27       "move        $t1, %4"          "\n\t"                  \
28       "daddu       $t0, $t0, $t1"    "\n\t"                  \
29       "ld          $t3, 0($t0)"      "\n\t"                  \
30       "move        $t1, %3"          "\n\t"                  \
31       "move        $t2, %4"          "\n\t"                  \
32       "daddu       $t1, $t1, $t2"    "\n\t"                  \
33       instruction" $t3, 0($t1)"      "\n\t"                  \
34       "li          $t2, 7"           "\n\t"                  \
35       "nor         $t2, $t2, $zero"  "\n\t"                  \
36       "and         $t1, $t1, $t2"    "\n\t"                  \
37       "ld          %0,  0($t1)"      "\n\t"                  \
38       "ld          %1,  8($t1)"      "\n\t"                  \
39       : "=r" (out), "=r" (outHI)                             \
40       : "r" (reg_val2) , "r" (reg_val_zero), "r" (offset)    \
41       : "t0", "t1", "t2", "t3"                               \
42    );                                                        \
43    printf("%s :: offset: 0x%x, out: 0x%lx, outHI: 0x%lx\n",  \
44           instruction, offset, out, outHI);                  \
45 }
46 
47 #define TEST3(instruction, offset, mem)         \
48 {                                               \
49    unsigned long long out = 0;                  \
50    __asm__ __volatile__(                        \
51       "move        $t0,   %1"        "\n\t"     \
52       "move        $t1,   %2"        "\n\t"     \
53       "daddu       $t0,   $t0, $t1"  "\n\t"     \
54       "dmtc1       $zero, $f0"       "\n\t"     \
55       instruction" $f0,  0($t0)"     "\n\t"     \
56       "dmfc1       %0,    $f0"       "\n\t"     \
57       : "=r" (out)                              \
58       : "r" (mem) , "r" (offset)                \
59       : "t0", "t1", "$f0"                       \
60    );                                           \
61    printf("%s :: offset: 0x%x, out: 0x%llx\n",  \
62           instruction, offset, out);            \
63 }
64 
65 #define TEST3w(instruction, offset, mem)      \
66 {                                             \
67    unsigned int out = 0;                      \
68    __asm__ __volatile__(                      \
69       "move        $t0,   %1"        "\n\t"   \
70       "move        $t1,   %2"        "\n\t"   \
71       "daddu       $t0,   $t0, $t1"  "\n\t"   \
72       "dmtc1       $zero, $f0"       "\n\t"   \
73       instruction" $f0,  0($t0)"     "\n\t"   \
74       "mfc1        %0,    $f0"       "\n\t"   \
75       : "=r" (out)                            \
76       : "r" (mem) , "r" (offset)              \
77       : "t0", "t1", "$f0"                     \
78    );                                         \
79    printf("%s :: offset: 0x%x, out: 0x%x\n",  \
80           instruction, offset, out);          \
81 }
82 
83 #define TEST4(instruction, offset)                         \
84 {                                                          \
85    unsigned long long out = 0;                             \
86    __asm__ __volatile__(                                   \
87       "move        $t0, %1"        "\n\t"                  \
88       "move        $t1, %3"        "\n\t"                  \
89       "daddu       $t0, $t0, $t1"  "\n\t"                  \
90       "ld          $t2, 0($t0)"    "\n\t"                  \
91       "move        $t0, %2"        "\n\t"                  \
92       "daddu       $t0, $t0, $t1"  "\n\t"                  \
93       "dmtc1       $t2, $f0"       "\n\t"                  \
94       instruction" $f0, 0($t0)"    "\n\t"                  \
95       "ld          %0,  0($t0)"    "\n\t"                  \
96       : "=r" (out)                                         \
97       : "r" (reg_val1) , "r" (reg_val_zero), "r" (offset)  \
98       : "t0", "t1", "t2", "$f0"                            \
99    );                                                      \
100    printf("%s :: offset: 0x%x, out: 0x%llx\n",             \
101           instruction, offset, out);                       \
102 }
103 
104 #define TEST5(instruction, offset, mem)         \
105 {                                               \
106    unsigned long long out = 0;                  \
107    __asm__ __volatile__(                        \
108       "move        $t0,   %1"        "\n\t"     \
109       "move        $t1,   %2"        "\n\t"     \
110       "dmtc1       $zero, $f0"       "\n\t"     \
111       instruction" $f0,   $t1($t0)"  "\n\t"     \
112       "dmfc1       %0,    $f0"       "\n\t"     \
113       : "=r" (out)                              \
114       : "r" (mem) , "r" (offset)                \
115       : "t0", "t1", "$f0"                       \
116    );                                           \
117    printf("%s :: offset: 0x%x, out: 0x%llx\n",  \
118           instruction, offset, out);            \
119 }
120 
121 #define TEST5w(instruction, offset, mem)      \
122 {                                             \
123    unsigned int out = 0;                      \
124    __asm__ __volatile__(                      \
125       "move        $t0,   %1"        "\n\t"   \
126       "move        $t1,   %2"        "\n\t"   \
127       "dmtc1       $zero, $f0"       "\n\t"   \
128       instruction" $f0,   $t1($t0)"  "\n\t"   \
129       "mfc1        %0,    $f0"       "\n\t"   \
130       : "=r" (out)                            \
131       : "r" (mem) , "r" (offset)              \
132       : "t0", "t1", "$f0"                     \
133    );                                         \
134    printf("%s :: offset: 0x%x, out: 0x%x\n",  \
135           instruction, offset, out);          \
136 }
137 
138 #define TEST6(instruction, offset)                         \
139 {                                                          \
140    unsigned long long out = 0;                             \
141    __asm__ __volatile__(                                   \
142       "move        $t0, %1"        "\n\t"                  \
143       "move        $t1, %3"        "\n\t"                  \
144       "daddu       $t0, $t0, $t1"  "\n\t"                  \
145       "ld          $t3, 0($t0)"    "\n\t"                  \
146       "move        $t1, %2"        "\n\t"                  \
147       "move        $t2, %3"        "\n\t"                  \
148       "daddu       $t1, $t1, $t2"  "\n\t"                  \
149       "dmtc1       $t3, $f3"       "\n\t"                  \
150       "move        $t0, %3"        "\n\t"                  \
151       instruction" $f3, $t0($t1)"  "\n\t"                  \
152       "ld          %0,  0($t1)"    "\n\t"                  \
153       : "=r" (out)                                         \
154       : "r" (reg_val2) , "r" (reg_val_zero), "r" (offset)  \
155       : "t0", "t1", "t2", "t3"                             \
156    );                                                      \
157    printf("%s :: offset: 0x%x, out: 0x%llx\n",             \
158           instruction, offset, out);                       \
159 }
160