1 #include <stdio.h> 2 3 #define branch(mask,icmm,_v1) \ 4 ({ \ 5 unsigned char taken; \ 6 unsigned b1 = _v1; \ 7 asm volatile( " larl 1, 2f\n\t" \ 8 " l 0, 0(1)\n\t" \ 9 " icm 0," #icmm",%[b1]\n\t" \ 10 " brc " #mask " ,1f\n\t" \ 11 " mvi %[taken],0\n\t" \ 12 " j 0f\n\t" \ 13 "1: mvi %[taken],1\n\t" \ 14 " j 0f\n\t" \ 15 "2: .long 0xffffffff\n\t" \ 16 "0: bcr 0,0 /* nop */\n\t" \ 17 : [taken] "=Q" (taken) \ 18 : [b1] "Q"(b1) \ 19 : "cc", "0","1"); \ 20 taken; \ 21 }) 22 23 void 24 icm_mask_0(void) 25 { 26 int wrong, ok; 27 unsigned v1; 28 29 printf("Test #1 mask == 0, value == 0xFFFFFFFF --> cc == 0\n"); 30 31 v1 = 0xFFFFFFFF; 32 wrong = ok = 0; 33 34 if (branch(0, 0, v1)) ++wrong; else ++ok; 35 if (branch(1, 0, v1)) ++wrong; else ++ok; 36 if (branch(2, 0, v1)) ++wrong; else ++ok; 37 if (branch(3, 0, v1)) ++wrong; else ++ok; 38 if (branch(4, 0, v1)) ++wrong; else ++ok; 39 if (branch(5, 0, v1)) ++wrong; else ++ok; 40 if (branch(6, 0, v1)) ++wrong; else ++ok; 41 if (branch(7, 0, v1)) ++wrong; else ++ok; 42 if (branch(8, 0, v1)) ++ok; else ++wrong; 43 if (branch(9, 0, v1)) ++ok; else ++wrong; 44 if (branch(10, 0, v1)) ++ok; else ++wrong; 45 if (branch(11, 0, v1)) ++ok; else ++wrong; 46 if (branch(12, 0, v1)) ++ok; else ++wrong; 47 if (branch(13, 0, v1)) ++ok; else ++wrong; 48 if (branch(14, 0, v1)) ++ok; else ++wrong; 49 if (branch(15, 0, v1)) ++ok; else ++wrong; 50 51 if (wrong != 0 || ok != 16) 52 printf("FAILED\n"); 53 else 54 printf("OK\n"); 55 } 56 57 void 58 icm_value_0(void) 59 { 60 int wrong, ok; 61 unsigned v1; 62 63 printf("Test #2 mask == 0xF, value == 0 --> cc == 0\n"); 64 65 v1 = 0; 66 wrong = ok = 0; 67 68 if (branch(0, 15, v1)) ++wrong; else ++ok; 69 if (branch(1, 15, v1)) ++wrong; else ++ok; 70 if (branch(2, 15, v1)) ++wrong; else ++ok; 71 if (branch(3, 15, v1)) ++wrong; else ++ok; 72 if (branch(4, 15, v1)) ++wrong; else ++ok; 73 if (branch(5, 15, v1)) ++wrong; else ++ok; 74 if (branch(6, 15, v1)) ++wrong; else ++ok; 75 if (branch(7, 15, v1)) ++wrong; else ++ok; 76 if (branch(8, 15, v1)) ++ok; else ++wrong; 77 if (branch(9, 15, v1)) ++ok; else ++wrong; 78 if (branch(10, 15, v1)) ++ok; else ++wrong; 79 if (branch(11, 15, v1)) ++ok; else ++wrong; 80 if (branch(12, 15, v1)) ++ok; else ++wrong; 81 if (branch(13, 15, v1)) ++ok; else ++wrong; 82 if (branch(14, 15, v1)) ++ok; else ++wrong; 83 if (branch(15, 15, v1)) ++ok; else ++wrong; 84 85 if (wrong != 0 || ok != 16) 86 printf("FAILED\n"); 87 else 88 printf("OK\n"); 89 } 90 91 /* loads one byte */ 92 void 93 icm_one_byte_msb_set(void) 94 { 95 int wrong, ok; 96 unsigned v1; 97 98 printf("Test #3 load one byte, msb set --> cc == 1\n"); 99 100 v1 = 0x80000000; 101 wrong = ok = 0; 102 103 if (branch(0, 8, v1)) ++wrong; else ++ok; 104 if (branch(1, 8, v1)) ++wrong; else ++ok; 105 if (branch(2, 8, v1)) ++wrong; else ++ok; 106 if (branch(3, 8, v1)) ++wrong; else ++ok; 107 if (branch(4, 8, v1)) ++ok; else ++wrong; 108 if (branch(5, 8, v1)) ++ok; else ++wrong; 109 if (branch(6, 8, v1)) ++ok; else ++wrong; 110 if (branch(7, 8, v1)) ++ok; else ++wrong; 111 if (branch(8, 8, v1)) ++wrong; else ++ok; 112 if (branch(9, 8, v1)) ++wrong; else ++ok; 113 if (branch(10, 8, v1)) ++wrong; else ++ok; 114 if (branch(11, 8, v1)) ++wrong; else ++ok; 115 if (branch(12, 8, v1)) ++ok; else ++wrong; 116 if (branch(13, 8, v1)) ++ok; else ++wrong; 117 if (branch(14, 8, v1)) ++ok; else ++wrong; 118 if (branch(15, 8, v1)) ++ok; else ++wrong; 119 120 if (branch(0, 4, v1)) ++wrong; else ++ok; 121 if (branch(1, 4, v1)) ++wrong; else ++ok; 122 if (branch(2, 4, v1)) ++wrong; else ++ok; 123 if (branch(3, 4, v1)) ++wrong; else ++ok; 124 if (branch(4, 4, v1)) ++ok; else ++wrong; 125 if (branch(5, 4, v1)) ++ok; else ++wrong; 126 if (branch(6, 4, v1)) ++ok; else ++wrong; 127 if (branch(7, 4, v1)) ++ok; else ++wrong; 128 if (branch(8, 4, v1)) ++wrong; else ++ok; 129 if (branch(9, 4, v1)) ++wrong; else ++ok; 130 if (branch(10, 4, v1)) ++wrong; else ++ok; 131 if (branch(11, 4, v1)) ++wrong; else ++ok; 132 if (branch(12, 4, v1)) ++ok; else ++wrong; 133 if (branch(13, 4, v1)) ++ok; else ++wrong; 134 if (branch(14, 4, v1)) ++ok; else ++wrong; 135 if (branch(15, 4, v1)) ++ok; else ++wrong; 136 137 if (branch(0, 2, v1)) ++wrong; else ++ok; 138 if (branch(1, 2, v1)) ++wrong; else ++ok; 139 if (branch(2, 2, v1)) ++wrong; else ++ok; 140 if (branch(3, 2, v1)) ++wrong; else ++ok; 141 if (branch(4, 2, v1)) ++ok; else ++wrong; 142 if (branch(5, 2, v1)) ++ok; else ++wrong; 143 if (branch(6, 2, v1)) ++ok; else ++wrong; 144 if (branch(7, 2, v1)) ++ok; else ++wrong; 145 if (branch(8, 2, v1)) ++wrong; else ++ok; 146 if (branch(9, 2, v1)) ++wrong; else ++ok; 147 if (branch(10, 2, v1)) ++wrong; else ++ok; 148 if (branch(11, 2, v1)) ++wrong; else ++ok; 149 if (branch(12, 2, v1)) ++ok; else ++wrong; 150 if (branch(13, 2, v1)) ++ok; else ++wrong; 151 if (branch(14, 2, v1)) ++ok; else ++wrong; 152 if (branch(15, 2, v1)) ++ok; else ++wrong; 153 154 if (branch(0, 1, v1)) ++wrong; else ++ok; 155 if (branch(1, 1, v1)) ++wrong; else ++ok; 156 if (branch(2, 1, v1)) ++wrong; else ++ok; 157 if (branch(3, 1, v1)) ++wrong; else ++ok; 158 if (branch(4, 1, v1)) ++ok; else ++wrong; 159 if (branch(5, 1, v1)) ++ok; else ++wrong; 160 if (branch(6, 1, v1)) ++ok; else ++wrong; 161 if (branch(7, 1, v1)) ++ok; else ++wrong; 162 if (branch(8, 1, v1)) ++wrong; else ++ok; 163 if (branch(9, 1, v1)) ++wrong; else ++ok; 164 if (branch(10, 1, v1)) ++wrong; else ++ok; 165 if (branch(11, 1, v1)) ++wrong; else ++ok; 166 if (branch(12, 1, v1)) ++ok; else ++wrong; 167 if (branch(13, 1, v1)) ++ok; else ++wrong; 168 if (branch(14, 1, v1)) ++ok; else ++wrong; 169 if (branch(15, 1, v1)) ++ok; else ++wrong; 170 171 if (wrong != 0 || ok != 64) 172 printf("FAILED\n"); 173 else 174 printf("OK\n"); 175 } 176 177 /* loads two bytes */ 178 void 179 icm_two_bytes_msb_set(void) 180 { 181 int wrong, ok; 182 unsigned v1; 183 184 printf("Test #4 load two bytes, msb set --> cc == 1\n"); 185 186 v1 = 0x80000000; 187 wrong = ok = 0; 188 189 if (branch(0, 12, v1)) ++wrong; else ++ok; 190 if (branch(1, 12, v1)) ++wrong; else ++ok; 191 if (branch(2, 12, v1)) ++wrong; else ++ok; 192 if (branch(3, 12, v1)) ++wrong; else ++ok; 193 if (branch(4, 12, v1)) ++ok; else ++wrong; 194 if (branch(5, 12, v1)) ++ok; else ++wrong; 195 if (branch(6, 12, v1)) ++ok; else ++wrong; 196 if (branch(7, 12, v1)) ++ok; else ++wrong; 197 if (branch(8, 12, v1)) ++wrong; else ++ok; 198 if (branch(9, 12, v1)) ++wrong; else ++ok; 199 if (branch(10, 12, v1)) ++wrong; else ++ok; 200 if (branch(11, 12, v1)) ++wrong; else ++ok; 201 if (branch(12, 12, v1)) ++ok; else ++wrong; 202 if (branch(13, 12, v1)) ++ok; else ++wrong; 203 if (branch(14, 12, v1)) ++ok; else ++wrong; 204 if (branch(15, 12, v1)) ++ok; else ++wrong; 205 206 if (branch(0, 10, v1)) ++wrong; else ++ok; 207 if (branch(1, 10, v1)) ++wrong; else ++ok; 208 if (branch(2, 10, v1)) ++wrong; else ++ok; 209 if (branch(3, 10, v1)) ++wrong; else ++ok; 210 if (branch(4, 10, v1)) ++ok; else ++wrong; 211 if (branch(5, 10, v1)) ++ok; else ++wrong; 212 if (branch(6, 10, v1)) ++ok; else ++wrong; 213 if (branch(7, 10, v1)) ++ok; else ++wrong; 214 if (branch(8, 10, v1)) ++wrong; else ++ok; 215 if (branch(9, 10, v1)) ++wrong; else ++ok; 216 if (branch(10, 10, v1)) ++wrong; else ++ok; 217 if (branch(11, 10, v1)) ++wrong; else ++ok; 218 if (branch(12, 10, v1)) ++ok; else ++wrong; 219 if (branch(13, 10, v1)) ++ok; else ++wrong; 220 if (branch(14, 10, v1)) ++ok; else ++wrong; 221 if (branch(15, 10, v1)) ++ok; else ++wrong; 222 223 if (branch(0, 9, v1)) ++wrong; else ++ok; 224 if (branch(1, 9, v1)) ++wrong; else ++ok; 225 if (branch(2, 9, v1)) ++wrong; else ++ok; 226 if (branch(3, 9, v1)) ++wrong; else ++ok; 227 if (branch(4, 9, v1)) ++ok; else ++wrong; 228 if (branch(5, 9, v1)) ++ok; else ++wrong; 229 if (branch(6, 9, v1)) ++ok; else ++wrong; 230 if (branch(7, 9, v1)) ++ok; else ++wrong; 231 if (branch(8, 9, v1)) ++wrong; else ++ok; 232 if (branch(9, 9, v1)) ++wrong; else ++ok; 233 if (branch(10, 9, v1)) ++wrong; else ++ok; 234 if (branch(11, 9, v1)) ++wrong; else ++ok; 235 if (branch(12, 9, v1)) ++ok; else ++wrong; 236 if (branch(13, 9, v1)) ++ok; else ++wrong; 237 if (branch(14, 9, v1)) ++ok; else ++wrong; 238 if (branch(15, 9, v1)) ++ok; else ++wrong; 239 240 if (branch(0, 6, v1)) ++wrong; else ++ok; 241 if (branch(1, 6, v1)) ++wrong; else ++ok; 242 if (branch(2, 6, v1)) ++wrong; else ++ok; 243 if (branch(3, 6, v1)) ++wrong; else ++ok; 244 if (branch(4, 6, v1)) ++ok; else ++wrong; 245 if (branch(5, 6, v1)) ++ok; else ++wrong; 246 if (branch(6, 6, v1)) ++ok; else ++wrong; 247 if (branch(7, 6, v1)) ++ok; else ++wrong; 248 if (branch(8, 6, v1)) ++wrong; else ++ok; 249 if (branch(9, 6, v1)) ++wrong; else ++ok; 250 if (branch(10, 6, v1)) ++wrong; else ++ok; 251 if (branch(11, 6, v1)) ++wrong; else ++ok; 252 if (branch(12, 6, v1)) ++ok; else ++wrong; 253 if (branch(13, 6, v1)) ++ok; else ++wrong; 254 if (branch(14, 6, v1)) ++ok; else ++wrong; 255 if (branch(15, 6, v1)) ++ok; else ++wrong; 256 257 if (branch(0, 5, v1)) ++wrong; else ++ok; 258 if (branch(1, 5, v1)) ++wrong; else ++ok; 259 if (branch(2, 5, v1)) ++wrong; else ++ok; 260 if (branch(3, 5, v1)) ++wrong; else ++ok; 261 if (branch(4, 5, v1)) ++ok; else ++wrong; 262 if (branch(5, 5, v1)) ++ok; else ++wrong; 263 if (branch(6, 5, v1)) ++ok; else ++wrong; 264 if (branch(7, 5, v1)) ++ok; else ++wrong; 265 if (branch(8, 5, v1)) ++wrong; else ++ok; 266 if (branch(9, 5, v1)) ++wrong; else ++ok; 267 if (branch(10, 5, v1)) ++wrong; else ++ok; 268 if (branch(11, 5, v1)) ++wrong; else ++ok; 269 if (branch(12, 5, v1)) ++ok; else ++wrong; 270 if (branch(13, 5, v1)) ++ok; else ++wrong; 271 if (branch(14, 5, v1)) ++ok; else ++wrong; 272 if (branch(15, 5, v1)) ++ok; else ++wrong; 273 274 if (branch(0, 3, v1)) ++wrong; else ++ok; 275 if (branch(1, 3, v1)) ++wrong; else ++ok; 276 if (branch(2, 3, v1)) ++wrong; else ++ok; 277 if (branch(3, 3, v1)) ++wrong; else ++ok; 278 if (branch(4, 3, v1)) ++ok; else ++wrong; 279 if (branch(5, 3, v1)) ++ok; else ++wrong; 280 if (branch(6, 3, v1)) ++ok; else ++wrong; 281 if (branch(7, 3, v1)) ++ok; else ++wrong; 282 if (branch(8, 3, v1)) ++wrong; else ++ok; 283 if (branch(9, 3, v1)) ++wrong; else ++ok; 284 if (branch(10, 3, v1)) ++wrong; else ++ok; 285 if (branch(11, 3, v1)) ++wrong; else ++ok; 286 if (branch(12, 3, v1)) ++ok; else ++wrong; 287 if (branch(13, 3, v1)) ++ok; else ++wrong; 288 if (branch(14, 3, v1)) ++ok; else ++wrong; 289 if (branch(15, 3, v1)) ++ok; else ++wrong; 290 291 if (wrong != 0 || ok != 96) 292 printf("FAILED\n"); 293 else 294 printf("OK\n"); 295 } 296 297 /* loads three bytes */ 298 void 299 icm_three_bytes_msb_set(void) 300 { 301 int wrong, ok; 302 unsigned v1; 303 304 printf("Test #5 load three bytes, msb set --> cc == 1\n"); 305 306 v1 = 0x80000000; 307 wrong = ok = 0; 308 309 if (branch(0, 14, v1)) ++wrong; else ++ok; 310 if (branch(1, 14, v1)) ++wrong; else ++ok; 311 if (branch(2, 14, v1)) ++wrong; else ++ok; 312 if (branch(3, 14, v1)) ++wrong; else ++ok; 313 if (branch(4, 14, v1)) ++ok; else ++wrong; 314 if (branch(5, 14, v1)) ++ok; else ++wrong; 315 if (branch(6, 14, v1)) ++ok; else ++wrong; 316 if (branch(7, 14, v1)) ++ok; else ++wrong; 317 if (branch(8, 14, v1)) ++wrong; else ++ok; 318 if (branch(9, 14, v1)) ++wrong; else ++ok; 319 if (branch(10, 14, v1)) ++wrong; else ++ok; 320 if (branch(11, 14, v1)) ++wrong; else ++ok; 321 if (branch(12, 14, v1)) ++ok; else ++wrong; 322 if (branch(13, 14, v1)) ++ok; else ++wrong; 323 if (branch(14, 14, v1)) ++ok; else ++wrong; 324 if (branch(15, 14, v1)) ++ok; else ++wrong; 325 326 if (branch(0, 13, v1)) ++wrong; else ++ok; 327 if (branch(1, 13, v1)) ++wrong; else ++ok; 328 if (branch(2, 13, v1)) ++wrong; else ++ok; 329 if (branch(3, 13, v1)) ++wrong; else ++ok; 330 if (branch(4, 13, v1)) ++ok; else ++wrong; 331 if (branch(5, 13, v1)) ++ok; else ++wrong; 332 if (branch(6, 13, v1)) ++ok; else ++wrong; 333 if (branch(7, 13, v1)) ++ok; else ++wrong; 334 if (branch(8, 13, v1)) ++wrong; else ++ok; 335 if (branch(9, 13, v1)) ++wrong; else ++ok; 336 if (branch(10, 13, v1)) ++wrong; else ++ok; 337 if (branch(11, 13, v1)) ++wrong; else ++ok; 338 if (branch(12, 13, v1)) ++ok; else ++wrong; 339 if (branch(13, 13, v1)) ++ok; else ++wrong; 340 if (branch(14, 13, v1)) ++ok; else ++wrong; 341 if (branch(15, 13, v1)) ++ok; else ++wrong; 342 343 if (branch(0, 11, v1)) ++wrong; else ++ok; 344 if (branch(1, 11, v1)) ++wrong; else ++ok; 345 if (branch(2, 11, v1)) ++wrong; else ++ok; 346 if (branch(3, 11, v1)) ++wrong; else ++ok; 347 if (branch(4, 11, v1)) ++ok; else ++wrong; 348 if (branch(5, 11, v1)) ++ok; else ++wrong; 349 if (branch(6, 11, v1)) ++ok; else ++wrong; 350 if (branch(7, 11, v1)) ++ok; else ++wrong; 351 if (branch(8, 11, v1)) ++wrong; else ++ok; 352 if (branch(9, 11, v1)) ++wrong; else ++ok; 353 if (branch(10, 11, v1)) ++wrong; else ++ok; 354 if (branch(11, 11, v1)) ++wrong; else ++ok; 355 if (branch(12, 11, v1)) ++ok; else ++wrong; 356 if (branch(13, 11, v1)) ++ok; else ++wrong; 357 if (branch(14, 11, v1)) ++ok; else ++wrong; 358 if (branch(15, 11, v1)) ++ok; else ++wrong; 359 360 if (branch(0, 7, v1)) ++wrong; else ++ok; 361 if (branch(1, 7, v1)) ++wrong; else ++ok; 362 if (branch(2, 7, v1)) ++wrong; else ++ok; 363 if (branch(3, 7, v1)) ++wrong; else ++ok; 364 if (branch(4, 7, v1)) ++ok; else ++wrong; 365 if (branch(5, 7, v1)) ++ok; else ++wrong; 366 if (branch(6, 7, v1)) ++ok; else ++wrong; 367 if (branch(7, 7, v1)) ++ok; else ++wrong; 368 if (branch(8, 7, v1)) ++wrong; else ++ok; 369 if (branch(9, 7, v1)) ++wrong; else ++ok; 370 if (branch(10, 7, v1)) ++wrong; else ++ok; 371 if (branch(11, 7, v1)) ++wrong; else ++ok; 372 if (branch(12, 7, v1)) ++ok; else ++wrong; 373 if (branch(13, 7, v1)) ++ok; else ++wrong; 374 if (branch(14, 7, v1)) ++ok; else ++wrong; 375 if (branch(15, 7, v1)) ++ok; else ++wrong; 376 377 if (wrong != 0 || ok != 64) 378 printf("FAILED\n"); 379 else 380 printf("OK\n"); 381 } 382 383 /* loads four bytes */ 384 void 385 icm_four_bytes_msb_set(void) 386 { 387 int wrong, ok; 388 unsigned v1; 389 390 printf("Test #6 load four bytes, msb set --> cc == 1\n"); 391 392 v1 = 0x80000000; 393 wrong = ok = 0; 394 395 if (branch(0, 15, v1)) ++wrong; else ++ok; 396 if (branch(1, 15, v1)) ++wrong; else ++ok; 397 if (branch(2, 15, v1)) ++wrong; else ++ok; 398 if (branch(3, 15, v1)) ++wrong; else ++ok; 399 if (branch(4, 15, v1)) ++ok; else ++wrong; 400 if (branch(5, 15, v1)) ++ok; else ++wrong; 401 if (branch(6, 15, v1)) ++ok; else ++wrong; 402 if (branch(7, 15, v1)) ++ok; else ++wrong; 403 if (branch(8, 15, v1)) ++wrong; else ++ok; 404 if (branch(9, 15, v1)) ++wrong; else ++ok; 405 if (branch(10, 15, v1)) ++wrong; else ++ok; 406 if (branch(11, 15, v1)) ++wrong; else ++ok; 407 if (branch(12, 15, v1)) ++ok; else ++wrong; 408 if (branch(13, 15, v1)) ++ok; else ++wrong; 409 if (branch(14, 15, v1)) ++ok; else ++wrong; 410 if (branch(15, 15, v1)) ++ok; else ++wrong; 411 412 if (wrong != 0 || ok != 16) 413 printf("FAILED\n"); 414 else 415 printf("OK\n"); 416 } 417 418 /* loads one byte */ 419 void 420 icm_one_byte_msb_not_set(void) 421 { 422 int wrong, ok, v1; 423 424 printf("Test #7 load one byte, msb not set --> cc == 2\n"); 425 426 v1 = 0x7FFFFFFF; 427 wrong = ok = 0; 428 429 if (branch(0, 8, v1)) ++wrong; else ++ok; 430 if (branch(1, 8, v1)) ++wrong; else ++ok; 431 if (branch(2, 8, v1)) ++ok; else ++wrong; 432 if (branch(3, 8, v1)) ++ok; else ++wrong; 433 if (branch(4, 8, v1)) ++wrong; else ++ok; 434 if (branch(5, 8, v1)) ++wrong; else ++ok; 435 if (branch(6, 8, v1)) ++ok; else ++wrong; 436 if (branch(7, 8, v1)) ++ok; else ++wrong; 437 if (branch(8, 8, v1)) ++wrong; else ++ok; 438 if (branch(9, 8, v1)) ++wrong; else ++ok; 439 if (branch(10, 8, v1)) ++ok; else ++wrong; 440 if (branch(11, 8, v1)) ++ok; else ++wrong; 441 if (branch(12, 8, v1)) ++wrong; else ++ok; 442 if (branch(13, 8, v1)) ++wrong; else ++ok; 443 if (branch(14, 8, v1)) ++ok; else ++wrong; 444 if (branch(15, 8, v1)) ++ok; else ++wrong; 445 446 if (branch(0, 4, v1)) ++wrong; else ++ok; 447 if (branch(1, 4, v1)) ++wrong; else ++ok; 448 if (branch(2, 4, v1)) ++ok; else ++wrong; 449 if (branch(3, 4, v1)) ++ok; else ++wrong; 450 if (branch(4, 4, v1)) ++wrong; else ++ok; 451 if (branch(5, 4, v1)) ++wrong; else ++ok; 452 if (branch(6, 4, v1)) ++ok; else ++wrong; 453 if (branch(7, 4, v1)) ++ok; else ++wrong; 454 if (branch(8, 4, v1)) ++wrong; else ++ok; 455 if (branch(9, 4, v1)) ++wrong; else ++ok; 456 if (branch(10, 4, v1)) ++ok; else ++wrong; 457 if (branch(11, 4, v1)) ++ok; else ++wrong; 458 if (branch(12, 4, v1)) ++wrong; else ++ok; 459 if (branch(13, 4, v1)) ++wrong; else ++ok; 460 if (branch(14, 4, v1)) ++ok; else ++wrong; 461 if (branch(15, 4, v1)) ++ok; else ++wrong; 462 463 if (branch(0, 2, v1)) ++wrong; else ++ok; 464 if (branch(1, 2, v1)) ++wrong; else ++ok; 465 if (branch(2, 2, v1)) ++ok; else ++wrong; 466 if (branch(3, 2, v1)) ++ok; else ++wrong; 467 if (branch(4, 2, v1)) ++wrong; else ++ok; 468 if (branch(5, 2, v1)) ++wrong; else ++ok; 469 if (branch(6, 2, v1)) ++ok; else ++wrong; 470 if (branch(7, 2, v1)) ++ok; else ++wrong; 471 if (branch(8, 2, v1)) ++wrong; else ++ok; 472 if (branch(9, 2, v1)) ++wrong; else ++ok; 473 if (branch(10, 2, v1)) ++ok; else ++wrong; 474 if (branch(11, 2, v1)) ++ok; else ++wrong; 475 if (branch(12, 2, v1)) ++wrong; else ++ok; 476 if (branch(13, 2, v1)) ++wrong; else ++ok; 477 if (branch(14, 2, v1)) ++ok; else ++wrong; 478 if (branch(15, 2, v1)) ++ok; else ++wrong; 479 480 if (branch(0, 1, v1)) ++wrong; else ++ok; 481 if (branch(1, 1, v1)) ++wrong; else ++ok; 482 if (branch(2, 1, v1)) ++ok; else ++wrong; 483 if (branch(3, 1, v1)) ++ok; else ++wrong; 484 if (branch(4, 1, v1)) ++wrong; else ++ok; 485 if (branch(5, 1, v1)) ++wrong; else ++ok; 486 if (branch(6, 1, v1)) ++ok; else ++wrong; 487 if (branch(7, 1, v1)) ++ok; else ++wrong; 488 if (branch(8, 1, v1)) ++wrong; else ++ok; 489 if (branch(9, 1, v1)) ++wrong; else ++ok; 490 if (branch(10, 1, v1)) ++ok; else ++wrong; 491 if (branch(11, 1, v1)) ++ok; else ++wrong; 492 if (branch(12, 1, v1)) ++wrong; else ++ok; 493 if (branch(13, 1, v1)) ++wrong; else ++ok; 494 if (branch(14, 1, v1)) ++ok; else ++wrong; 495 if (branch(15, 1, v1)) ++ok; else ++wrong; 496 497 if (wrong != 0 || ok != 64) 498 printf("FAILED\n"); 499 else 500 printf("OK\n"); 501 } 502 503 /* loads two bytes */ 504 void 505 icm_two_bytes_msb_not_set(void) 506 { 507 int wrong, ok; 508 unsigned v1; 509 510 printf("Test #8 load two bytes, msb not set --> cc == 2\n"); 511 512 v1 = 0x7FFFFFFF; 513 wrong = ok = 0; 514 515 if (branch(0, 12, v1)) ++wrong; else ++ok; 516 if (branch(1, 12, v1)) ++wrong; else ++ok; 517 if (branch(2, 12, v1)) ++ok; else ++wrong; 518 if (branch(3, 12, v1)) ++ok; else ++wrong; 519 if (branch(4, 12, v1)) ++wrong; else ++ok; 520 if (branch(5, 12, v1)) ++wrong; else ++ok; 521 if (branch(6, 12, v1)) ++ok; else ++wrong; 522 if (branch(7, 12, v1)) ++ok; else ++wrong; 523 if (branch(8, 12, v1)) ++wrong; else ++ok; 524 if (branch(9, 12, v1)) ++wrong; else ++ok; 525 if (branch(10, 12, v1)) ++ok; else ++wrong; 526 if (branch(11, 12, v1)) ++ok; else ++wrong; 527 if (branch(12, 12, v1)) ++wrong; else ++ok; 528 if (branch(13, 12, v1)) ++wrong; else ++ok; 529 if (branch(14, 12, v1)) ++ok; else ++wrong; 530 if (branch(15, 12, v1)) ++ok; else ++wrong; 531 532 if (branch(0, 10, v1)) ++wrong; else ++ok; 533 if (branch(1, 10, v1)) ++wrong; else ++ok; 534 if (branch(2, 10, v1)) ++ok; else ++wrong; 535 if (branch(3, 10, v1)) ++ok; else ++wrong; 536 if (branch(4, 10, v1)) ++wrong; else ++ok; 537 if (branch(5, 10, v1)) ++wrong; else ++ok; 538 if (branch(6, 10, v1)) ++ok; else ++wrong; 539 if (branch(7, 10, v1)) ++ok; else ++wrong; 540 if (branch(8, 10, v1)) ++wrong; else ++ok; 541 if (branch(9, 10, v1)) ++wrong; else ++ok; 542 if (branch(10, 10, v1)) ++ok; else ++wrong; 543 if (branch(11, 10, v1)) ++ok; else ++wrong; 544 if (branch(12, 10, v1)) ++wrong; else ++ok; 545 if (branch(13, 10, v1)) ++wrong; else ++ok; 546 if (branch(14, 10, v1)) ++ok; else ++wrong; 547 if (branch(15, 10, v1)) ++ok; else ++wrong; 548 549 if (branch(0, 9, v1)) ++wrong; else ++ok; 550 if (branch(1, 9, v1)) ++wrong; else ++ok; 551 if (branch(2, 9, v1)) ++ok; else ++wrong; 552 if (branch(3, 9, v1)) ++ok; else ++wrong; 553 if (branch(4, 9, v1)) ++wrong; else ++ok; 554 if (branch(5, 9, v1)) ++wrong; else ++ok; 555 if (branch(6, 9, v1)) ++ok; else ++wrong; 556 if (branch(7, 9, v1)) ++ok; else ++wrong; 557 if (branch(8, 9, v1)) ++wrong; else ++ok; 558 if (branch(9, 9, v1)) ++wrong; else ++ok; 559 if (branch(10, 9, v1)) ++ok; else ++wrong; 560 if (branch(11, 9, v1)) ++ok; else ++wrong; 561 if (branch(12, 9, v1)) ++wrong; else ++ok; 562 if (branch(13, 9, v1)) ++wrong; else ++ok; 563 if (branch(14, 9, v1)) ++ok; else ++wrong; 564 if (branch(15, 9, v1)) ++ok; else ++wrong; 565 566 if (branch(0, 6, v1)) ++wrong; else ++ok; 567 if (branch(1, 6, v1)) ++wrong; else ++ok; 568 if (branch(2, 6, v1)) ++ok; else ++wrong; 569 if (branch(3, 6, v1)) ++ok; else ++wrong; 570 if (branch(4, 6, v1)) ++wrong; else ++ok; 571 if (branch(5, 6, v1)) ++wrong; else ++ok; 572 if (branch(6, 6, v1)) ++ok; else ++wrong; 573 if (branch(7, 6, v1)) ++ok; else ++wrong; 574 if (branch(8, 6, v1)) ++wrong; else ++ok; 575 if (branch(9, 6, v1)) ++wrong; else ++ok; 576 if (branch(10, 6, v1)) ++ok; else ++wrong; 577 if (branch(11, 6, v1)) ++ok; else ++wrong; 578 if (branch(12, 6, v1)) ++wrong; else ++ok; 579 if (branch(13, 6, v1)) ++wrong; else ++ok; 580 if (branch(14, 6, v1)) ++ok; else ++wrong; 581 if (branch(15, 6, v1)) ++ok; else ++wrong; 582 583 if (branch(0, 5, v1)) ++wrong; else ++ok; 584 if (branch(1, 5, v1)) ++wrong; else ++ok; 585 if (branch(2, 5, v1)) ++ok; else ++wrong; 586 if (branch(3, 5, v1)) ++ok; else ++wrong; 587 if (branch(4, 5, v1)) ++wrong; else ++ok; 588 if (branch(5, 5, v1)) ++wrong; else ++ok; 589 if (branch(6, 5, v1)) ++ok; else ++wrong; 590 if (branch(7, 5, v1)) ++ok; else ++wrong; 591 if (branch(8, 5, v1)) ++wrong; else ++ok; 592 if (branch(9, 5, v1)) ++wrong; else ++ok; 593 if (branch(10, 5, v1)) ++ok; else ++wrong; 594 if (branch(11, 5, v1)) ++ok; else ++wrong; 595 if (branch(12, 5, v1)) ++wrong; else ++ok; 596 if (branch(13, 5, v1)) ++wrong; else ++ok; 597 if (branch(14, 5, v1)) ++ok; else ++wrong; 598 if (branch(15, 5, v1)) ++ok; else ++wrong; 599 600 if (branch(0, 3, v1)) ++wrong; else ++ok; 601 if (branch(1, 3, v1)) ++wrong; else ++ok; 602 if (branch(2, 3, v1)) ++ok; else ++wrong; 603 if (branch(3, 3, v1)) ++ok; else ++wrong; 604 if (branch(4, 3, v1)) ++wrong; else ++ok; 605 if (branch(5, 3, v1)) ++wrong; else ++ok; 606 if (branch(6, 3, v1)) ++ok; else ++wrong; 607 if (branch(7, 3, v1)) ++ok; else ++wrong; 608 if (branch(8, 3, v1)) ++wrong; else ++ok; 609 if (branch(9, 3, v1)) ++wrong; else ++ok; 610 if (branch(10, 3, v1)) ++ok; else ++wrong; 611 if (branch(11, 3, v1)) ++ok; else ++wrong; 612 if (branch(12, 3, v1)) ++wrong; else ++ok; 613 if (branch(13, 3, v1)) ++wrong; else ++ok; 614 if (branch(14, 3, v1)) ++ok; else ++wrong; 615 if (branch(15, 3, v1)) ++ok; else ++wrong; 616 617 if (wrong != 0 || ok != 96) 618 printf("FAILED\n"); 619 else 620 printf("OK\n"); 621 } 622 623 624 /* loads three bytes */ 625 void 626 icm_three_bytes_msb_not_set(void) 627 { 628 int wrong, ok; 629 unsigned v1; 630 631 printf("Test #9 load three bytes, msb not set --> cc == 2\n"); 632 633 v1 = 0x7FFFFFFF; 634 wrong = ok = 0; 635 636 if (branch(0, 14, v1)) ++wrong; else ++ok; 637 if (branch(1, 14, v1)) ++wrong; else ++ok; 638 if (branch(2, 14, v1)) ++ok; else ++wrong; 639 if (branch(3, 14, v1)) ++ok; else ++wrong; 640 if (branch(4, 14, v1)) ++wrong; else ++ok; 641 if (branch(5, 14, v1)) ++wrong; else ++ok; 642 if (branch(6, 14, v1)) ++ok; else ++wrong; 643 if (branch(7, 14, v1)) ++ok; else ++wrong; 644 if (branch(8, 14, v1)) ++wrong; else ++ok; 645 if (branch(9, 14, v1)) ++wrong; else ++ok; 646 if (branch(10, 14, v1)) ++ok; else ++wrong; 647 if (branch(11, 14, v1)) ++ok; else ++wrong; 648 if (branch(12, 14, v1)) ++wrong; else ++ok; 649 if (branch(13, 14, v1)) ++wrong; else ++ok; 650 if (branch(14, 14, v1)) ++ok; else ++wrong; 651 if (branch(15, 14, v1)) ++ok; else ++wrong; 652 653 if (branch(0, 13, v1)) ++wrong; else ++ok; 654 if (branch(1, 13, v1)) ++wrong; else ++ok; 655 if (branch(2, 13, v1)) ++ok; else ++wrong; 656 if (branch(3, 13, v1)) ++ok; else ++wrong; 657 if (branch(4, 13, v1)) ++wrong; else ++ok; 658 if (branch(5, 13, v1)) ++wrong; else ++ok; 659 if (branch(6, 13, v1)) ++ok; else ++wrong; 660 if (branch(7, 13, v1)) ++ok; else ++wrong; 661 if (branch(8, 13, v1)) ++wrong; else ++ok; 662 if (branch(9, 13, v1)) ++wrong; else ++ok; 663 if (branch(10, 13, v1)) ++ok; else ++wrong; 664 if (branch(11, 13, v1)) ++ok; else ++wrong; 665 if (branch(12, 13, v1)) ++wrong; else ++ok; 666 if (branch(13, 13, v1)) ++wrong; else ++ok; 667 if (branch(14, 13, v1)) ++ok; else ++wrong; 668 if (branch(15, 13, v1)) ++ok; else ++wrong; 669 670 if (branch(0, 11, v1)) ++wrong; else ++ok; 671 if (branch(1, 11, v1)) ++wrong; else ++ok; 672 if (branch(2, 11, v1)) ++ok; else ++wrong; 673 if (branch(3, 11, v1)) ++ok; else ++wrong; 674 if (branch(4, 11, v1)) ++wrong; else ++ok; 675 if (branch(5, 11, v1)) ++wrong; else ++ok; 676 if (branch(6, 11, v1)) ++ok; else ++wrong; 677 if (branch(7, 11, v1)) ++ok; else ++wrong; 678 if (branch(8, 11, v1)) ++wrong; else ++ok; 679 if (branch(9, 11, v1)) ++wrong; else ++ok; 680 if (branch(10, 11, v1)) ++ok; else ++wrong; 681 if (branch(11, 11, v1)) ++ok; else ++wrong; 682 if (branch(12, 11, v1)) ++wrong; else ++ok; 683 if (branch(13, 11, v1)) ++wrong; else ++ok; 684 if (branch(14, 11, v1)) ++ok; else ++wrong; 685 if (branch(15, 11, v1)) ++ok; else ++wrong; 686 687 if (branch(0, 7, v1)) ++wrong; else ++ok; 688 if (branch(1, 7, v1)) ++wrong; else ++ok; 689 if (branch(2, 7, v1)) ++ok; else ++wrong; 690 if (branch(3, 7, v1)) ++ok; else ++wrong; 691 if (branch(4, 7, v1)) ++wrong; else ++ok; 692 if (branch(5, 7, v1)) ++wrong; else ++ok; 693 if (branch(6, 7, v1)) ++ok; else ++wrong; 694 if (branch(7, 7, v1)) ++ok; else ++wrong; 695 if (branch(8, 7, v1)) ++wrong; else ++ok; 696 if (branch(9, 7, v1)) ++wrong; else ++ok; 697 if (branch(10, 7, v1)) ++ok; else ++wrong; 698 if (branch(11, 7, v1)) ++ok; else ++wrong; 699 if (branch(12, 7, v1)) ++wrong; else ++ok; 700 if (branch(13, 7, v1)) ++wrong; else ++ok; 701 if (branch(14, 7, v1)) ++ok; else ++wrong; 702 if (branch(15, 7, v1)) ++ok; else ++wrong; 703 704 if (wrong != 0 || ok != 64) 705 printf("FAILED\n"); 706 else 707 printf("OK\n"); 708 } 709 710 /* loads four bytes */ 711 void 712 icm_four_bytes_msb_not_set(void) 713 { 714 int wrong, ok; 715 unsigned v1; 716 717 printf("Test #10 load four bytes, msb not set --> cc == 2\n"); 718 719 v1 = 0x7FFFFFFF; 720 wrong = ok = 0; 721 722 if (branch(0, 15, v1)) ++wrong; else ++ok; 723 if (branch(1, 15, v1)) ++wrong; else ++ok; 724 if (branch(2, 15, v1)) ++ok; else ++wrong; 725 if (branch(3, 15, v1)) ++ok; else ++wrong; 726 if (branch(4, 15, v1)) ++wrong; else ++ok; 727 if (branch(5, 15, v1)) ++wrong; else ++ok; 728 if (branch(6, 15, v1)) ++ok; else ++wrong; 729 if (branch(7, 15, v1)) ++ok; else ++wrong; 730 if (branch(8, 15, v1)) ++wrong; else ++ok; 731 if (branch(9, 15, v1)) ++wrong; else ++ok; 732 if (branch(10, 15, v1)) ++ok; else ++wrong; 733 if (branch(11, 15, v1)) ++ok; else ++wrong; 734 if (branch(12, 15, v1)) ++wrong; else ++ok; 735 if (branch(13, 15, v1)) ++wrong; else ++ok; 736 if (branch(14, 15, v1)) ++ok; else ++wrong; 737 if (branch(15, 15, v1)) ++ok; else ++wrong; 738 739 if (wrong != 0 || ok != 16) 740 printf("FAILED\n"); 741 else 742 printf("OK\n"); 743 } 744 745 int main() 746 { 747 icm_mask_0(); 748 icm_value_0(); 749 750 icm_one_byte_msb_set(); 751 icm_two_bytes_msb_set(); 752 icm_three_bytes_msb_set(); 753 icm_four_bytes_msb_set(); 754 755 icm_one_byte_msb_not_set(); 756 icm_two_bytes_msb_not_set(); 757 icm_three_bytes_msb_not_set(); 758 icm_four_bytes_msb_not_set(); 759 760 return 0; 761 } 762