1 2 /* How to compile: 3 gcc -O -g -Wall -mcpu=cortex-a8 -o testarmv6int testarmv6int.c 4 */ 5 6 #include <stdio.h> 7 8 /* test macros to generate and output the result of a single instruction */ 9 #define TESTINST2(instruction, RMval, RD, RM, carryin) \ 10 { \ 11 unsigned int out; \ 12 unsigned int cpsr; \ 13 \ 14 __asm__ volatile( \ 15 "movs %3,%3;" \ 16 "msrne cpsr_f,#(1<<29);" \ 17 "msreq cpsr_f,#0;" \ 18 "mov " #RM ",%2;" \ 19 /* set #RD to 0x55555555 so we can see which parts get overwritten */ \ 20 "mov " #RD ", #0x55" "\n\t" \ 21 "orr " #RD "," #RD "," #RD ", LSL #8" "\n\t" \ 22 "orr " #RD "," #RD "," #RD ", LSL #16" "\n\t" \ 23 instruction ";" \ 24 "mov %0," #RD ";" \ 25 "mrs %1,cpsr;" \ 26 : "=&r" (out), "=&r" (cpsr) \ 27 : "r" (RMval), "r" (carryin) \ 28 : #RD, #RM, "cc", "memory" \ 29 ); \ 30 printf("%s :: rd 0x%08x rm 0x%08x, carryin %d, cpsr 0x%08x %c%c%c%c\n", \ 31 instruction, out, RMval, \ 32 carryin ? 1 : 0, \ 33 cpsr & 0xffff0000, \ 34 ((1<<31) & cpsr) ? 'N' : ' ', \ 35 ((1<<30) & cpsr) ? 'Z' : ' ', \ 36 ((1<<29) & cpsr) ? 'C' : ' ', \ 37 ((1<<28) & cpsr) ? 'V' : ' ' \ 38 ); \ 39 } 40 41 #define TESTINST3(instruction, RMval, RNval, RD, RM, RN, carryin) \ 42 { \ 43 unsigned int out; \ 44 unsigned int cpsr; \ 45 \ 46 __asm__ volatile( \ 47 "movs %4,%4;" \ 48 "msrne cpsr_f,#(1<<29);" \ 49 "msreq cpsr_f,#0;" \ 50 "mov " #RM ",%2;" \ 51 "mov " #RN ",%3;" \ 52 instruction ";" \ 53 "mov %0," #RD ";" \ 54 "mrs %1,cpsr;" \ 55 : "=&r" (out), "=&r" (cpsr) \ 56 : "r" (RMval), "r" (RNval), "r" (carryin) \ 57 : #RD, #RM, #RN, "cc", "memory" \ 58 ); \ 59 printf("%s :: rd 0x%08x rm 0x%08x, rn 0x%08x, carryin %d, cpsr 0x%08x %c%c%c%c\n", \ 60 instruction, out, RMval, RNval, \ 61 carryin ? 1 : 0, \ 62 cpsr & 0xffff0000, \ 63 ((1<<31) & cpsr) ? 'N' : ' ', \ 64 ((1<<30) & cpsr) ? 'Z' : ' ', \ 65 ((1<<29) & cpsr) ? 'C' : ' ', \ 66 ((1<<28) & cpsr) ? 'V' : ' ' \ 67 ); \ 68 } 69 70 #define TESTINST4(instruction, RMval, RNval, RSval, RD, RM, RN, RS, carryin) \ 71 { \ 72 unsigned int out; \ 73 unsigned int cpsr; \ 74 \ 75 __asm__ volatile( \ 76 "movs %5,%5;" \ 77 "msrne cpsr_f,#(1<<29);" \ 78 "msreq cpsr_f,#0;" \ 79 "mov " #RM ",%2;" \ 80 "mov " #RN ",%3;" \ 81 "mov " #RS ",%4;" \ 82 instruction ";" \ 83 "mov %0," #RD ";" \ 84 "mrs %1,cpsr;" \ 85 : "=&r" (out), "=&r" (cpsr) \ 86 : "r" (RMval), "r" (RNval), "r" (RSval), "r" (carryin) \ 87 : #RD, #RM, #RN, #RS, "cc", "memory" \ 88 ); \ 89 printf("%s :: rd 0x%08x rm 0x%08x, rn 0x%08x rs 0x%08x, carryin %d, cpsr 0x%08x %c%c%c%c\n", \ 90 instruction, out, RMval, RNval, RSval, \ 91 carryin ? 1 : 0, \ 92 cpsr & 0xffff0000, \ 93 ((1<<31) & cpsr) ? 'N' : ' ', \ 94 ((1<<30) & cpsr) ? 'Z' : ' ', \ 95 ((1<<29) & cpsr) ? 'C' : ' ', \ 96 ((1<<28) & cpsr) ? 'V' : ' ' \ 97 ); \ 98 } 99 100 #define TESTINST4_2OUT(instruction, RDval, RD2val, RMval, RSval, RD, RD2, RM, RS, carryin) \ 101 { \ 102 unsigned int out; \ 103 unsigned int out2; \ 104 unsigned int cpsr; \ 105 \ 106 __asm__ volatile( \ 107 "movs %7,%7;" \ 108 "msrne cpsr_f,#(1<<29);" \ 109 "msreq cpsr_f,#0;" \ 110 "mov " #RD ",%3;" \ 111 "mov " #RD2 ",%4;" \ 112 "mov " #RM ",%5;" \ 113 "mov " #RS ",%6;" \ 114 instruction ";" \ 115 "mov %0," #RD ";" \ 116 "mov %1," #RD2 ";" \ 117 "mrs %2,cpsr;" \ 118 : "=&r" (out), "=&r" (out2), "=&r" (cpsr) \ 119 : "r" (RDval), "r" (RD2val), "r" (RMval), "r" (RSval), "r" (carryin) \ 120 : #RD, #RD2, #RM, #RS, "cc", "memory" \ 121 ); \ 122 printf("%s :: rd 0x%08x rd2 0x%08x, rm 0x%08x rs 0x%08x, carryin %d, cpsr 0x%08x %c%c%c%c\n", \ 123 instruction, out, out2, RMval, RSval, \ 124 carryin ? 1 : 0, \ 125 cpsr & 0xffff0000, \ 126 ((1<<31) & cpsr) ? 'N' : ' ', \ 127 ((1<<30) & cpsr) ? 'Z' : ' ', \ 128 ((1<<29) & cpsr) ? 'C' : ' ', \ 129 ((1<<28) & cpsr) ? 'V' : ' ' \ 130 ); \ 131 } 132 133 /* helpers */ 134 #define TESTCARRY { int c = 0; for (c = 0; c < 2; c++) { 135 #define TESTCARRYEND }} 136 137 138 139 140 int main(int argc, char **argv) 141 { 142 143 printf("MOV\n"); 144 TESTINST2("mov r0, r1", 1, r0, r1, 0); 145 TESTINST2("cpy r0, r1", 1, r0, r1, 0); 146 TESTINST2("mov r0, #0", 0, r0, r1, 0); 147 TESTINST2("mov r0, #1", 0, r0, r1, 0); 148 TESTCARRY 149 TESTINST2("movs r0, r1", 1, r0, r1, c); 150 TESTINST2("movs r0, r1", 0, r0, r1, c); 151 TESTINST2("movs r0, r1", 0x80000000, r0, r1, c); 152 TESTINST2("movs r0, #0", 0, r0, r1, c); 153 TESTINST2("movs r0, #1", 0, r0, r1, c); 154 TESTCARRYEND 155 156 printf("MVN\n"); 157 TESTINST2("mvn r0, r1", 1, r0, r1, 0); 158 TESTCARRY 159 TESTINST2("mvns r0, r1", 1, r0, r1, c); 160 TESTINST2("mvns r0, r1", 0, r0, r1, c); 161 TESTINST2("mvns r0, r1", 0x80000000, r0, r1, c); 162 TESTCARRYEND 163 164 printf("ADD\n"); 165 TESTINST3("adds r0, r1, r2", 0, 0, r0, r1, r2, 0); 166 TESTINST3("adds r0, r1, r2", 0, 1, r0, r1, r2, 0); 167 TESTINST3("adds r0, r1, r2", 1, 0, r0, r1, r2, 0); 168 TESTINST3("adds r0, r1, r2", 1, 1, r0, r1, r2, 0); 169 TESTINST3("adds r0, r1, r2", 0, -1, r0, r1, r2, 0); 170 TESTINST3("adds r0, r1, r2", 1, -1, r0, r1, r2, 0); 171 TESTINST3("adds r0, r1, r2", 0x7fffffff, 1, r0, r1, r2, 0); 172 TESTINST3("adds r0, r1, r2", 0x80000000, -1, r0, r1, r2, 0); 173 TESTINST3("adds r0, r1, r2", 0x80000000, 0, r0, r1, r2, 0); 174 175 printf("ADC\n"); 176 TESTINST3("adcs r0, r1, r2", 0, 0, r0, r1, r2, 0); 177 TESTINST3("adcs r0, r1, r2", 0, 0, r0, r1, r2, 1); 178 179 printf("LSL\n"); 180 TESTINST3("lsl r0, r1, r2", 0xffffffff, 0, r0, r1, r2, 0); 181 TESTINST3("lsl r0, r1, r2", 0xffffffff, 1, r0, r1, r2, 0); 182 TESTINST3("lsl r0, r1, r2", 0xffffffff, 2, r0, r1, r2, 0); 183 TESTINST3("lsl r0, r1, r2", 0xffffffff, 31, r0, r1, r2, 0); 184 TESTINST3("lsl r0, r1, r2", 0xffffffff, 32, r0, r1, r2, 0); 185 TESTINST3("lsl r0, r1, r2", 0xffffffff, 33, r0, r1, r2, 0); 186 TESTINST3("lsl r0, r1, r2", 0xffffffff, 63, r0, r1, r2, 0); 187 TESTINST3("lsl r0, r1, r2", 0xffffffff, 64, r0, r1, r2, 0); 188 TESTINST3("lsl r0, r1, r2", 0xffffffff, 255, r0, r1, r2, 0); 189 TESTINST3("lsl r0, r1, r2", 0xffffffff, 256, r0, r1, r2, 0); 190 191 TESTINST3("lsl r0, r1, r2", 0x1, 0, r0, r1, r2, 0); 192 TESTINST3("lsl r0, r1, r2", 0x1, 1, r0, r1, r2, 0); 193 TESTINST3("lsl r0, r1, r2", 0x1, 31, r0, r1, r2, 0); 194 TESTINST3("lsl r0, r1, r2", 0x2, 31, r0, r1, r2, 0); 195 196 printf("LSLS\n"); 197 TESTCARRY 198 TESTINST3("lsls r0, r1, r2", 0xffffffff, 0, r0, r1, r2, c); 199 TESTINST3("lsls r0, r1, r2", 0xffffffff, 1, r0, r1, r2, c); 200 TESTINST3("lsls r0, r1, r2", 0xffffffff, 2, r0, r1, r2, c); 201 TESTINST3("lsls r0, r1, r2", 0xffffffff, 31, r0, r1, r2, c); 202 TESTINST3("lsls r0, r1, r2", 0xffffffff, 32, r0, r1, r2, c); 203 TESTINST3("lsls r0, r1, r2", 0xffffffff, 33, r0, r1, r2, c); 204 TESTINST3("lsls r0, r1, r2", 0xffffffff, 63, r0, r1, r2, c); 205 TESTINST3("lsls r0, r1, r2", 0xffffffff, 64, r0, r1, r2, c); 206 TESTINST3("lsls r0, r1, r2", 0xffffffff, 255, r0, r1, r2, c); 207 TESTINST3("lsls r0, r1, r2", 0xffffffff, 256, r0, r1, r2, c); 208 TESTINST3("lsls r0, r1, r2", 0x1, 0, r0, r1, r2, c); 209 TESTINST3("lsls r0, r1, r2", 0x1, 1, r0, r1, r2, c); 210 TESTINST3("lsls r0, r1, r2", 0x1, 31, r0, r1, r2, c); 211 TESTINST3("lsls r0, r1, r2", 0x2, 31, r0, r1, r2, c); 212 TESTCARRYEND 213 214 printf("LSL immediate\n"); 215 TESTCARRY 216 TESTINST2("lsl r0, r1, #0", 0xffffffff, r0, r1, c); 217 TESTINST2("lsl r0, r1, #1", 0xffffffff, r0, r1, c); 218 TESTINST2("lsl r0, r1, #31", 0xffffffff, r0, r1, c); 219 TESTINST2("lsl r0, r1, #0", 0x1, r0, r1, c); 220 TESTINST2("lsl r0, r1, #1", 0x1, r0, r1, c); 221 TESTINST2("lsl r0, r1, #31", 0x1, r0, r1, c); 222 TESTINST2("lsl r0, r1, #31", 0x2, r0, r1, c); 223 TESTCARRYEND 224 225 printf("LSLS immediate\n"); 226 TESTCARRY 227 TESTINST2("lsls r0, r1, #0", 0xffffffff, r0, r1, c); 228 TESTINST2("lsls r0, r1, #1", 0xffffffff, r0, r1, c); 229 TESTINST2("lsls r0, r1, #31", 0xffffffff, r0, r1, c); 230 TESTINST2("lsls r0, r1, #0", 0x1, r0, r1, c); 231 TESTINST2("lsls r0, r1, #1", 0x1, r0, r1, c); 232 TESTINST2("lsls r0, r1, #31", 0x1, r0, r1, c); 233 TESTINST2("lsls r0, r1, #31", 0x2, r0, r1, c); 234 TESTCARRYEND 235 236 printf("LSR\n"); 237 TESTINST3("lsr r0, r1, r2", 0xffffffff, 0, r0, r1, r2, 0); 238 TESTINST3("lsr r0, r1, r2", 0xffffffff, 1, r0, r1, r2, 0); 239 TESTINST3("lsr r0, r1, r2", 0xffffffff, 2, r0, r1, r2, 0); 240 TESTINST3("lsr r0, r1, r2", 0xffffffff, 31, r0, r1, r2, 0); 241 TESTINST3("lsr r0, r1, r2", 0xffffffff, 32, r0, r1, r2, 0); 242 TESTINST3("lsr r0, r1, r2", 0xffffffff, 33, r0, r1, r2, 0); 243 TESTINST3("lsr r0, r1, r2", 0xffffffff, 63, r0, r1, r2, 0); 244 TESTINST3("lsr r0, r1, r2", 0xffffffff, 64, r0, r1, r2, 0); 245 TESTINST3("lsr r0, r1, r2", 0xffffffff, 255, r0, r1, r2, 0); 246 TESTINST3("lsr r0, r1, r2", 0xffffffff, 256, r0, r1, r2, 0); 247 248 printf("LSRS\n"); 249 TESTCARRY 250 TESTINST3("lsrs r0, r1, r2", 0xffffffff, 0, r0, r1, r2, c); 251 TESTINST3("lsrs r0, r1, r2", 0xffffffff, 1, r0, r1, r2, c); 252 TESTINST3("lsrs r0, r1, r2", 0xffffffff, 2, r0, r1, r2, c); 253 TESTINST3("lsrs r0, r1, r2", 0xffffffff, 31, r0, r1, r2, c); 254 TESTINST3("lsrs r0, r1, r2", 0xffffffff, 32, r0, r1, r2, c); 255 TESTINST3("lsrs r0, r1, r2", 0xffffffff, 33, r0, r1, r2, c); 256 TESTINST3("lsrs r0, r1, r2", 0xffffffff, 63, r0, r1, r2, c); 257 TESTINST3("lsrs r0, r1, r2", 0xffffffff, 64, r0, r1, r2, c); 258 TESTINST3("lsrs r0, r1, r2", 0xffffffff, 255, r0, r1, r2, c); 259 TESTCARRYEND 260 261 printf("LSR immediate\n"); 262 TESTINST2("lsr r0, r1, #0", 0xffffffff, r0, r1, 0); 263 TESTINST2("lsr r0, r1, #1", 0xffffffff, r0, r1, 0); 264 TESTINST2("lsr r0, r1, #31", 0xffffffff, r0, r1, 0); 265 TESTINST2("lsr r0, r1, #32", 0xffffffff, r0, r1, 0); 266 TESTINST2("lsr r0, r1, #16", 0x00010000, r0, r1, 0); 267 TESTINST2("lsr r0, r1, #17", 0x00010000, r0, r1, 0); 268 TESTINST2("lsr r0, r1, #18", 0x00010000, r0, r1, 0); 269 270 printf("LSRS immediate\n"); 271 TESTCARRY 272 TESTINST2("lsrs r0, r1, #0", 0xffffffff, r0, r1, c); 273 TESTINST2("lsrs r0, r1, #1", 0xffffffff, r0, r1, c); 274 TESTINST2("lsrs r0, r1, #31", 0xffffffff, r0, r1, c); 275 TESTINST2("lsrs r0, r1, #32", 0xffffffff, r0, r1, c); 276 TESTINST2("lsrs r0, r1, #16", 0x00010000, r0, r1, c); 277 TESTINST2("lsrs r0, r1, #17", 0x00010000, r0, r1, c); 278 TESTINST2("lsrs r0, r1, #18", 0x00010000, r0, r1, c); 279 TESTCARRYEND 280 281 printf("ASR\n"); 282 TESTCARRY 283 TESTINST3("asr r0, r1, r2", 0xffffffff, 0, r0, r1, r2, c); 284 TESTINST3("asr r0, r1, r2", 0xffffffff, 1, r0, r1, r2, c); 285 TESTINST3("asr r0, r1, r2", 0xffffffff, 2, r0, r1, r2, c); 286 TESTINST3("asr r0, r1, r2", 0xffffffff, 31, r0, r1, r2, c); 287 TESTINST3("asr r0, r1, r2", 0xffffffff, 32, r0, r1, r2, c); 288 TESTINST3("asr r0, r1, r2", 0xffffffff, 33, r0, r1, r2, c); 289 TESTINST3("asr r0, r1, r2", 0xffffffff, 63, r0, r1, r2, c); 290 TESTINST3("asr r0, r1, r2", 0xffffffff, 64, r0, r1, r2, c); 291 TESTINST3("asr r0, r1, r2", 0xffffffff, 255, r0, r1, r2, c); 292 TESTINST3("asr r0, r1, r2", 0xffffffff, 256, r0, r1, r2, c); 293 TESTINST3("asr r0, r1, r2", 0x7fffffff, 0, r0, r1, r2, c); 294 TESTINST3("asr r0, r1, r2", 0x7fffffff, 1, r0, r1, r2, c); 295 TESTINST3("asr r0, r1, r2", 0x7fffffff, 2, r0, r1, r2, c); 296 TESTINST3("asr r0, r1, r2", 0x7fffffff, 31, r0, r1, r2, c); 297 TESTINST3("asr r0, r1, r2", 0x7fffffff, 32, r0, r1, r2, c); 298 TESTINST3("asr r0, r1, r2", 0x7fffffff, 33, r0, r1, r2, c); 299 TESTINST3("asr r0, r1, r2", 0x7fffffff, 63, r0, r1, r2, c); 300 TESTINST3("asr r0, r1, r2", 0x7fffffff, 64, r0, r1, r2, c); 301 TESTINST3("asr r0, r1, r2", 0x7fffffff, 255, r0, r1, r2, c); 302 TESTINST3("asr r0, r1, r2", 0x7fffffff, 256, r0, r1, r2, c); 303 TESTCARRYEND 304 305 printf("ASRS\n"); 306 TESTCARRY 307 TESTINST3("asrs r0, r1, r2", 0xffffffff, 0, r0, r1, r2, c); 308 TESTINST3("asrs r0, r1, r2", 0xffffffff, 1, r0, r1, r2, c); 309 TESTINST3("asrs r0, r1, r2", 0xffffffff, 2, r0, r1, r2, c); 310 TESTINST3("asrs r0, r1, r2", 0xffffffff, 31, r0, r1, r2, c); 311 TESTINST3("asrs r0, r1, r2", 0xffffffff, 32, r0, r1, r2, c); 312 TESTINST3("asrs r0, r1, r2", 0xffffffff, 33, r0, r1, r2, c); 313 TESTINST3("asrs r0, r1, r2", 0xffffffff, 63, r0, r1, r2, c); 314 TESTINST3("asrs r0, r1, r2", 0xffffffff, 64, r0, r1, r2, c); 315 TESTINST3("asrs r0, r1, r2", 0xffffffff, 255, r0, r1, r2, c); 316 TESTINST3("asrs r0, r1, r2", 0xffffffff, 256, r0, r1, r2, c); 317 TESTINST3("asrs r0, r1, r2", 0x7fffffff, 0, r0, r1, r2, c); 318 TESTINST3("asrs r0, r1, r2", 0x7fffffff, 1, r0, r1, r2, c); 319 TESTINST3("asrs r0, r1, r2", 0x7fffffff, 2, r0, r1, r2, c); 320 TESTINST3("asrs r0, r1, r2", 0x7fffffff, 31, r0, r1, r2, c); 321 TESTINST3("asrs r0, r1, r2", 0x7fffffff, 32, r0, r1, r2, c); 322 TESTINST3("asrs r0, r1, r2", 0x7fffffff, 33, r0, r1, r2, c); 323 TESTINST3("asrs r0, r1, r2", 0x7fffffff, 63, r0, r1, r2, c); 324 TESTINST3("asrs r0, r1, r2", 0x7fffffff, 64, r0, r1, r2, c); 325 TESTINST3("asrs r0, r1, r2", 0x7fffffff, 255, r0, r1, r2, c); 326 TESTINST3("asrs r0, r1, r2", 0x7fffffff, 256, r0, r1, r2, c); 327 TESTCARRYEND 328 329 TESTCARRY 330 TESTINST3("asrs r0, r1, r2", 0x8, 0, r0, r1, r2, c); 331 TESTINST3("asrs r0, r1, r2", 0x8, 1, r0, r1, r2, c); 332 TESTINST3("asrs r0, r1, r2", 0x8, 2, r0, r1, r2, c); 333 TESTINST3("asrs r0, r1, r2", 0x8, 3, r0, r1, r2, c); 334 TESTINST3("asrs r0, r1, r2", 0x8, 4, r0, r1, r2, c); 335 TESTINST3("asrs r0, r1, r2", 0x8, 5, r0, r1, r2, c); 336 TESTCARRYEND 337 338 TESTINST3("asrs r0, r1, r2", 0x80000001, 1, r0, r1, r2, 0); 339 TESTINST3("asrs r0, r1, r2", 0x80000001, 2, r0, r1, r2, 0); 340 341 printf("ASR immediate\n"); 342 TESTINST2("asr r0, r1, #0", 0xffffffff, r0, r1, 0); 343 TESTINST2("asr r0, r1, #1", 0xffffffff, r0, r1, 0); 344 TESTINST2("asr r0, r1, #31", 0xffffffff, r0, r1, 0); 345 TESTINST2("asr r0, r1, #32", 0xffffffff, r0, r1, 0); 346 TESTINST2("asr r0, r1, #0", 0x7fffffff, r0, r1, 0); 347 TESTINST2("asr r0, r1, #1", 0x7fffffff, r0, r1, 0); 348 TESTINST2("asr r0, r1, #31", 0x7fffffff, r0, r1, 0); 349 TESTINST2("asr r0, r1, #32", 0x7fffffff, r0, r1, 0); 350 TESTINST2("asr r0, r1, #16", 0x00010000, r0, r1, 0); 351 TESTINST2("asr r0, r1, #17", 0x00010000, r0, r1, 0); 352 TESTINST2("asr r0, r1, #18", 0x00010000, r0, r1, 0); 353 354 printf("ASRS immediate\n"); 355 TESTCARRY 356 TESTINST2("asrs r0, r1, #0", 0xffffffff, r0, r1, c); 357 TESTINST2("asrs r0, r1, #1", 0xffffffff, r0, r1, c); 358 TESTINST2("asrs r0, r1, #31", 0xffffffff, r0, r1, c); 359 TESTINST2("asrs r0, r1, #32", 0xffffffff, r0, r1, c); 360 TESTINST2("asrs r0, r1, #0", 0x7fffffff, r0, r1, c); 361 TESTINST2("asrs r0, r1, #1", 0x7fffffff, r0, r1, c); 362 TESTINST2("asrs r0, r1, #31", 0x7fffffff, r0, r1, c); 363 TESTINST2("asrs r0, r1, #32", 0x7fffffff, r0, r1, c); 364 TESTINST2("asrs r0, r1, #16", 0x00010000, r0, r1, c); 365 TESTINST2("asrs r0, r1, #17", 0x00010000, r0, r1, c); 366 TESTINST2("asrs r0, r1, #18", 0x00010000, r0, r1, c); 367 TESTCARRYEND 368 369 printf("ROR\n"); 370 TESTCARRY 371 TESTINST3("ror r0, r1, r2", 0x00088000, 0, r0, r1, r2, c); 372 TESTINST3("ror r0, r1, r2", 0x80088000, 1, r0, r1, r2, c); 373 TESTINST3("ror r0, r1, r2", 0x00088000, 1, r0, r1, r2, c); 374 TESTINST3("ror r0, r1, r2", 0x00088000, 2, r0, r1, r2, c); 375 TESTINST3("ror r0, r1, r2", 0x00088000, 31, r0, r1, r2, c); 376 TESTINST3("ror r0, r1, r2", 0x00088000, 32, r0, r1, r2, c); 377 TESTINST3("ror r0, r1, r2", 0x00088000, 33, r0, r1, r2, c); 378 TESTINST3("ror r0, r1, r2", 0x00088000, 63, r0, r1, r2, c); 379 TESTINST3("ror r0, r1, r2", 0x00088000, 64, r0, r1, r2, c); 380 TESTINST3("ror r0, r1, r2", 0x00088000, 255, r0, r1, r2, c); 381 TESTINST3("ror r0, r1, r2", 0x00088000, 256, r0, r1, r2, c); 382 TESTINST3("ror r0, r1, r2", 0x80088000, 256, r0, r1, r2, c); 383 TESTINST3("ror r0, r1, r2", 0x00088000, 257, r0, r1, r2, c); 384 TESTCARRYEND 385 386 printf("RORS\n"); 387 TESTCARRY 388 TESTINST3("rors r0, r1, r2", 0x00088000, 0, r0, r1, r2, c); 389 TESTINST3("rors r0, r1, r2", 0x80088000, 0, r0, r1, r2, c); 390 TESTINST3("rors r0, r1, r2", 0x00088000, 1, r0, r1, r2, c); 391 TESTINST3("rors r0, r1, r2", 0x00088000, 2, r0, r1, r2, c); 392 TESTINST3("rors r0, r1, r2", 0x00088000, 31, r0, r1, r2, c); 393 TESTINST3("rors r0, r1, r2", 0x00088000, 32, r0, r1, r2, c); 394 TESTINST3("rors r0, r1, r2", 0x00088000, 33, r0, r1, r2, c); 395 TESTINST3("rors r0, r1, r2", 0x00088000, 63, r0, r1, r2, c); 396 TESTINST3("rors r0, r1, r2", 0x00088000, 64, r0, r1, r2, c); 397 TESTINST3("rors r0, r1, r2", 0x00088000, 255, r0, r1, r2, c); 398 TESTINST3("rors r0, r1, r2", 0x00088000, 256, r0, r1, r2, c); 399 TESTINST3("rors r0, r1, r2", 0x80088000, 256, r0, r1, r2, c); 400 TESTINST3("rors r0, r1, r2", 0x00088000, 257, r0, r1, r2, c); 401 TESTCARRYEND 402 403 printf("ROR immediate\n"); 404 TESTCARRY 405 TESTINST2("ror r0, r1, #0", 0x00088000, r0, r1, c); 406 TESTINST2("ror r0, r1, #1", 0x00088000, r0, r1, c); 407 TESTINST2("ror r0, r1, #31", 0x00088000, r0, r1, c); 408 TESTINST2("ror r0, r1, #16", 0x00010000, r0, r1, c); 409 TESTINST2("ror r0, r1, #17", 0x00010000, r0, r1, c); 410 TESTINST2("ror r0, r1, #18", 0x00010000, r0, r1, c); 411 TESTCARRYEND 412 413 printf("RORS immediate\n"); 414 TESTCARRY 415 TESTINST2("rors r0, r1, #0", 0x00088000, r0, r1, c); 416 TESTINST2("rors r0, r1, #1", 0x00088000, r0, r1, c); 417 TESTINST2("rors r0, r1, #31", 0x00088000, r0, r1, c); 418 TESTINST2("rors r0, r1, #16", 0x00010000, r0, r1, c); 419 TESTINST2("rors r0, r1, #17", 0x00010000, r0, r1, c); 420 TESTINST2("rors r0, r1, #18", 0x00010000, r0, r1, c); 421 TESTCARRYEND 422 423 printf("shift with barrel shifter\n"); 424 TESTCARRY 425 TESTINST4("add r0, r1, r2, lsl r3", 0, 0xffffffff, 0, r0, r1, r2, r3, c); 426 TESTINST4("add r0, r1, r2, lsl r3", 0, 0xffffffff, 1, r0, r1, r2, r3, c); 427 TESTINST4("add r0, r1, r2, lsl r3", 0, 0xffffffff, 31, r0, r1, r2, r3, c); 428 TESTINST4("add r0, r1, r2, lsl r3", 0, 0xffffffff, 32, r0, r1, r2, r3, c); 429 TESTINST4("add r0, r1, r2, lsl r3", 0, 0xffffffff, 255, r0, r1, r2, r3, c); 430 TESTINST4("add r0, r1, r2, lsl r3", 0, 0xffffffff, 256, r0, r1, r2, r3, c); 431 TESTINST4("add r0, r1, r2, lsr r3", 0, 0xffffffff, 0, r0, r1, r2, r3, c); 432 TESTINST4("add r0, r1, r2, lsr r3", 0, 0xffffffff, 1, r0, r1, r2, r3, c); 433 TESTINST4("add r0, r1, r2, lsr r3", 0, 0xffffffff, 31, r0, r1, r2, r3, c); 434 TESTINST4("add r0, r1, r2, lsr r3", 0, 0xffffffff, 32, r0, r1, r2, r3, c); 435 TESTINST4("add r0, r1, r2, lsr r3", 0, 0xffffffff, 255, r0, r1, r2, r3, c); 436 TESTINST4("add r0, r1, r2, lsr r3", 0, 0xffffffff, 256, r0, r1, r2, r3, c); 437 TESTINST4("add r0, r1, r2, asr r3", 0, 0x7fffffff, 0, r0, r1, r2, r3, c); 438 TESTINST4("add r0, r1, r2, asr r3", 0, 0x7fffffff, 1, r0, r1, r2, r3, c); 439 TESTINST4("add r0, r1, r2, asr r3", 0, 0x7fffffff, 31, r0, r1, r2, r3, c); 440 TESTINST4("add r0, r1, r2, asr r3", 0, 0x7fffffff, 32, r0, r1, r2, r3, c); 441 TESTINST4("add r0, r1, r2, asr r3", 0, 0x7fffffff, 255, r0, r1, r2, r3, c); 442 TESTINST4("add r0, r1, r2, asr r3", 0, 0x7fffffff, 256, r0, r1, r2, r3, c); 443 TESTINST4("add r0, r1, r2, lsr r3", 0, 0xffffffff, 256, r0, r1, r2, r3, c); 444 TESTCARRYEND 445 446 TESTCARRY 447 TESTINST4("add r0, r1, r2, asr r3", 0, 0x8, 0, r0, r1, r2, r3, c); 448 TESTINST4("add r0, r1, r2, asr r3", 0, 0x8, 1, r0, r1, r2, r3, c); 449 TESTINST4("add r0, r1, r2, asr r3", 0, 0x8, 2, r0, r1, r2, r3, c); 450 TESTINST4("add r0, r1, r2, asr r3", 0, 0x8, 3, r0, r1, r2, r3, c); 451 TESTINST4("add r0, r1, r2, asr r3", 0, 0x8, 4, r0, r1, r2, r3, c); 452 TESTINST4("add r0, r1, r2, asr r3", 0, 0x8, 5, r0, r1, r2, r3, c); 453 TESTCARRYEND 454 455 TESTCARRY 456 TESTINST4("add r0, r1, r2, ror r3", 0, 0x00088000, 0, r0, r1, r2, r3, c); 457 TESTINST4("add r0, r1, r2, ror r3", 0, 0x80088000, 0, r0, r1, r2, r3, c); 458 TESTINST4("add r0, r1, r2, ror r3", 0, 0x00088000, 1, r0, r1, r2, r3, c); 459 TESTINST4("add r0, r1, r2, ror r3", 0, 0x00088000, 31, r0, r1, r2, r3, c); 460 TESTINST4("add r0, r1, r2, ror r3", 0, 0x00088000, 32, r0, r1, r2, r3, c); 461 TESTINST4("add r0, r1, r2, ror r3", 0, 0x00088000, 255, r0, r1, r2, r3, c); 462 TESTINST4("add r0, r1, r2, ror r3", 0, 0x00088000, 256, r0, r1, r2, r3, c); 463 TESTINST4("add r0, r1, r2, ror r3", 0, 0x80088000, 256, r0, r1, r2, r3, c); 464 TESTINST4("add r0, r1, r2, ror r3", 0, 0x00088000, 257, r0, r1, r2, r3, c); 465 TESTCARRYEND 466 467 TESTCARRY 468 TESTINST4("adds r0, r1, r2, lsl r3", 0, 0xffffffff, 0, r0, r1, r2, r3, c); 469 TESTINST4("adds r0, r1, r2, lsl r3", 0, 0xffffffff, 1, r0, r1, r2, r3, c); 470 TESTINST4("adds r0, r1, r2, lsl r3", 0, 0xffffffff, 31, r0, r1, r2, r3, c); 471 TESTINST4("adds r0, r1, r2, lsl r3", 0, 0xffffffff, 32, r0, r1, r2, r3, c); 472 TESTINST4("adds r0, r1, r2, lsl r3", 0, 0xffffffff, 255, r0, r1, r2, r3, c); 473 TESTINST4("adds r0, r1, r2, lsl r3", 0, 0xffffffff, 256, r0, r1, r2, r3, c); 474 TESTINST4("adds r0, r1, r2, lsr r3", 0, 0xffffffff, 0, r0, r1, r2, r3, c); 475 TESTINST4("adds r0, r1, r2, lsr r3", 0, 0xffffffff, 1, r0, r1, r2, r3, c); 476 TESTINST4("adds r0, r1, r2, lsr r3", 0, 0xffffffff, 31, r0, r1, r2, r3, c); 477 TESTINST4("adds r0, r1, r2, lsr r3", 0, 0xffffffff, 32, r0, r1, r2, r3, c); 478 TESTINST4("adds r0, r1, r2, lsr r3", 0, 0xffffffff, 255, r0, r1, r2, r3, c); 479 TESTINST4("adds r0, r1, r2, lsr r3", 0, 0xffffffff, 256, r0, r1, r2, r3, c); 480 481 TESTINST4("adds r0, r1, r2, ror r3", 0, 0x00088000, 0, r0, r1, r2, r3, c); 482 TESTINST4("adds r0, r1, r2, ror r3", 0, 0x80088000, 0, r0, r1, r2, r3, c); 483 TESTINST4("adds r0, r1, r2, ror r3", 0, 0x00088000, 1, r0, r1, r2, r3, c); 484 TESTINST4("adds r0, r1, r2, ror r3", 0, 0x00088000, 31, r0, r1, r2, r3, c); 485 TESTINST4("adds r0, r1, r2, ror r3", 0, 0x00088000, 32, r0, r1, r2, r3, c); 486 TESTINST4("adds r0, r1, r2, ror r3", 0, 0x00088000, 255, r0, r1, r2, r3, c); 487 TESTINST4("adds r0, r1, r2, ror r3", 0, 0x00088000, 256, r0, r1, r2, r3, c); 488 TESTINST4("adds r0, r1, r2, ror r3", 0, 0x80088000, 256, r0, r1, r2, r3, c); 489 TESTINST4("adds r0, r1, r2, ror r3", 0, 0x00088000, 257, r0, r1, r2, r3, c); 490 TESTCARRYEND 491 492 TESTCARRY 493 TESTINST4("adcs r0, r1, r2, lsl r3", 0, 0xffffffff, 0, r0, r1, r2, r3, c); 494 TESTINST4("adcs r0, r1, r2, lsr r3", 0, 0xffffffff, 0, r0, r1, r2, r3, c); 495 TESTINST4("adcs r0, r1, r2, lsl r3", 0, 0xffffffff, 1, r0, r1, r2, r3, c); 496 TESTINST4("adcs r0, r1, r2, lsr r3", 0, 0xffffffff, 1, r0, r1, r2, r3, c); 497 TESTCARRYEND 498 499 printf("MUL\n"); 500 TESTINST3("mul r0, r1, r2", 0, 0, r0, r1, r2, 0); 501 TESTINST3("mul r0, r1, r2", 0xffffffff, 0, r0, r1, r2, 0); 502 TESTINST3("mul r0, r1, r2", 0, 0xffffffff, r0, r1, r2, 0); 503 TESTINST3("mul r0, r1, r2", 0xffffffff, 0xffffffff, r0, r1, r2, 0); 504 TESTINST3("mul r0, r1, r2", 0x7fffffff, 0x7fffffff, r0, r1, r2, 0); 505 TESTINST3("mul r0, r1, r2", 0x0000ffff, 0x0000ffff, r0, r1, r2, 0); 506 507 printf("MULS\n"); 508 TESTINST3("muls r0, r1, r2", 0, 0, r0, r1, r2, 0); 509 TESTINST3("muls r0, r1, r2", 0xffffffff, 0, r0, r1, r2, 0); 510 TESTINST3("muls r0, r1, r2", 0, 0xffffffff, r0, r1, r2, 0); 511 TESTINST3("muls r0, r1, r2", 0xffffffff, 0xffffffff, r0, r1, r2, 0); 512 TESTINST3("muls r0, r1, r2", 0x7fffffff, 0x7fffffff, r0, r1, r2, 0); 513 TESTINST3("muls r0, r1, r2", 0x0000ffff, 0x0000ffff, r0, r1, r2, 0); 514 515 printf("MLA\n"); 516 TESTINST4("mla r0, r1, r2, r3", 0, 0, 1, r0, r1, r2, r3, 0); 517 TESTINST4("mla r0, r1, r2, r3", 0xffffffff, 0, 1, r0, r1, r2, r3, 0); 518 TESTINST4("mla r0, r1, r2, r3", 0, 0xffffffff, 1, r0, r1, r2, r3, 0); 519 TESTINST4("mla r0, r1, r2, r3", 0xffffffff, 0xffffffff, 1, r0, r1, r2, r3, 0); 520 TESTINST4("mla r0, r1, r2, r3", 0x7fffffff, 0x7fffffff, 1, r0, r1, r2, r3, 0); 521 TESTINST4("mla r0, r1, r2, r3", 0x0000ffff, 0x0000ffff, 1, r0, r1, r2, r3, 0); 522 523 printf("MLAS\n"); 524 TESTINST4("mlas r0, r1, r2, r3", 0, 0, 1, r0, r1, r2, r3, 0); 525 TESTINST4("mlas r0, r1, r2, r3", 0xffffffff, 0, 1, r0, r1, r2, r3, 0); 526 TESTINST4("mlas r0, r1, r2, r3", 0, 0xffffffff, 1, r0, r1, r2, r3, 0); 527 TESTINST4("mlas r0, r1, r2, r3", 0xffffffff, 0xffffffff, 1, r0, r1, r2, r3, 0); 528 TESTINST4("mlas r0, r1, r2, r3", 0x7fffffff, 0x7fffffff, 1, r0, r1, r2, r3, 0); 529 TESTINST4("mlas r0, r1, r2, r3", 0x0000ffff, 0x0000ffff, 1, r0, r1, r2, r3, 0); 530 531 printf("MLS\n"); 532 TESTINST4("mls r0, r1, r2, r3", 0, 0, 1, r0, r1, r2, r3, 0); 533 TESTINST4("mls r0, r1, r2, r3", 0xffffffff, 0, 1, r0, r1, r2, r3, 0); 534 TESTINST4("mls r0, r1, r2, r3", 0, 0xffffffff, 1, r0, r1, r2, r3, 0); 535 TESTINST4("mls r0, r1, r2, r3", 0xffffffff, 0xffffffff, 1, r0, r1, r2, r3, 0); 536 TESTINST4("mls r0, r1, r2, r3", 0x7fffffff, 0x7fffffff, 1, r0, r1, r2, r3, 0); 537 TESTINST4("mls r0, r1, r2, r3", 0x0000ffff, 0x0000ffff, 1, r0, r1, r2, r3, 0); 538 539 printf("UMULL\n"); 540 TESTINST4_2OUT("umull r0, r1, r2, r3", 0, 0, 0, 0, r0, r1, r2, r3, 0); 541 TESTINST4_2OUT("umull r0, r1, r2, r3", 0, 0, 0, 1, r0, r1, r2, r3, 0); 542 TESTINST4_2OUT("umull r0, r1, r2, r3", 0, 0, 1, 0, r0, r1, r2, r3, 0); 543 TESTINST4_2OUT("umull r0, r1, r2, r3", 0, 0, 1, 1, r0, r1, r2, r3, 0); 544 TESTINST4_2OUT("umull r0, r1, r2, r3", 0, 0, 0xffff, 0xffff, r0, r1, r2, r3, 0); 545 TESTINST4_2OUT("umull r0, r1, r2, r3", 0, 0, 0xffffffff, 0xffffffff, r0, r1, r2, r3, 0); 546 TESTINST4_2OUT("umulls r0, r1, r2, r3", 0, 0, 0, 0, r0, r1, r2, r3, 0); 547 TESTINST4_2OUT("umulls r0, r1, r2, r3", 0, 0, 0, 1, r0, r1, r2, r3, 0); 548 TESTINST4_2OUT("umulls r0, r1, r2, r3", 0, 0, 1, 0, r0, r1, r2, r3, 0); 549 TESTINST4_2OUT("umulls r0, r1, r2, r3", 0, 0, 1, 1, r0, r1, r2, r3, 0); 550 TESTINST4_2OUT("umulls r0, r1, r2, r3", 0, 0, 0xffff, 0xffff, r0, r1, r2, r3, 0); 551 TESTINST4_2OUT("umulls r0, r1, r2, r3", 0, 0, 0xffffffff, 0xffffffff, r0, r1, r2, r3, 0); 552 553 printf("SMULL\n"); 554 TESTINST4_2OUT("smull r0, r1, r2, r3", 0, 0, 0, 0, r0, r1, r2, r3, 0); 555 TESTINST4_2OUT("smull r0, r1, r2, r3", 0, 0, 0, 1, r0, r1, r2, r3, 0); 556 TESTINST4_2OUT("smull r0, r1, r2, r3", 0, 0, 1, 0, r0, r1, r2, r3, 0); 557 TESTINST4_2OUT("smull r0, r1, r2, r3", 0, 0, 1, 1, r0, r1, r2, r3, 0); 558 TESTINST4_2OUT("smull r0, r1, r2, r3", 0, 0, 0xffff, 0xffff, r0, r1, r2, r3, 0); 559 TESTINST4_2OUT("smull r0, r1, r2, r3", 0, 0, 0xffffffff, 0xffffffff, r0, r1, r2, r3, 0); 560 TESTINST4_2OUT("smulls r0, r1, r2, r3", 0, 0, 0, 0, r0, r1, r2, r3, 0); 561 TESTINST4_2OUT("smulls r0, r1, r2, r3", 0, 0, 0, 1, r0, r1, r2, r3, 0); 562 TESTINST4_2OUT("smulls r0, r1, r2, r3", 0, 0, 1, 0, r0, r1, r2, r3, 0); 563 TESTINST4_2OUT("smulls r0, r1, r2, r3", 0, 0, 1, 1, r0, r1, r2, r3, 0); 564 TESTINST4_2OUT("smulls r0, r1, r2, r3", 0, 0, 0xffff, 0xffff, r0, r1, r2, r3, 0); 565 TESTINST4_2OUT("smulls r0, r1, r2, r3", 0, 0, 0xffffffff, 0xffffffff, r0, r1, r2, r3, 0); 566 567 printf("UMLAL\n"); 568 TESTINST4_2OUT("umlal r0, r1, r2, r3", 0, 0, 0, 0, r0, r1, r2, r3, 0); 569 TESTINST4_2OUT("umlal r0, r1, r2, r3", 0, 1, 0, 0, r0, r1, r2, r3, 0); 570 TESTINST4_2OUT("umlal r0, r1, r2, r3", 1, 1, 0, 0, r0, r1, r2, r3, 0); 571 TESTINST4_2OUT("umlal r0, r1, r2, r3", 0, 0xffffffff, 1, 1, r0, r1, r2, r3, 0); 572 TESTINST4_2OUT("umlal r0, r1, r2, r3", 0, 0, 0, 1, r0, r1, r2, r3, 0); 573 TESTINST4_2OUT("umlal r0, r1, r2, r3", 0, 0, 1, 0, r0, r1, r2, r3, 0); 574 TESTINST4_2OUT("umlal r0, r1, r2, r3", 0, 0, 1, 1, r0, r1, r2, r3, 0); 575 TESTINST4_2OUT("umlal r0, r1, r2, r3", 0, 0, 0xffff, 0xffff, r0, r1, r2, r3, 0); 576 TESTINST4_2OUT("umlal r0, r1, r2, r3", 0, 0, 0xffffffff, 0xffffffff, r0, r1, r2, r3, 0); 577 TESTINST4_2OUT("umlals r0, r1, r2, r3", 0, 0, 0, 0, r0, r1, r2, r3, 0); 578 TESTINST4_2OUT("umlals r0, r1, r2, r3", 0, 1, 0, 0, r0, r1, r2, r3, 0); 579 TESTINST4_2OUT("umlals r0, r1, r2, r3", 1, 1, 0, 0, r0, r1, r2, r3, 0); 580 TESTINST4_2OUT("umlals r0, r1, r2, r3", 0, 0xffffffff, 1, 1, r0, r1, r2, r3, 0); 581 TESTINST4_2OUT("umlals r0, r1, r2, r3", 0, 0, 0, 1, r0, r1, r2, r3, 0); 582 TESTINST4_2OUT("umlals r0, r1, r2, r3", 0, 0, 1, 0, r0, r1, r2, r3, 0); 583 TESTINST4_2OUT("umlals r0, r1, r2, r3", 0, 0, 1, 1, r0, r1, r2, r3, 0); 584 TESTINST4_2OUT("umlals r0, r1, r2, r3", 0, 0, 0xffff, 0xffff, r0, r1, r2, r3, 0); 585 TESTINST4_2OUT("umlals r0, r1, r2, r3", 0, 0, 0xffffffff, 0xffffffff, r0, r1, r2, r3, 0); 586 587 printf("SMLAL\n"); 588 TESTINST4_2OUT("smlal r0, r1, r2, r3", 0, 0, 0, 0, r0, r1, r2, r3, 0); 589 TESTINST4_2OUT("smlal r0, r1, r2, r3", 0, 1, 0, 0, r0, r1, r2, r3, 0); 590 TESTINST4_2OUT("smlal r0, r1, r2, r3", 1, 1, 0, 0, r0, r1, r2, r3, 0); 591 TESTINST4_2OUT("smlal r0, r1, r2, r3", 0, 0xffffffff, 1, 1, r0, r1, r2, r3, 0); 592 TESTINST4_2OUT("smlal r0, r1, r2, r3", 0, 0, 0, 1, r0, r1, r2, r3, 0); 593 TESTINST4_2OUT("smlal r0, r1, r2, r3", 0, 0, 1, 0, r0, r1, r2, r3, 0); 594 TESTINST4_2OUT("smlal r0, r1, r2, r3", 0, 0, 1, 1, r0, r1, r2, r3, 0); 595 TESTINST4_2OUT("smlal r0, r1, r2, r3", 0, 0, 0xffff, 0xffff, r0, r1, r2, r3, 0); 596 TESTINST4_2OUT("smlal r0, r1, r2, r3", 0, 0, 0xffffffff, 0xffffffff, r0, r1, r2, r3, 0); 597 TESTINST4_2OUT("smlals r0, r1, r2, r3", 0, 0, 0, 0, r0, r1, r2, r3, 0); 598 TESTINST4_2OUT("smlals r0, r1, r2, r3", 0, 1, 0, 0, r0, r1, r2, r3, 0); 599 TESTINST4_2OUT("smlals r0, r1, r2, r3", 1, 1, 0, 0, r0, r1, r2, r3, 0); 600 TESTINST4_2OUT("smlals r0, r1, r2, r3", 0, 0xffffffff, 1, 1, r0, r1, r2, r3, 0); 601 TESTINST4_2OUT("smlals r0, r1, r2, r3", 0, 0, 0, 1, r0, r1, r2, r3, 0); 602 TESTINST4_2OUT("smlals r0, r1, r2, r3", 0, 0, 1, 0, r0, r1, r2, r3, 0); 603 TESTINST4_2OUT("smlals r0, r1, r2, r3", 0, 0, 1, 1, r0, r1, r2, r3, 0); 604 TESTINST4_2OUT("smlals r0, r1, r2, r3", 0, 0, 0xffff, 0xffff, r0, r1, r2, r3, 0); 605 TESTINST4_2OUT("smlals r0, r1, r2, r3", 0, 0, 0xffffffff, 0xffffffff, r0, r1, r2, r3, 0); 606 607 printf("CLZ\n"); 608 TESTCARRY 609 TESTINST2("clz r0, r1", 0, r0, r1, c); 610 TESTINST2("clz r0, r1", 1, r0, r1, c); 611 TESTINST2("clz r0, r1", 0x10, r0, r1, c); 612 TESTINST2("clz r0, r1", 0xffffffff, r0, r1, c); 613 TESTCARRYEND 614 615 printf("extend instructions\n"); 616 TESTINST2("uxtb r0, r1", 0, r0, r1, 0); 617 TESTINST2("uxtb r0, r1", 1, r0, r1, 0); 618 TESTINST2("uxtb r0, r1", 0xff, r0, r1, 0); 619 TESTINST2("uxtb r0, r1", 0xffffffff, r0, r1, 0); 620 TESTINST2("sxtb r0, r1", 0, r0, r1, 0); 621 TESTINST2("sxtb r0, r1", 1, r0, r1, 0); 622 TESTINST2("sxtb r0, r1", 0xff, r0, r1, 0); 623 TESTINST2("sxtb r0, r1", 0xffffffff, r0, r1, 0); 624 625 TESTINST2("uxth r0, r1", 0, r0, r1, 0); 626 TESTINST2("uxth r0, r1", 1, r0, r1, 0); 627 TESTINST2("uxth r0, r1", 0xffff, r0, r1, 0); 628 TESTINST2("uxth r0, r1", 0xffffffff, r0, r1, 0); 629 TESTINST2("sxth r0, r1", 0, r0, r1, 0); 630 TESTINST2("sxth r0, r1", 1, r0, r1, 0); 631 TESTINST2("sxth r0, r1", 0x7fff, r0, r1, 0); 632 TESTINST2("sxth r0, r1", 0xffff, r0, r1, 0); 633 TESTINST2("sxth r0, r1", 0x10ffff, r0, r1, 0); 634 TESTINST2("sxth r0, r1", 0x107fff, r0, r1, 0); 635 TESTINST2("sxth r0, r1", 0xffffffff, r0, r1, 0); 636 637 TESTINST2("uxtb r0, r1, ror #0", 0x000000ff, r0, r1, 0); 638 TESTINST2("uxtb r0, r1, ror #8", 0x000000ff, r0, r1, 0); 639 TESTINST2("uxtb r0, r1, ror #8", 0x0000ff00, r0, r1, 0); 640 TESTINST2("uxtb r0, r1, ror #16", 0x00ff0000, r0, r1, 0); 641 TESTINST2("uxtb r0, r1, ror #24", 0xff000000, r0, r1, 0); 642 643 TESTINST2("uxtb16 r0, r1", 0xffffffff, r0, r1, 0); 644 TESTINST2("uxtb16 r0, r1, ror #16", 0x0000ffff, r0, r1, 0); 645 TESTINST2("sxtb16 r0, r1", 0xffffffff, r0, r1, 0); 646 TESTINST2("sxtb16 r0, r1", 0x00ff00ff, r0, r1, 0); 647 TESTINST2("sxtb16 r0, r1", 0x007f007f, r0, r1, 0); 648 649 printf("------------ BFI ------------\n"); 650 651 /* bfi rDst, rSrc, #lsb-in-dst, #number-of-bits-to-copy */ 652 TESTINST2("bfi r0, r1, #0, #11", 0xAAAAAAAA, r0, r1, 0); 653 TESTINST2("bfi r0, r1, #1, #11", 0xAAAAAAAA, r0, r1, 0); 654 TESTINST2("bfi r0, r1, #2, #11", 0xAAAAAAAA, r0, r1, 0); 655 656 TESTINST2("bfi r0, r1, #19, #11", 0xFFFFFFFF, r0, r1, 0); 657 TESTINST2("bfi r0, r1, #20, #11", 0xFFFFFFFF, r0, r1, 0); 658 TESTINST2("bfi r0, r1, #21, #11", 0xFFFFFFFF, r0, r1, 0); 659 660 TESTINST2("bfi r0, r1, #0, #32", 0xFFFFFFFF, r0, r1, 0); 661 TESTINST2("bfi r0, r1, #1, #31", 0xFFFFFFFF, r0, r1, 0); 662 663 TESTINST2("bfi r0, r1, #29, #3", 0xFFFFFFFF, r0, r1, 0); 664 TESTINST2("bfi r0, r1, #30, #2", 0xFFFFFFFF, r0, r1, 0); 665 TESTINST2("bfi r0, r1, #31, #1", 0xFFFFFFFF, r0, r1, 0); 666 667 printf("------------ BFC ------------\n"); 668 669 /* bfi rDst, #lsb-in-dst, #number-of-bits-to-copy */ 670 TESTINST2("bfc r0, #0, #11", 0xAAAAAAAA, r0, r1, 0); 671 TESTINST2("bfc r0, #1, #11", 0xAAAAAAAA, r0, r1, 0); 672 TESTINST2("bfc r0, #2, #11", 0xAAAAAAAA, r0, r1, 0); 673 674 TESTINST2("bfc r0, #19, #11", 0xFFFFFFFF, r0, r1, 0); 675 TESTINST2("bfc r0, #20, #11", 0xFFFFFFFF, r0, r1, 0); 676 TESTINST2("bfc r0, #21, #11", 0xFFFFFFFF, r0, r1, 0); 677 678 TESTINST2("bfc r0, #0, #32", 0xFFFFFFFF, r0, r1, 0); 679 TESTINST2("bfc r0, #1, #31", 0xFFFFFFFF, r0, r1, 0); 680 681 TESTINST2("bfc r0, #29, #3", 0xFFFFFFFF, r0, r1, 0); 682 TESTINST2("bfc r0, #30, #2", 0xFFFFFFFF, r0, r1, 0); 683 TESTINST2("bfc r0, #31, #1", 0xFFFFFFFF, r0, r1, 0); 684 685 printf("------------ SBFX ------------\n"); 686 687 /* sbfx rDst, rSrc, #lsb, #width */ 688 TESTINST2("sbfx r0, r1, #0, #1", 0x00000000, r0, r1, 0); 689 TESTINST2("sbfx r0, r1, #0, #1", 0x00000001, r0, r1, 0); 690 TESTINST2("sbfx r0, r1, #1, #1", 0x00000000, r0, r1, 0); 691 TESTINST2("sbfx r0, r1, #1, #1", 0x00000001, r0, r1, 0); 692 TESTINST2("sbfx r0, r1, #1, #1", 0x00000002, r0, r1, 0); 693 TESTINST2("sbfx r0, r1, #1, #1", 0x00000003, r0, r1, 0); 694 695 TESTINST2("sbfx r0, r1, #0, #2", 0x00000000, r0, r1, 0); 696 TESTINST2("sbfx r0, r1, #0, #2", 0x00000001, r0, r1, 0); 697 TESTINST2("sbfx r0, r1, #1, #2", 0x00000000, r0, r1, 0); 698 TESTINST2("sbfx r0, r1, #1, #2", 0x00000001, r0, r1, 0); 699 TESTINST2("sbfx r0, r1, #1, #2", 0x00000002, r0, r1, 0); 700 TESTINST2("sbfx r0, r1, #1, #2", 0x00000003, r0, r1, 0); 701 702 TESTINST2("sbfx r0, r1, #0, #11", 0xAAAAAAAA, r0, r1, 0); 703 TESTINST2("sbfx r0, r1, #1, #11", 0xAAAAAAAA, r0, r1, 0); 704 TESTINST2("sbfx r0, r1, #2, #11", 0xAAAAAAAA, r0, r1, 0); 705 706 TESTINST2("sbfx r0, r1, #2, #11", 0xAAAAAAAA, r0, r1, 0); 707 708 TESTINST2("sbfx r0, r1, #31, #1", 0xAAAAAAAA, r0, r1, 0); 709 TESTINST2("sbfx r0, r1, #30, #2", 0xAAAAAAAA, r0, r1, 0); 710 711 printf("------------ UBFX ------------\n"); 712 713 /* ubfx rDst, rSrc, #lsb, #width */ 714 TESTINST2("ubfx r0, r1, #0, #1", 0x00000000, r0, r1, 0); 715 TESTINST2("ubfx r0, r1, #0, #1", 0x00000001, r0, r1, 0); 716 TESTINST2("ubfx r0, r1, #1, #1", 0x00000000, r0, r1, 0); 717 TESTINST2("ubfx r0, r1, #1, #1", 0x00000001, r0, r1, 0); 718 TESTINST2("ubfx r0, r1, #1, #1", 0x00000002, r0, r1, 0); 719 TESTINST2("ubfx r0, r1, #1, #1", 0x00000003, r0, r1, 0); 720 721 TESTINST2("ubfx r0, r1, #0, #2", 0x00000000, r0, r1, 0); 722 TESTINST2("ubfx r0, r1, #0, #2", 0x00000001, r0, r1, 0); 723 TESTINST2("ubfx r0, r1, #1, #2", 0x00000000, r0, r1, 0); 724 TESTINST2("ubfx r0, r1, #1, #2", 0x00000001, r0, r1, 0); 725 TESTINST2("ubfx r0, r1, #1, #2", 0x00000002, r0, r1, 0); 726 TESTINST2("ubfx r0, r1, #1, #2", 0x00000003, r0, r1, 0); 727 728 TESTINST2("ubfx r0, r1, #0, #11", 0xAAAAAAAA, r0, r1, 0); 729 TESTINST2("ubfx r0, r1, #1, #11", 0xAAAAAAAA, r0, r1, 0); 730 TESTINST2("ubfx r0, r1, #2, #11", 0xAAAAAAAA, r0, r1, 0); 731 732 TESTINST2("ubfx r0, r1, #2, #11", 0xAAAAAAAA, r0, r1, 0); 733 734 TESTINST2("ubfx r0, r1, #31, #1", 0xAAAAAAAA, r0, r1, 0); 735 TESTINST2("ubfx r0, r1, #30, #2", 0xAAAAAAAA, r0, r1, 0); 736 737 printf("------------ SMULL{B,T}{B,T} ------------\n"); 738 /* SMULxx rD, rN, rM */ 739 740 TESTINST3("smulbb r0, r1, r2", 0x00030000, 0x00040000, r0, r1, r2, 0); 741 TESTINST3("smulbb r0, r1, r2", 0x00030001, 0x00040002, r0, r1, r2, 0); 742 TESTINST3("smulbb r0, r1, r2", 0x00038001, 0x00047fff, r0, r1, r2, 0); 743 TESTINST3("smulbb r0, r1, r2", 0x00037fff, 0x00047fff, r0, r1, r2, 0); 744 TESTINST3("smulbb r0, r1, r2", 0x0003ffff, 0x0004ffff, r0, r1, r2, 0); 745 746 printf("------------ SXTAB ------------\n"); 747 TESTINST3("sxtab r0, r1, r2, ROR #24", 0x31415927, 0x27182819, 748 r0, r1, r2, 0); 749 TESTINST3("sxtab r0, r1, r2, ROR #16", 0x31415927, 0x27182819, 750 r0, r1, r2, 0); 751 TESTINST3("sxtab r0, r1, r2, ROR #8", 0x31415927, 0x27182819, 752 r0, r1, r2, 0); 753 TESTINST3("sxtab r0, r1, r2, ROR #0", 0x31415927, 0x27182819, 754 r0, r1, r2, 0); 755 756 TESTINST3("sxtab r0, r1, r2, ROR #24", 0x31415927, 0x27182899, 757 r0, r1, r2, 0); 758 TESTINST3("sxtab r0, r1, r2, ROR #16", 0x31415927, 0x27182899, 759 r0, r1, r2, 0); 760 TESTINST3("sxtab r0, r1, r2, ROR #8", 0x31415927, 0x27182899, 761 r0, r1, r2, 0); 762 TESTINST3("sxtab r0, r1, r2, ROR #0", 0x31415927, 0x27182899, 763 r0, r1, r2, 0); 764 765 printf("------------ UXTAB ------------\n"); 766 TESTINST3("uxtab r0, r1, r2, ROR #24", 0x31415927, 0x27182819, 767 r0, r1, r2, 0); 768 TESTINST3("uxtab r0, r1, r2, ROR #16", 0x31415927, 0x27182819, 769 r0, r1, r2, 0); 770 TESTINST3("uxtab r0, r1, r2, ROR #8", 0x31415927, 0x27182819, 771 r0, r1, r2, 0); 772 TESTINST3("uxtab r0, r1, r2, ROR #0", 0x31415927, 0x27182819, 773 r0, r1, r2, 0); 774 775 TESTINST3("uxtab r0, r1, r2, ROR #24", 0x31415927, 0x27182899, 776 r0, r1, r2, 0); 777 TESTINST3("uxtab r0, r1, r2, ROR #16", 0x31415927, 0x27182899, 778 r0, r1, r2, 0); 779 TESTINST3("uxtab r0, r1, r2, ROR #8", 0x31415927, 0x27182899, 780 r0, r1, r2, 0); 781 TESTINST3("uxtab r0, r1, r2, ROR #0", 0x31415927, 0x27182899, 782 r0, r1, r2, 0); 783 784 printf("------------ SXTAH ------------\n"); 785 TESTINST3("sxtah r0, r1, r2, ROR #24", 0x31415927, 0x27182819, 786 r0, r1, r2, 0); 787 TESTINST3("sxtah r0, r1, r2, ROR #16", 0x31415927, 0x27182819, 788 r0, r1, r2, 0); 789 TESTINST3("sxtah r0, r1, r2, ROR #8 ", 0x31415927, 0x27182819, 790 r0, r1, r2, 0); 791 TESTINST3("sxtah r0, r1, r2, ROR #0 ", 0x31415927, 0x27182819, 792 r0, r1, r2, 0); 793 794 TESTINST3("sxtah r0, r1, r2, ROR #24", 0x31415927, 0x27189819, 795 r0, r1, r2, 0); 796 TESTINST3("sxtah r0, r1, r2, ROR #16", 0x31415927, 0x27189819, 797 r0, r1, r2, 0); 798 TESTINST3("sxtah r0, r1, r2, ROR #8 ", 0x31415927, 0x27189819, 799 r0, r1, r2, 0); 800 TESTINST3("sxtah r0, r1, r2, ROR #0 ", 0x31415927, 0x27189819, 801 r0, r1, r2, 0); 802 803 printf("------------ UXTAH ------------\n"); 804 TESTINST3("uxtah r0, r1, r2, ROR #24", 0x31415927, 0x27182819, 805 r0, r1, r2, 0); 806 TESTINST3("uxtah r0, r1, r2, ROR #16", 0x31415927, 0x27182819, 807 r0, r1, r2, 0); 808 TESTINST3("uxtah r0, r1, r2, ROR #8 ", 0x31415927, 0x27182819, 809 r0, r1, r2, 0); 810 TESTINST3("uxtah r0, r1, r2, ROR #0 ", 0x31415927, 0x27182819, 811 r0, r1, r2, 0); 812 813 TESTINST3("uxtah r0, r1, r2, ROR #24", 0x31415927, 0x27189819, 814 r0, r1, r2, 0); 815 TESTINST3("uxtah r0, r1, r2, ROR #16", 0x31415927, 0x27189819, 816 r0, r1, r2, 0); 817 TESTINST3("uxtah r0, r1, r2, ROR #8 ", 0x31415927, 0x27189819, 818 r0, r1, r2, 0); 819 TESTINST3("uxtah r0, r1, r2, ROR #0 ", 0x31415927, 0x27189819, 820 r0, r1, r2, 0); 821 822 printf("------------ PLD/PLDW (begin) ------------\n"); 823 /* These don't have any effect on the architected state, so, 824 uh, there's no result values to check. Just _do_ some of 825 them and check Valgrind's instruction decoder eats them up 826 without complaining. */ 827 { int alocal; 828 printf("pld reg +/- imm12 cases\n"); 829 __asm__ __volatile__( "pld [%0, #128]" : :/*in*/"r"(&alocal) ); 830 __asm__ __volatile__( "pld [%0, #-128]" : :/*in*/"r"(&alocal) ); 831 __asm__ __volatile__( "pld [r15, #-128]" : :/*in*/"r"(&alocal) ); 832 833 // apparently pldw is v7 only 834 //__asm__ __volatile__( "pldw [%0, #128]" : :/*in*/"r"(&alocal) ); 835 //__asm__ __volatile__( "pldw [%0, #-128]" : :/*in*/"r"(&alocal) ); 836 //__asm__ __volatile__( "pldw [r15, #128]" : :/*in*/"r"(&alocal) ); 837 838 printf("pld reg +/- shifted reg cases\n"); 839 __asm__ __volatile__( "pld [%0, %1]" : : /*in*/"r"(&alocal), "r"(0) ); 840 __asm__ __volatile__( "pld [%0, %1, LSL #1]" : : /*in*/"r"(&alocal), "r"(0) ); 841 __asm__ __volatile__( "pld [%0, %1, LSR #1]" : : /*in*/"r"(&alocal), "r"(0) ); 842 __asm__ __volatile__( "pld [%0, %1, ASR #1]" : : /*in*/"r"(&alocal), "r"(0) ); 843 __asm__ __volatile__( "pld [%0, %1, ROR #1]" : : /*in*/"r"(&alocal), "r"(0) ); 844 __asm__ __volatile__( "pld [%0, %1, RRX]" : : /*in*/"r"(&alocal), "r"(0) ); 845 } 846 printf("------------ PLD/PLDW (done) ------------\n"); 847 848 printf("------------ RBIT ------------\n"); 849 TESTINST2("rbit r0, r1", 0x00000000, r0, r1, 0); 850 TESTINST2("rbit r0, r1", 0xFFFFFFFF, r0, r1, 0); 851 TESTINST2("rbit r0, r1", 0x80000000, r0, r1, 0); 852 TESTINST2("rbit r0, r1", 0x00000001, r0, r1, 0); 853 TESTINST2("rbit r0, r1", 0x31415927, r0, r1, 0); 854 TESTINST2("rbit r0, r1", 0x14141562, r0, r1, 0); 855 TESTINST2("rbit r0, r1", 0xabe8391f, r0, r1, 0); 856 TESTINST2("rbit r0, r1", 0x9028aa80, r0, r1, 0); 857 TESTINST2("rbit r0, r1", 0xead1fc6d, r0, r1, 0); 858 TESTINST2("rbit r0, r1", 0x35c98c55, r0, r1, 0); 859 TESTINST2("rbit r0, r1", 0x534af1eb, r0, r1, 0); 860 TESTINST2("rbit r0, r1", 0x45511b08, r0, r1, 0); 861 TESTINST2("rbit r0, r1", 0x90077f71, r0, r1, 0); 862 TESTINST2("rbit r0, r1", 0xde8ca84b, r0, r1, 0); 863 TESTINST2("rbit r0, r1", 0xe37a0dda, r0, r1, 0); 864 TESTINST2("rbit r0, r1", 0xe5b83d4b, r0, r1, 0); 865 TESTINST2("rbit r0, r1", 0xbb6d14ec, r0, r1, 0); 866 TESTINST2("rbit r0, r1", 0x68983cc9, r0, r1, 0); 867 868 printf("------------ REV ------------\n"); 869 TESTINST2("rev r0, r1", 0x00000000, r0, r1, 0); 870 TESTINST2("rev r0, r1", 0xFFFFFFFF, r0, r1, 0); 871 TESTINST2("rev r0, r1", 0x80000000, r0, r1, 0); 872 TESTINST2("rev r0, r1", 0x00000001, r0, r1, 0); 873 TESTINST2("rev r0, r1", 0x31415927, r0, r1, 0); 874 TESTINST2("rev r0, r1", 0x14141562, r0, r1, 0); 875 TESTINST2("rev r0, r1", 0xabe8391f, r0, r1, 0); 876 TESTINST2("rev r0, r1", 0x9028aa80, r0, r1, 0); 877 TESTINST2("rev r0, r1", 0xead1fc6d, r0, r1, 0); 878 TESTINST2("rev r0, r1", 0x35c98c55, r0, r1, 0); 879 TESTINST2("rev r0, r1", 0x534af1eb, r0, r1, 0); 880 TESTINST2("rev r0, r1", 0x45511b08, r0, r1, 0); 881 TESTINST2("rev r0, r1", 0x90077f71, r0, r1, 0); 882 TESTINST2("rev r0, r1", 0xde8ca84b, r0, r1, 0); 883 TESTINST2("rev r0, r1", 0xe37a0dda, r0, r1, 0); 884 TESTINST2("rev r0, r1", 0xe5b83d4b, r0, r1, 0); 885 TESTINST2("rev r0, r1", 0xbb6d14ec, r0, r1, 0); 886 TESTINST2("rev r0, r1", 0x68983cc9, r0, r1, 0); 887 888 printf("------------ REV16 ------------\n"); 889 TESTINST2("rev16 r0, r1", 0x00000000, r0, r1, 0); 890 TESTINST2("rev16 r0, r1", 0xFFFFFFFF, r0, r1, 0); 891 TESTINST2("rev16 r0, r1", 0x80000000, r0, r1, 0); 892 TESTINST2("rev16 r0, r1", 0x00000001, r0, r1, 0); 893 TESTINST2("rev16 r0, r1", 0x31415927, r0, r1, 0); 894 TESTINST2("rev16 r0, r1", 0x14141562, r0, r1, 0); 895 TESTINST2("rev16 r0, r1", 0xabe8391f, r0, r1, 0); 896 TESTINST2("rev16 r0, r1", 0x9028aa80, r0, r1, 0); 897 TESTINST2("rev16 r0, r1", 0xead1fc6d, r0, r1, 0); 898 TESTINST2("rev16 r0, r1", 0x35c98c55, r0, r1, 0); 899 TESTINST2("rev16 r0, r1", 0x534af1eb, r0, r1, 0); 900 TESTINST2("rev16 r0, r1", 0x45511b08, r0, r1, 0); 901 TESTINST2("rev16 r0, r1", 0x90077f71, r0, r1, 0); 902 TESTINST2("rev16 r0, r1", 0xde8ca84b, r0, r1, 0); 903 TESTINST2("rev16 r0, r1", 0xe37a0dda, r0, r1, 0); 904 TESTINST2("rev16 r0, r1", 0xe5b83d4b, r0, r1, 0); 905 TESTINST2("rev16 r0, r1", 0xbb6d14ec, r0, r1, 0); 906 TESTINST2("rev16 r0, r1", 0x68983cc9, r0, r1, 0); 907 908 printf("------------ NOP (begin) ------------\n"); 909 printf("nop\n"); 910 __asm__ __volatile__("nop" ::: "memory","cc"); 911 printf("nopeq\n"); 912 __asm__ __volatile__("nopeq" ::: "memory","cc"); 913 printf("nopne\n"); 914 __asm__ __volatile__("nopne" ::: "memory","cc"); 915 printf("------------ NOP (end) ------------\n"); 916 917 return 0; 918 } 919