• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #define TEST1(instruction, RSval, RTval, RD, RS, RT)  \
2 {                                                     \
3    unsigned long long out;                            \
4    __asm__ __volatile__(                              \
5       "move $"#RS", %1"     "\n\t"                    \
6       "move $"#RT", %2"     "\n\t"                    \
7       "move $"#RD", $zero"  "\n\t"                    \
8       instruction           "\n\t"                    \
9       "move %0,     $"#RD   "\n\t"                    \
10       : "=r" (out)                                    \
11       : "r" (RSval), "r" (RTval)                      \
12       : #RD, #RS, #RT                                 \
13    );                                                 \
14    printf("%s :: rd 0x%llx, rs 0x%llx, rt 0x%llx\n",  \
15           instruction, out, (long long) RSval,        \
16           (long long) RTval);                         \
17 }
18 
19 #define TEST2(instruction, RSval, imm, RT, RS)         \
20 {                                                      \
21    unsigned long long out;                             \
22    __asm__ __volatile__(                               \
23       "move $"#RS", %1"     "\n\t"                     \
24       "move $"#RT", $zero"  "\n\t"                     \
25       instruction           "\n\t"                     \
26       "move %0,     $"#RT   "\n\t"                     \
27       : "=r" (out)                                     \
28       : "r" (RSval)                                    \
29       : #RT, #RS                                       \
30    );                                                  \
31    printf("%s :: rt 0x%llx, rs 0x%llx, imm 0x%04x\n",  \
32           instruction, out, (long long) RSval, imm);   \
33 }
34 
35 #define TEST3(instruction, RSval, RD, RS)        \
36 {                                                \
37    unsigned long long out;                       \
38    __asm__ __volatile__(                         \
39       "move $"#RS", %1"     "\n\t"               \
40       "move $"#RD", $zero"  "\n\t"               \
41       instruction           "\n\t"               \
42       "move %0,     $"#RD   "\n\t"               \
43       : "=r" (out)                               \
44       : "r" (RSval)                              \
45       : #RD, #RS                                 \
46    );                                            \
47    printf("%s :: rd 0x%llx, rs 0x%llx\n",        \
48           instruction, out, (long long) RSval);  \
49 }
50 
51 #define TEST4(instruction, RSval, RTval, RS, RT)                       \
52 {                                                                      \
53    unsigned long long HI;                                              \
54    unsigned long long LO;                                              \
55    __asm__ __volatile__(                                               \
56       "move $"#RS", %2"  "\n\t"                                        \
57       "move $"#RT", %3"  "\n\t"                                        \
58       "mthi $zero"       "\n\t"                                        \
59       "mtlo $zero"       "\n\t"                                        \
60       instruction        "\n\t"                                        \
61       "mfhi %0"          "\n\t"                                        \
62       "mflo %1"          "\n\t"                                        \
63       : "=r" (HI), "=r" (LO)                                           \
64       : "r" (RSval), "r"(RTval)                                        \
65       : #RS, #RT                                                       \
66    );                                                                  \
67    printf("%s :: rs 0x%llx, rt 0x%llx, HI 0x%llx, LO 0x%llx\n",        \
68           instruction, (long long) RSval, (long long) RTval, HI, LO);  \
69 }
70 
71 #define TEST5(instruction, RSval, RTval, RS, RT)                       \
72 {                                                                      \
73    unsigned long long HI;                                              \
74    unsigned long long LO;                                              \
75    __asm__ __volatile__(                                               \
76       "move $"#RS", %2"  "\n\t"                                        \
77       "move $"#RT", %3"  "\n\t"                                        \
78       "mthi $"#RS        "\n\t"                                        \
79       "mtlo $"#RT        "\n\t"                                        \
80       instruction        "\n\t"                                        \
81       "mfhi %0"          "\n\t"                                        \
82       "mflo %1"          "\n\t"                                        \
83       : "=r" (HI), "=r" (LO)                                           \
84       : "r" (RSval), "r"(RTval)                                        \
85       : #RS, #RT                                                       \
86    );                                                                  \
87    printf("%s :: rs 0x%llx, rt 0x%llx, HI 0x%llx, LO 0x%llx\n",        \
88           instruction, (long long) RSval, (long long) RTval, HI, LO);  \
89 }
90 
91 #define TEST6(instruction, imm, RT)         \
92 {                                           \
93    unsigned long long out;                  \
94    __asm__ __volatile__(                    \
95       "move $"#RT", $zero"  "\n\t"          \
96       instruction           "\n\t"          \
97       "move %0, $"#RT       "\n\t"          \
98       : "=r" (out) :                        \
99       : #RT                                 \
100    );                                       \
101    printf("%s :: rt 0x%llx, imm 0x%04x\n",  \
102           instruction, out, imm);           \
103 }
104