PageRenderTime 1330ms CodeModel.GetById 80ms app.highlight 744ms RepoModel.GetById 441ms app.codeStats 2ms

/test/tests.c

https://github.com/salty-horse/syn68k
C | 4105 lines | 3077 code | 960 blank | 68 comment | 84 complexity | da3e32b1e548277369befce9a7478c91 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1#include "syn68k_public.h"
   2#include "driver.h"
   3#include "setup.h"
   4#include <stdio.h>
   5
   6
   7#define TEST(f, cc_mask, size, changes_memory, max_calls) void f (uint16 *code)
   8#define MEM (US_TO_SYN68K (&mem[0]))
   9#define MEMEND (US_TO_SYN68K (&mem[MEM_SIZE - 1]))
  10#define MEMMID (US_TO_SYN68K (&mem[(MEM_SIZE) / 2]))
  11
  12#define GNUC_LOSES_WITH_EXPONENTIAL_GROWTH
  13#ifdef GNUC_LOSES_WITH_EXPONENTIAL_GROWTH
  14static inline int
  15MASK (const char *s, int c)
  16{
  17  int i, ret;
  18  
  19  for (i = 0, ret = 0; i < 16; i++)
  20    ret |= ((s[i] == c) << (15 - i));
  21  return ret;
  22}
  23#else
  24#define MASK(s,c) ((  (s[0 ] == (c)) << 15) | ((s[1 ] == (c)) << 14) \
  25		   | ((s[2 ] == (c)) << 13) | ((s[3 ] == (c)) << 12) \
  26		   | ((s[4 ] == (c)) << 11) | ((s[5 ] == (c)) << 10) \
  27		   | ((s[6 ] == (c)) <<  9) | ((s[7 ] == (c)) <<  8) \
  28		   | ((s[8 ] == (c)) <<  7) | ((s[9 ] == (c)) <<  6) \
  29		   | ((s[10] == (c)) <<  5) | ((s[11] == (c)) <<  4) \
  30		   | ((s[12] == (c)) <<  3) | ((s[13] == (c)) <<  2) \
  31		   | ((s[14] == (c)) <<  1) | ((s[15] == (c))))
  32#endif
  33#define B(s) MASK(s, '1')
  34#define R(s) (B(s) | (MASK(s, 'r') & randint (0, 65535)))
  35
  36#define NOP_OPCODE 0x4E71
  37
  38#define RANDOM_SIZE() (randint (0, 2) << 6)
  39
  40/* The WRITE4 macro does not write out values in big-endian!  Rather, it
  41 * writes out the words in big endian format and leaves the bytes within
  42 * each word in whatever format.  This is because we always byte swap
  43 * words later, if appropriate.
  44 */
  45#define WRITE4(c,n)    \
  46{                      \
  47  uint32 tmp = (n);    \
  48  code[c] = tmp >> 16; \
  49  code[(c) + 1] = tmp; \
  50}
  51
  52
  53
  54TEST (unpk_reg, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
  55{
  56  code[0] = R ("1000rrr110000rrr");
  57  code[1] = randnum ();
  58}
  59
  60
  61TEST (unpk_mem, ALL_CCS, 2, MIGHT_CHANGE_MEMORY, NO_LIMIT)
  62{
  63  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 0);
  64  code[0] = R ("1000rrr110001rrr");
  65  code[1] = randnum ();
  66}
  67
  68
  69TEST (unlk, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
  70{
  71  uint8 *p;
  72
  73  for (p = mem; p < mem + MEM_SIZE; )
  74    {
  75      uint32 addr = randint (MEM + 50, MEMEND - 50) & ~1;
  76      *p++ = addr >> 24;
  77      *p++ = addr >> 16;
  78      *p++ = addr >> 8;
  79      *p++ = addr;
  80    }
  81
  82  /* NOTE: "unlk a7" wedges my 68040 NeXT, so I am skipping that test here.
  83   * "unlk a7" works on a 68030 NeXT, so it may be worth modifying this
  84   * code to test that case when we run it on a non-68040 based machine.
  85   */
  86
  87  /* WARNING!  Assumes that mem is aligned % 4 */
  88  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 3);
  89  code[0] = R ("0100111001011000") | randint (0, 6);
  90}
  91
  92TEST (movewl_ind_ind, ALL_CCS, 1, MIGHT_CHANGE_MEMORY, NO_LIMIT)
  93{
  94  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 1);
  95  code[0] = (R ("001rrrr000000rrr")   /* Randomly either word or long. */
  96	     | (randint (2, 4) << 6)    /* Random amode [2, 4] */
  97	     | (randint (2, 4) << 3));  /* Random amode [2, 4] */
  98}
  99
 100
 101TEST (divsl_ll_reg, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
 102{
 103  int divisor_reg = randint (0, 7);
 104  do { EM_DREG (divisor_reg) = randnum ();} while (EM_DREG (divisor_reg) == 0);
 105  code[0] = B ("0100110001000000") | divisor_reg;
 106  code[1] = R ("0rrr1r0000000rrr");
 107}
 108
 109
 110TEST (divsl_ll_ind, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
 111{
 112  uint16 *p;
 113  int i;
 114
 115  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 1);
 116  for (i = 0, p = (uint16 *)mem; i < MEM_SIZE / sizeof (uint16); i++)
 117    *p++ = SWAPUW_IFLE (randint (1, 65535));
 118  code[0] = R ("0100110001000rrr") | (randint (2, 4) << 3);
 119  code[1] = R ("0rrr1r0000000rrr");
 120}
 121
 122
 123TEST (divsl_ll_absl, ALL_CCS, 4, WONT_CHANGE_MEMORY, NO_LIMIT)
 124{
 125  uint16 *p;
 126  int i;
 127
 128  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 1);
 129  for (i = 0, p = (uint16 *)mem; i < MEM_SIZE / sizeof (uint16); i++)
 130    *p++ = SWAPUW_IFLE (randint (1, 65535));
 131  code[0] = B ("0100110001111001");
 132  code[1] = R ("0rrr1r0000000rrr");
 133  WRITE4 (2, randint (MEM + 50, MEMEND - 50) & ~1);
 134}
 135
 136
 137TEST (lea_pc_ind_preix, ALL_CCS, 50, WONT_CHANGE_MEMORY, NO_LIMIT)
 138{
 139  int i;
 140  int bd_size = randint (2, 3), od_size = randint (1, 3);
 141  int scale = randint (0, 3);
 142
 143  randomize_mem ();
 144  randomize_regs (0, 15, 0, 8 >> scale, (4 >> scale) - 1);
 145
 146  /* Put out some initial NOPs */
 147  for (i = 0; i < 4; i++)
 148    code[i] = NOP_OPCODE;  /* nop */
 149
 150  /* Output the main opcode. */
 151  code[i] = R ("0100rrr111111011");
 152  code[i + 1] = (R ("rrrrr0010r000000") | (scale << 9)
 153		 | (bd_size << 4) | od_size);
 154  i += 2;
 155
 156  /* Output the base displacement. */
 157  switch (bd_size) {
 158  case 2:
 159    code[i] = (5 + (od_size - 1)) * 2 + (randint (0, 5) * 4);
 160    i++;
 161    break;
 162  case 3:
 163    WRITE4 (i, (6 + (od_size - 1)) * 2 + (randint (0, 5) * 4));
 164    i += 2;
 165    break;
 166  }
 167
 168  /* Output outer displacement (if any). */
 169  switch (od_size) {
 170  case 1:
 171    break;
 172  case 2:
 173    code[i] = randint (-20, 20);
 174    i++;
 175    break;
 176  case 3:
 177    WRITE4 (i, randint (-20, 20));
 178    i += 2;
 179    break;
 180  }
 181
 182  /* Skip over array of addresses. */
 183  code[i] = 0x4EF9;  /* jmp absl */
 184  WRITE4 (i + 1, (unsigned long) (code - (MEMORY_OFFSET / 2) + 50));
 185  
 186  for (i += 3; i < 49; i += 2)
 187    WRITE4 (i, randint (MEM + 50, MEMEND - 50));
 188}
 189
 190
 191TEST (lea_pc_ind_postix, ALL_CCS, 50, WONT_CHANGE_MEMORY, NO_LIMIT)
 192{
 193  int i;
 194  int bd_size = randint (2, 3), od_size = randint (1, 3);
 195  int scale = randint (0, 3);
 196
 197  randomize_mem ();
 198  randomize_regs (0, 15, -6, 6, 0);
 199
 200  /* Put out some initial NOPs */
 201  for (i = 0; i < 4; i++)
 202    code[i] = NOP_OPCODE;  /* nop */
 203
 204  /* Output the main opcode. */
 205  code[i] = R ("0100rrr111111011");
 206  code[i + 1] = (R ("rrrrr0010r000100") | (scale << 9)
 207		 | (bd_size << 4) | od_size);
 208  i += 2;
 209
 210  /* Output the base displacement. */
 211  switch (bd_size) {
 212  case 2:
 213    code[i] = (5 + (od_size - 1)) * 2 + (randint (0, 5) * 4);
 214    i++;
 215    break;
 216  case 3:
 217    WRITE4 (i, (6 + (od_size - 1)) * 2 + (randint (0, 5) * 4));
 218    i += 2;
 219    break;
 220  }
 221
 222  /* Output outer displacement (if any). */
 223  switch (od_size) {
 224  case 1:
 225    break;
 226  case 2:
 227    code[i] = randint (-20, 20);
 228    i++;
 229    break;
 230  case 3:
 231    WRITE4 (i, randint (-20, 20));
 232    i += 2;
 233    break;
 234  }
 235
 236  /* Skip over array of addresses. */
 237  code[i] = 0x4EF9;  /* jmp absl */
 238  WRITE4 (i + 1, (unsigned long) (code - (MEMORY_OFFSET / 2) + 50));
 239  
 240  for (i += 3; i < 49; i += 2)
 241    WRITE4 (i, randint (MEM + 100, MEMEND - 100));
 242}
 243
 244
 245TEST (moveb_pc_ind_preix_dreg, ALL_CCS, 50, WONT_CHANGE_MEMORY, NO_LIMIT)
 246{
 247  int i;
 248  int bd_size = randint (2, 3), od_size = randint (1, 3);
 249  int scale = randint (0, 3);
 250
 251  randomize_mem ();
 252  randomize_regs (0, 15, 0, 8 >> scale, (4 >> scale) - 1);
 253
 254  /* Put out some initial NOPs */
 255  for (i = 0; i < 4; i++)
 256    code[i] = NOP_OPCODE;  /* nop */
 257
 258  /* Output the main opcode. */
 259  code[i] = R ("0001rrr000111011");
 260  code[i + 1] = (R ("rrrrr0010r000000") | (scale << 9)
 261		 | (bd_size << 4) | od_size);
 262  i += 2;
 263
 264  /* Output the base displacement. */
 265  switch (bd_size) {
 266  case 2:
 267    code[i] = (5 + (od_size - 1)) * 2 + (randint (0, 5) * 4);
 268    i++;
 269    break;
 270  case 3:
 271    WRITE4 (i, (6 + (od_size - 1)) * 2 + (randint (0, 5) * 4));
 272    i += 2;
 273    break;
 274  }
 275
 276  /* Output outer displacement (if any). */
 277  switch (od_size) {
 278  case 1:
 279    break;
 280  case 2:
 281    code[i] = randint (-20, 20);
 282    i++;
 283    break;
 284  case 3:
 285    WRITE4 (i, randint (-20, 20));
 286    i += 2;
 287    break;
 288  }
 289
 290  /* Skip over array of addresses. */
 291  code[i] = 0x4EF9;  /* jmp absl */
 292  WRITE4 (i + 1, (unsigned long) (code - (MEMORY_OFFSET / 2) + 50));
 293  
 294  for (i += 3; i < 49; i += 2)
 295    WRITE4 (i, randint (MEM + 50, MEMEND - 50));
 296}
 297
 298
 299TEST (moveb_pc_ind_postix_dreg, ALL_CCS, 50, WONT_CHANGE_MEMORY, NO_LIMIT)
 300{
 301  int i;
 302  int bd_size = randint (2, 3), od_size = randint (1, 3);
 303  int scale = randint (0, 3);
 304
 305  randomize_mem ();
 306  randomize_regs (0, 15, -6, 6, 0);
 307
 308  /* Put out some initial NOPs */
 309  for (i = 0; i < 4; i++)
 310    code[i] = NOP_OPCODE;  /* nop */
 311
 312  /* Output the main opcode. */
 313  code[i] = R ("0001rrr000111011");
 314  code[i + 1] = (R ("rrrrr0010r000100") | (scale << 9)
 315		 | (bd_size << 4) | od_size);
 316  i += 2;
 317
 318  /* Output the base displacement. */
 319  switch (bd_size) {
 320  case 2:
 321    code[i] = (5 + (od_size - 1)) * 2 + (randint (0, 5) * 4);
 322    i++;
 323    break;
 324  case 3:
 325    WRITE4 (i, (6 + (od_size - 1)) * 2 + (randint (0, 5) * 4));
 326    i += 2;
 327    break;
 328  }
 329
 330  /* Output outer displacement (if any). */
 331  switch (od_size) {
 332  case 1:
 333    break;
 334  case 2:
 335    code[i] = randint (-20, 20);
 336    i++;
 337    break;
 338  case 3:
 339    WRITE4 (i, randint (-20, 20));
 340    i += 2;
 341    break;
 342  }
 343
 344  /* Skip over array of addresses. */
 345  code[i] = 0x4EF9;  /* jmp absl */
 346  WRITE4 (i + 1, (unsigned long) (code - (MEMORY_OFFSET / 2) + 50));
 347  
 348  for (i += 3; i < 49; i += 2)
 349    WRITE4 (i, randint (MEM + 100, MEMEND - 100));
 350}
 351
 352
 353TEST (moveb_pcd16_dreg, ALL_CCS, 6, WONT_CHANGE_MEMORY, NO_LIMIT)
 354{
 355  randomize_mem ();
 356  code[0] = NOP_OPCODE;  /* nop */
 357  code[1] = NOP_OPCODE;  /* nop */
 358  code[2] = R ("0001rrr000111010");
 359  code[3] = randint (-4, 4);
 360  code[4] = NOP_OPCODE;  /* nop */
 361  code[5] = NOP_OPCODE;  /* nop */
 362}
 363
 364
 365TEST (movewl_pcd16_dreg, ALL_CCS, 6, WONT_CHANGE_MEMORY, NO_LIMIT)
 366{
 367  randomize_mem ();
 368  code[0] = NOP_OPCODE;  /* nop */
 369  code[1] = NOP_OPCODE;  /* nop */
 370  code[2] = R ("001rrrr000111010");
 371  code[3] = randint (-4, 4) & ~1;
 372  code[4] = NOP_OPCODE;  /* nop */
 373  code[5] = NOP_OPCODE;  /* nop */
 374}
 375
 376
 377TEST (moveb_pcd8_dreg, ALL_CCS, 40, WONT_CHANGE_MEMORY, NO_LIMIT)
 378{
 379  int i;
 380  int long_ix = randint (0, 1);    /* Are we using a index reg as a long? */
 381
 382  randomize_mem ();
 383  randomize_regs (0, 15, -2, 2, 0);
 384
 385  /* If we have a word sized index, blow away high word of all regs so
 386   * that we know the high word is being properly ignored.
 387   */
 388  if (!long_ix)
 389    {
 390      for (i = 0; i < 16; i++)
 391	cpu_state.regs[i].ul.n = ((cpu_state.regs[i].ul.n & 0xFFFF)
 392				  | (randnum () << 16));
 393    }
 394
 395  for (i = 0; i < 20; i++)
 396    code[i] = NOP_OPCODE;  /* nop */
 397  code[i] = R ("0001rrr000111011");
 398  code[i + 1] = (R ("rrrr0rr000000000") | (long_ix << 11)
 399		 | (randint (-4, 4) & 0xFF));
 400  for (i += 2; i < 40; i++)
 401    code[i] = NOP_OPCODE;  /* nop */
 402}
 403
 404
 405TEST (movewl_pcd8_dreg, ALL_CCS, 40, WONT_CHANGE_MEMORY, NO_LIMIT)
 406{
 407  int i;
 408
 409  randomize_mem ();
 410  randomize_regs (0, 15, -2, 2, 1);
 411
 412  for (i = 0; i < 20; i++)
 413    code[i] = NOP_OPCODE;  /* nop */
 414  code[i] = R ("001rrrr000111011");
 415  code[i + 1] = R ("rrrrrrr000000000") | (randint (-4, 4) & 0xFE);
 416  for (i += 2; i < 40; i++)
 417    code[i] = NOP_OPCODE;  /* nop */
 418}
 419
 420
 421TEST (moveb_pc_ind_ix_dreg, ALL_CCS, 40, WONT_CHANGE_MEMORY, NO_LIMIT)
 422{
 423  int i;
 424  int bd_size = randint (1, 3);
 425
 426  randomize_mem ();
 427  randomize_regs (0, 15, -2, 2, 0);
 428
 429  for (i = 0; i < 20; i++)
 430    code[i] = NOP_OPCODE;  /* nop */
 431  code[i] = R ("0001rrr000111011");
 432  code[i + 1] = R ("rrrrrrr10r000000") | (bd_size << 4);
 433  switch (bd_size) {
 434  case 1:
 435    i += 2;
 436    break;
 437  case 2:
 438    code[i + 2] = randint (-4, 4);
 439    i += 3;
 440    break;
 441  case 3:
 442    WRITE4 (i + 2, randint (-4, 4));
 443    i += 4;
 444    break;
 445  }
 446
 447  for (; i < 40; i++)
 448    code[i] = NOP_OPCODE;  /* nop */
 449}
 450
 451
 452TEST (movewl_pc_ind_ix_dreg, ALL_CCS, 40, WONT_CHANGE_MEMORY, NO_LIMIT)
 453{
 454  int i;
 455  int bd_size = randint (1, 3);
 456
 457  randomize_mem ();
 458  randomize_regs (0, 15, -2, 2, 1);
 459
 460  for (i = 0; i < 20; i++)
 461    code[i] = NOP_OPCODE;  /* nop */
 462  code[i] = R ("001rrrr000111011");
 463  code[i + 1] = R ("rrrrrrr10r000000") | (bd_size << 4);
 464  switch (bd_size) {
 465  case 1:
 466    i += 2;
 467    break;
 468  case 2:
 469    code[i + 2] = randint (-4, 4) & ~1;
 470    i += 3;
 471    break;
 472  case 3:
 473    WRITE4 (i + 2, randint (-4, 4) & ~1);
 474    i += 4;
 475    break;
 476  }
 477
 478  for (; i < 40; i++)
 479    code[i] = NOP_OPCODE;  /* nop */
 480}
 481
 482
 483TEST (lea_ind_preix, ALL_CCS, 50, WONT_CHANGE_MEMORY, NO_LIMIT)
 484{
 485  int i;
 486  int bd_size, od_size = randint (1, 3);
 487  int scale = randint (0, 3);
 488  int base_address_reg = randint (0, 7);
 489  int base_suppress = randint (0, 1);
 490  int ixreg_specifier;
 491
 492  randomize_mem ();
 493  randomize_regs (0, 15, 0, 8 >> scale, (4 >> scale) - 1);
 494
 495  /* Put out some initial NOPs */
 496  for (i = 0; i < 4; i++)
 497    code[i] = NOP_OPCODE;  /* nop */
 498
 499  /* Determine the index reg.  Make sure it's not the same as our base reg. */
 500  do
 501    {
 502      ixreg_specifier = randint (0, 15);
 503    }
 504  while ((ixreg_specifier & 8) && (ixreg_specifier & 7) == base_address_reg);
 505
 506  if (base_suppress)
 507    bd_size = 3;
 508  else
 509    bd_size = randint (2, 3);
 510
 511  /* Output the main opcode. */
 512  code[i] = R ("0100rrr111110000") | base_address_reg;
 513  code[i + 1] = (R ("0000r0010r000000") | (ixreg_specifier << 12)
 514		 | (base_suppress << 7) | (scale << 9) | (bd_size << 4)
 515		 | od_size);
 516  i += 2;
 517
 518  /* Put the address of a block of random memory into our base register. */
 519  cpu_state.regs[8 + base_address_reg].ul.n
 520    = randint (MEM + 32, MEM + 128) & ~1;
 521
 522  /* Output the base displacement. */
 523  if (!base_suppress)
 524    {
 525      /* Since we aren't suppressing the base, make this a small offset. */
 526      switch (bd_size) {
 527      case 2:
 528	code[i] = (5 + (od_size - 1)) * 2 + (randint (0, 5) * 4);
 529	i++;
 530	break;
 531      case 3:
 532	WRITE4 (i, (6 + (od_size - 1)) * 2 + (randint (0, 5) * 4));
 533	i += 2;
 534	break;
 535      }
 536    }
 537  else  /* base_suppress */
 538    {
 539      /* Since we're suppressing the base, we must make it larger and
 540       * point directly to the base of the addresses in which we
 541       * are interested.
 542       */
 543      WRITE4 (i, MEM + 32 + (randint (0, 50) * 4));
 544      i += 2;
 545    }
 546
 547  /* Output outer displacement (if any). */
 548  switch (od_size) {
 549  case 1:
 550    break;
 551  case 2:
 552    code[i] = randint (-20, 20);
 553    i++;
 554    break;
 555  case 3:
 556    WRITE4 (i, randint (-20, 20));
 557    i += 2;
 558    break;
 559  }
 560
 561  /* Skip over array of addresses. */
 562  code[i] = 0x4EF9;  /* jmp absl */
 563  WRITE4 (i + 1, (unsigned long) (code - (MEMORY_OFFSET / 2) + 50));
 564  
 565  for (i += 3; i < 49; i += 2)
 566    WRITE4 (i, randint (MEM + 50, MEMEND - 50));
 567}
 568
 569
 570TEST (lea_ind_postix, ALL_CCS, 50, WONT_CHANGE_MEMORY, NO_LIMIT)
 571{
 572  int i;
 573  int bd_size, od_size = randint (1, 3);
 574  int scale = randint (0, 3);
 575  int base_address_reg = randint (0, 7);
 576  int base_suppress = randint (0, 1);
 577  int ixreg_specifier = randint (0, 15);
 578
 579  randomize_mem ();
 580  randomize_regs (0, 15, -1024, 1024, 1);
 581
 582  /* Put out some initial NOPs */
 583  for (i = 0; i < 4; i++)
 584    code[i] = NOP_OPCODE;  /* nop */
 585
 586  if (base_suppress)
 587    bd_size = 3;
 588  else
 589    bd_size = randint (2, 3);
 590
 591  /* Output the main opcode. */
 592  code[i] = R ("0100rrr111110000") | base_address_reg;
 593  code[i + 1] = (R ("0000r0010r000100") | (ixreg_specifier << 12)
 594		 | (base_suppress << 7) | (scale << 9) | (bd_size << 4)
 595		 | od_size);
 596  i += 2;
 597
 598  /* Put the address of a block of random memory into our base register. */
 599  cpu_state.regs[8 + base_address_reg].ul.n
 600    = randint (MEM + 32, MEMEND - 128) & ~1;
 601
 602  /* Output the base displacement. */
 603  if (!base_suppress)
 604    {
 605      /* Since we aren't suppressing the base, make this a small offset. */
 606      switch (bd_size) {
 607      case 2:
 608	code[i] = (5 + (od_size - 1)) * 2 + (randint (0, 5) * 4);
 609	i++;
 610	break;
 611      case 3:
 612	WRITE4 (i, (6 + (od_size - 1)) * 2 + (randint (0, 5) * 4));
 613	i += 2;
 614	break;
 615      }
 616    }
 617  else  /* base_suppress */
 618    {
 619      /* Since we're suppressing the base, we must make it larger and
 620       * point directly to the base of the addresses in which we
 621       * are interested.
 622       */
 623      WRITE4 (i, MEM + 32 + (randint (0, 50) * 4));
 624      i += 2;
 625    }
 626
 627  /* Output outer displacement (if any). */
 628  switch (od_size) {
 629  case 1:
 630    break;
 631  case 2:
 632    code[i] = randint (-20, 20);
 633    i++;
 634    break;
 635  case 3:
 636    WRITE4 (i, randint (-20, 20));
 637    i += 2;
 638    break;
 639  }
 640
 641  /* Skip over array of addresses. */
 642  code[i] = 0x4EF9;  /* jmp absl */
 643  WRITE4 (i + 1, (unsigned long) (code - (MEMORY_OFFSET / 2) + 50));
 644  
 645  for (i += 3; i < 49; i += 2)
 646    WRITE4 (i, randint (MEM + 50, MEMEND - 50));
 647}
 648
 649
 650TEST (add_absl_dreg, ALL_CCS, 3, WONT_CHANGE_MEMORY, NO_LIMIT)
 651{
 652  randomize_mem ();
 653  code[0] = R ("1101rrr000111001") | RANDOM_SIZE ();
 654  WRITE4 (1, randint (MEM + 8, MEMEND - 8) & ~1);
 655}
 656
 657
 658TEST (abcd_reg, C_BIT | Z_BIT | X_BIT, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
 659{
 660  code[0] = R ("1100rrr100000rrr");
 661}
 662
 663
 664TEST (abcd_mem, C_BIT | Z_BIT | X_BIT, 1, MIGHT_CHANGE_MEMORY, NO_LIMIT)
 665{
 666  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 0);
 667  code[0] = R ("1100rrr100001rrr");
 668}
 669
 670
 671TEST (addb_dreg_dreg, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
 672{
 673  code[0] = R ("1101rrr000000rrr");
 674}
 675
 676
 677TEST (addw_reg_dreg, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
 678{
 679  code[0] = R ("1101rrr00100rrrr");
 680}
 681
 682
 683TEST (addl_reg_dreg, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
 684{
 685  code[0] = R ("1101rrr01000rrrr");
 686}
 687
 688
 689TEST (add_d16_dreg, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
 690{
 691  randomize_mem ();
 692  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 1);
 693  code[0] = R ("1101rrr000101rrr") | RANDOM_SIZE ();
 694  code[1] = randint (-290, 290) & ~1;
 695}
 696
 697
 698TEST (addb_const_dreg, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
 699{
 700  code[0] = R ("1101rrr000111100");
 701  code[1] = randint (0, 65535);
 702}
 703
 704
 705TEST (addw_const_dreg, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
 706{
 707  code[0] = R ("1101rrr001111100");
 708  code[1] = randint (0, 65535);
 709}
 710
 711
 712TEST (add_dreg_ind, ALL_CCS, 1, MIGHT_CHANGE_MEMORY, NO_LIMIT)
 713{
 714  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 1);
 715  code[0] = (R ("1101rrr100000rrr")
 716	     | RANDOM_SIZE ()
 717	     | (randint (2, 4) << 3));  /* Random amode [2, 4] */
 718}
 719
 720
 721TEST (add_ind_dreg, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
 722{
 723  randomize_mem ();
 724  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 1);
 725  code[0] = (R ("1101rrr000000rrr")
 726	     | RANDOM_SIZE ()
 727	     | (randint (2, 4) << 3)); /* Random amode [2, 4] */
 728}
 729
 730TEST (addl_const_dreg, ALL_CCS, 3, WONT_CHANGE_MEMORY, NO_LIMIT)
 731{
 732  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 1);
 733  code[0] = R ("1101rrr010111100");
 734  WRITE4 (1, randnum ());
 735}
 736
 737
 738TEST (add_dreg_d16, ALL_CCS, 2, MIGHT_CHANGE_MEMORY, NO_LIMIT)
 739{
 740  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 1);
 741  code[0] = R ("1101rrr100101rrr") | RANDOM_SIZE ();
 742  code[1] = randint (-290, 290) & ~1;
 743}
 744
 745
 746TEST (add_dreg_absl, ALL_CCS, 3, MIGHT_CHANGE_MEMORY, NO_LIMIT)
 747{
 748  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 1);
 749  code[0] = R ("1101rrr100111001") | RANDOM_SIZE ();
 750  WRITE4 (1, randint (MEM + 4, MEMEND - 4) & ~1);
 751}
 752
 753
 754TEST (addaw_reg_areg, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
 755{
 756  code[0] = R ("1101rrr01100rrrr");
 757}
 758
 759
 760TEST (addal_reg_areg, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
 761{
 762  code[0] = R ("1101rrr11100rrrr");
 763}
 764
 765
 766TEST (adda_ind_areg, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
 767{
 768  randomize_mem ();
 769  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 1);
 770  code[0] = (R ("1101rrrr11000rrr")   /* Random size. */
 771	     | (randint (2, 4) << 3));  /* Random amode [2, 4]; */
 772}
 773
 774
 775TEST (adda_d16_areg, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
 776{
 777  randomize_mem ();
 778  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 1);
 779  code[0] = R ("1101rrrr11101rrr");  /* Random size. */
 780  code[1] = randint (-290, 290) & ~1;
 781}
 782
 783
 784TEST (adda_absl_areg, ALL_CCS, 3, WONT_CHANGE_MEMORY, NO_LIMIT)
 785{
 786  randomize_mem ();
 787  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 1);
 788  code[0] = R ("1101rrrr11111001");  /* Random size. */
 789  WRITE4 (1, randint (MEM + 4, MEMEND - 4) & ~1);
 790}
 791
 792
 793TEST (addaw_const_areg, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
 794{
 795  code[0] = R ("1101rrr011111100");
 796  code[1] = randint (0, 65535);
 797}
 798
 799
 800TEST (addal_const_areg, ALL_CCS, 3, WONT_CHANGE_MEMORY, NO_LIMIT)
 801{
 802  code[0] = R ("1101rrr111111100");
 803  code[1] = randint (0, 65535);
 804  code[2] = randint (0, 65535);
 805}
 806
 807
 808TEST (addibw_dreg, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
 809{
 810  code[0] = R ("000001100r000rrr");  /* Randomly either byte or word */
 811  code[1] = randnum ();
 812}
 813
 814
 815TEST (addil_dreg, ALL_CCS, 3, WONT_CHANGE_MEMORY, NO_LIMIT)
 816{
 817  code[0] = R ("0000011010000rrr");
 818  WRITE4 (1, randnum ());
 819}
 820
 821
 822TEST (addibw_ind, ALL_CCS, 2, MIGHT_CHANGE_MEMORY, NO_LIMIT)
 823{
 824  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 1);
 825  code[0] = (R ("000001100r000rrr")    /* Randomly either byte or word. */
 826	     | (randint (2, 4) << 3));  /* Random amode [2, 4] */
 827  code[1] = randnum ();
 828}
 829
 830
 831TEST (addil_ind, ALL_CCS, 3, MIGHT_CHANGE_MEMORY, NO_LIMIT)
 832{
 833  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 1);
 834  code[0] = (R ("0000011010000rrr")
 835	     | (randint (2, 4) << 3));  /* Random amode [2, 4] */
 836  WRITE4 (1, randnum ());
 837}
 838
 839
 840TEST (addibw_d16, ALL_CCS, 3, MIGHT_CHANGE_MEMORY, NO_LIMIT)
 841{
 842  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 1);
 843  code[0] = R ("000001100r101rrr");  /* Randomly either byte or word. */
 844  code[1] = randnum ();
 845  code[2] = randint (-290, 290) & ~1;
 846}
 847
 848
 849TEST (addil_d16, ALL_CCS, 4, MIGHT_CHANGE_MEMORY, NO_LIMIT)
 850{
 851  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 1);
 852  code[0] = R ("0000011010101rrr");
 853  WRITE4 (1, randnum ());
 854  code[3] = randint (-290, 290) & ~1;
 855}
 856
 857
 858TEST (addibw_absl, ALL_CCS, 4, MIGHT_CHANGE_MEMORY, NO_LIMIT)
 859{
 860  code[0] = R ("000001100r111001");  /* Randomly either byte or word. */
 861  code[1] = randnum ();
 862
 863  WRITE4 (2, randint (MEM + 4, MEMEND - 4) & ~1);
 864}
 865
 866
 867TEST (addil_absl, ALL_CCS, 5, MIGHT_CHANGE_MEMORY, NO_LIMIT)
 868{
 869  code[0] = R ("0000011010111001");  /* Randomly either byte or word. */
 870  WRITE4 (1, randnum ());
 871  WRITE4 (3, randint (MEM + 4, MEMEND - 4) & ~1);
 872}
 873
 874
 875TEST (addq_dreg, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
 876{
 877  code[0] = R ("0101rrr000000rrr") | RANDOM_SIZE ();
 878}
 879
 880
 881TEST (addq_areg, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
 882{
 883  code[0] = R ("0101rrr000001rrr") | (randint (1, 2) << 6); /* word or long */
 884}
 885
 886
 887TEST (addq_ind, ALL_CCS, 1, MIGHT_CHANGE_MEMORY, NO_LIMIT)
 888{
 889  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 1);
 890  code[0] = (R ("0101rrr000000rrr")
 891	     | RANDOM_SIZE ()
 892	     | (randint (2, 4) << 3));  /* random amode [2, 4] */
 893}
 894
 895
 896TEST (addq_d16, ALL_CCS, 2, MIGHT_CHANGE_MEMORY, NO_LIMIT)
 897{
 898  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 1);
 899  code[0] = R ("0101rrr000101rrr") | RANDOM_SIZE ();
 900  code[1] = randint (-290, 290) & ~1;
 901}
 902
 903
 904TEST (addq_absl, ALL_CCS, 3, MIGHT_CHANGE_MEMORY, NO_LIMIT)
 905{
 906  code[0] = R ("0101rrr000111001") | RANDOM_SIZE ();
 907  WRITE4 (1, randint (MEM + 4, MEMEND - 4) & ~1);
 908}
 909
 910
 911TEST (addx_reg, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
 912{
 913  code[0] = R ("1101rrr100000rrr") | RANDOM_SIZE ();
 914}
 915
 916
 917TEST (addx_mem, ALL_CCS, 1, MIGHT_CHANGE_MEMORY, NO_LIMIT)
 918{
 919  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 1);
 920  code[0] = R ("1101rrr100001rrr") | RANDOM_SIZE ();
 921}
 922
 923
 924TEST (and_dreg_dreg, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
 925{
 926  code[0] = R ("1100rrr000000rrr") | RANDOM_SIZE ();
 927}
 928
 929
 930TEST (and_ind_dreg, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
 931{
 932  randomize_mem ();
 933  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 1);
 934  code[0] = (R ("1100rrr000000rrr")
 935	     | RANDOM_SIZE ()
 936	     | (randint (2, 4) << 3));
 937}
 938
 939
 940TEST (and_d16_dreg, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
 941{
 942  randomize_mem ();
 943  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 1);
 944  code[0] = R ("1100rrr000101rrr") | RANDOM_SIZE ();
 945  code[1] = randint (-290, 290) & ~1;
 946}
 947
 948
 949TEST (and_absl_dreg, ALL_CCS, 3, WONT_CHANGE_MEMORY, NO_LIMIT)
 950{
 951  randomize_mem ();
 952  code[0] = R ("1100rrr000111001") | RANDOM_SIZE ();
 953  WRITE4 (1, randint (MEM + 4, MEMEND - 4) & ~1);
 954}
 955
 956
 957TEST (andbw_const_dreg, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
 958{
 959  code[0] = R ("1100rrr00r111100");  /* randomly byte or word */
 960  code[1] = randnum ();
 961}
 962
 963
 964TEST (andl_const_dreg, ALL_CCS, 3, WONT_CHANGE_MEMORY, NO_LIMIT)
 965{
 966  code[0] = R ("1100rrr010111100");
 967  WRITE4 (1, randnum ());
 968}
 969
 970
 971TEST (and_dreg_ind, ALL_CCS, 1, MIGHT_CHANGE_MEMORY, NO_LIMIT)
 972{
 973  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 1);
 974  code[0] = (R ("1100rrr100000rrr")
 975	     | RANDOM_SIZE ()
 976	     | (randint (2, 4) << 3));
 977}
 978
 979
 980TEST (and_dreg_d16, ALL_CCS, 2, MIGHT_CHANGE_MEMORY, NO_LIMIT)
 981{
 982  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 1);
 983  code[0] = R ("1100rrr100101rrr") | RANDOM_SIZE ();
 984  code[1] = randint (-290, 290) & ~1;
 985}
 986
 987
 988TEST (and_dreg_absl, ALL_CCS, 3, MIGHT_CHANGE_MEMORY, NO_LIMIT)
 989{
 990  code[0] = R ("1100rrr100111001") | RANDOM_SIZE ();
 991  WRITE4 (1, randint (MEM + 4, MEMEND - 4) & ~1);
 992}
 993
 994
 995TEST (andibw_dreg, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
 996{
 997  code[0] = R ("000000100r000rrr");
 998  code[1] = randnum ();
 999}
1000
1001
1002TEST (andil_dreg, ALL_CCS, 3, WONT_CHANGE_MEMORY, NO_LIMIT)
1003{
1004  code[0] = R ("0000001010000rrr");
1005  WRITE4 (1, randnum ());
1006}
1007
1008
1009TEST (andibw_ind, ALL_CCS, 2, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1010{
1011  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 1);
1012  code[0] = R ("000000100r000rrr") | (randint (2, 4) << 3);
1013  code[1] = randnum ();
1014}
1015
1016
1017TEST (andil_ind, ALL_CCS, 3, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1018{
1019  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 1);
1020  code[0] = R ("0000001010000rrr") | (randint (2, 4) << 3);
1021  WRITE4 (1, randnum ());
1022}
1023
1024
1025TEST (andibw_d16, ALL_CCS, 3, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1026{
1027  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 1);
1028  code[0] = R ("000000100r101rrr");  /* randomly either byte or word. */
1029  code[1] = randnum ();
1030  code[2] = randint (-290, 290) & ~1;
1031}
1032
1033
1034TEST (andil_d16, ALL_CCS, 4, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1035{
1036  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 1);
1037  code[0] = R ("0000001010101rrr");
1038  WRITE4 (1, randnum ());
1039  code[3] = randint (-290, 290) & ~1;
1040}
1041
1042
1043TEST (andibw_absl, ALL_CCS, 4, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1044{
1045  code[0] = R ("000000100r111001");
1046  code[1] = randnum ();
1047  WRITE4 (2, randint (MEM + 4, MEMEND - 4) & ~1);
1048}
1049
1050
1051TEST (andil_absl, ALL_CCS, 5, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1052{
1053  code[0] = B ("0000001010111001");
1054  WRITE4 (1, randnum ());
1055  WRITE4 (3, randint (MEM + 4, MEMEND - 4) & ~1);
1056}
1057
1058
1059TEST (andi_to_ccr, ALL_CCS, 2, WONT_CHANGE_MEMORY, 32)
1060{
1061  code[0] = B ("0000001000111100");
1062  code[1] = times_called;
1063}
1064
1065
1066TEST (asl_dx_dy, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
1067{
1068  code[0] = R ("1110rrr100100rrr") | RANDOM_SIZE ();
1069}
1070
1071
1072TEST (asl_const_dy, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
1073{
1074  code[0] = R ("1110rrr100000rrr") | RANDOM_SIZE ();
1075}
1076
1077
1078TEST (asl_ind, ALL_CCS, 1, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1079{
1080  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 1);
1081  code[0] = R ("1110000111000rrr") | (randint (2, 4) << 3);
1082}
1083
1084
1085TEST (asl_d16, ALL_CCS, 2, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1086{
1087  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 1);
1088  code[0] = R ("1110000111101rrr");
1089  code[1] = randint (-290, 290) & ~1;
1090}
1091
1092
1093TEST (asl_absl, ALL_CCS, 3, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1094{
1095  code[0] = B ("1110000111111001");
1096  WRITE4 (1, randint (MEM + 4, MEMEND - 4) & ~1);
1097}
1098
1099
1100TEST (asr_dx_dy, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
1101{
1102  code[0] = R ("1110rrr000100rrr") | RANDOM_SIZE ();
1103}
1104
1105
1106TEST (asr_const_dy, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
1107{
1108  code[0] = R ("1110rrr000000rrr") | RANDOM_SIZE ();
1109}
1110
1111
1112TEST (asr_ind, ALL_CCS, 1, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1113{
1114  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 1);
1115  code[0] = R ("1110000011000rrr") | (randint (2, 4) << 3);
1116}
1117
1118
1119TEST (asr_d16, ALL_CCS, 2, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1120{
1121  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 1);
1122  code[0] = R ("1110000011101rrr");
1123  code[1] = randint (-290, 290) & ~1;
1124}
1125
1126
1127TEST (asr_absl, ALL_CCS, 3, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1128{
1129  code[0] = B ("1110000011111001");
1130  WRITE4 (1, randint (MEM + 4, MEMEND - 4) & ~1);
1131}
1132
1133
1134TEST (lsl_dx_dy, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
1135{
1136  code[0] = R ("1110rrr100101rrr") | RANDOM_SIZE ();
1137}
1138
1139
1140TEST (lsl_const_dy, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
1141{
1142  code[0] = R ("1110rrr100001rrr") | RANDOM_SIZE ();
1143}
1144
1145
1146TEST (lsl_ind, ALL_CCS, 1, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1147{
1148  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 1);
1149  code[0] = R ("1110001111000rrr") | (randint (2, 4) << 3);
1150}
1151
1152
1153TEST (lsl_d16, ALL_CCS, 2, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1154{
1155  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 1);
1156  code[0] = R ("1110001111101rrr");
1157  code[1] = randint (-290, 290) & ~1;
1158}
1159
1160
1161TEST (lsl_absl, ALL_CCS, 3, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1162{
1163  code[0] = B ("1110001111111001");
1164  WRITE4 (1, randint (MEM + 4, MEMEND - 4) & ~1);
1165}
1166
1167
1168TEST (lsr_dx_dy, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
1169{
1170  code[0] = R ("1110rrr000101rrr") | RANDOM_SIZE ();
1171}
1172
1173
1174TEST (lsr_const_dy, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
1175{
1176  code[0] = R ("1110rrr000001rrr") | RANDOM_SIZE ();
1177}
1178
1179
1180TEST (lsr_ind, ALL_CCS, 1, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1181{
1182  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 1);
1183  code[0] = R ("1110001011000rrr") | (randint (2, 4) << 3);
1184}
1185
1186
1187TEST (lsr_d16, ALL_CCS, 2, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1188{
1189  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 1);
1190  code[0] = R ("1110001011101rrr");
1191  code[1] = randint (-290, 290) & ~1;
1192}
1193
1194
1195TEST (lsr_absl, ALL_CCS, 3, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1196{
1197  code[0] = B ("1110001011111001");
1198  WRITE4 (1, randint (MEM + 4, MEMEND - 4) & ~1);
1199}
1200
1201
1202#define BCC_TEST_B(bits) \
1203  code[0] = 0x6004 | ((bits) << 8);  /* b?? * + 4 */   \
1204  code[1] = B ("0111000000000000");  /* moveq #0,d0 */ \
1205  code[2] = 0x6002;                  /* bra * + 2 */   \
1206  code[3] = B ("0111000000000001");  /* moveq #1,d0 */ \
1207  code[4] = NOP_OPCODE               /* nop */
1208
1209TEST (bra_b, ALL_CCS, 5, WONT_CHANGE_MEMORY, 2) { BCC_TEST_B (0x0); }
1210/* 0x1 is reserved for bsr */
1211TEST (bhi_b, ALL_CCS, 5, WONT_CHANGE_MEMORY, 2) { BCC_TEST_B (0x2); }
1212TEST (bls_b, ALL_CCS, 5, WONT_CHANGE_MEMORY, 2) { BCC_TEST_B (0x3); }
1213TEST (bcc_b, ALL_CCS, 5, WONT_CHANGE_MEMORY, 2) { BCC_TEST_B (0x4); }
1214TEST (bcs_b, ALL_CCS, 5, WONT_CHANGE_MEMORY, 2) { BCC_TEST_B (0x5); }
1215TEST (bne_b, ALL_CCS, 5, WONT_CHANGE_MEMORY, 2) { BCC_TEST_B (0x6); }
1216TEST (beq_b, ALL_CCS, 5, WONT_CHANGE_MEMORY, 2) { BCC_TEST_B (0x7); }
1217TEST (bvc_b, ALL_CCS, 5, WONT_CHANGE_MEMORY, 2) { BCC_TEST_B (0x8); }
1218TEST (bvs_b, ALL_CCS, 5, WONT_CHANGE_MEMORY, 2) { BCC_TEST_B (0x9); }
1219TEST (bpl_b, ALL_CCS, 5, WONT_CHANGE_MEMORY, 2) { BCC_TEST_B (0xA); }
1220TEST (bmi_b, ALL_CCS, 5, WONT_CHANGE_MEMORY, 2) { BCC_TEST_B (0xB); }
1221TEST (bge_b, ALL_CCS, 5, WONT_CHANGE_MEMORY, 2) { BCC_TEST_B (0xC); }
1222TEST (blt_b, ALL_CCS, 5, WONT_CHANGE_MEMORY, 2) { BCC_TEST_B (0xD); }
1223TEST (bgt_b, ALL_CCS, 5, WONT_CHANGE_MEMORY, 2) { BCC_TEST_B (0xE); }
1224TEST (ble_b, ALL_CCS, 5, WONT_CHANGE_MEMORY, 2) { BCC_TEST_B (0xF); }
1225
1226#undef BCC_TEST_B
1227
1228#define BCC_TEST_W(bits) \
1229  code[0] = 0x6000 | ((bits) << 8);    /* b?? * + 8   */ \
1230  code[1] = 0x0006;                    /* (offset)    */ \
1231  code[2] = B ("0111000000000000");    /* moveq #0,d0 */ \
1232  code[3] = 0x6002;                    /* bra * + 2   */ \
1233  code[4] = B ("0111000000000001");    /* moveq #1,d0 */ \
1234  code[5] = NOP_OPCODE                 /* nop         */
1235
1236TEST (bra_w, ALL_CCS, 6, WONT_CHANGE_MEMORY, 2) { BCC_TEST_W (0x0); }
1237/* 0x1 is reserved for bsr */
1238TEST (bhi_w, ALL_CCS, 6, WONT_CHANGE_MEMORY, 2) { BCC_TEST_W (0x2); }
1239TEST (bls_w, ALL_CCS, 6, WONT_CHANGE_MEMORY, 2) { BCC_TEST_W (0x3); }
1240TEST (bcc_w, ALL_CCS, 6, WONT_CHANGE_MEMORY, 2) { BCC_TEST_W (0x4); }
1241TEST (bcs_w, ALL_CCS, 6, WONT_CHANGE_MEMORY, 2) { BCC_TEST_W (0x5); }
1242TEST (bne_w, ALL_CCS, 6, WONT_CHANGE_MEMORY, 2) { BCC_TEST_W (0x6); }
1243TEST (beq_w, ALL_CCS, 6, WONT_CHANGE_MEMORY, 2) { BCC_TEST_W (0x7); }
1244TEST (bvc_w, ALL_CCS, 6, WONT_CHANGE_MEMORY, 2) { BCC_TEST_W (0x8); }
1245TEST (bvs_w, ALL_CCS, 6, WONT_CHANGE_MEMORY, 2) { BCC_TEST_W (0x9); }
1246TEST (bpl_w, ALL_CCS, 6, WONT_CHANGE_MEMORY, 2) { BCC_TEST_W (0xA); }
1247TEST (bmi_w, ALL_CCS, 6, WONT_CHANGE_MEMORY, 2) { BCC_TEST_W (0xB); }
1248TEST (bge_w, ALL_CCS, 6, WONT_CHANGE_MEMORY, 2) { BCC_TEST_W (0xC); }
1249TEST (blt_w, ALL_CCS, 6, WONT_CHANGE_MEMORY, 2) { BCC_TEST_W (0xD); }
1250TEST (bgt_w, ALL_CCS, 6, WONT_CHANGE_MEMORY, 2) { BCC_TEST_W (0xE); }
1251TEST (ble_w, ALL_CCS, 6, WONT_CHANGE_MEMORY, 2) { BCC_TEST_W (0xF); }
1252
1253#undef BCC_TEST_W
1254
1255#define BCC_TEST_L(bits) \
1256  code[0] = 0x60FF | ((bits) << 8);    /* b?? * + 8   */ \
1257  code[1] = 0x0000;                    /* (offset hi) */ \
1258  code[2] = 0x0008;                    /* (offset lo) */ \
1259  code[3] = B ("0111000000000000");    /* moveq #0,d0 */ \
1260  code[4] = 0x6002;                    /* bra * + 2   */ \
1261  code[5] = B ("0111000000000001");    /* moveq #1,d0 */ \
1262  code[6] = NOP_OPCODE                 /* nop         */
1263
1264TEST (bra_l, ALL_CCS, 7, WONT_CHANGE_MEMORY, 2) { BCC_TEST_L (0x0); }
1265/* 0x1 is reserved for bsr */
1266TEST (bhi_l, ALL_CCS, 7, WONT_CHANGE_MEMORY, 2) { BCC_TEST_L (0x2); }
1267TEST (bls_l, ALL_CCS, 7, WONT_CHANGE_MEMORY, 2) { BCC_TEST_L (0x3); }
1268TEST (bcc_l, ALL_CCS, 7, WONT_CHANGE_MEMORY, 2) { BCC_TEST_L (0x4); }
1269TEST (bcs_l, ALL_CCS, 7, WONT_CHANGE_MEMORY, 2) { BCC_TEST_L (0x5); }
1270TEST (bne_l, ALL_CCS, 7, WONT_CHANGE_MEMORY, 2) { BCC_TEST_L (0x6); }
1271TEST (beq_l, ALL_CCS, 7, WONT_CHANGE_MEMORY, 2) { BCC_TEST_L (0x7); }
1272TEST (bvc_l, ALL_CCS, 7, WONT_CHANGE_MEMORY, 2) { BCC_TEST_L (0x8); }
1273TEST (bvs_l, ALL_CCS, 7, WONT_CHANGE_MEMORY, 2) { BCC_TEST_L (0x9); }
1274TEST (bpl_l, ALL_CCS, 7, WONT_CHANGE_MEMORY, 2) { BCC_TEST_L (0xA); }
1275TEST (bmi_l, ALL_CCS, 7, WONT_CHANGE_MEMORY, 2) { BCC_TEST_L (0xB); }
1276TEST (bge_l, ALL_CCS, 7, WONT_CHANGE_MEMORY, 2) { BCC_TEST_L (0xC); }
1277TEST (blt_l, ALL_CCS, 7, WONT_CHANGE_MEMORY, 2) { BCC_TEST_L (0xD); }
1278TEST (bgt_l, ALL_CCS, 7, WONT_CHANGE_MEMORY, 2) { BCC_TEST_L (0xE); }
1279TEST (ble_l, ALL_CCS, 7, WONT_CHANGE_MEMORY, 2) { BCC_TEST_L (0xF); }
1280
1281#undef BCC_TEST_L
1282
1283
1284TEST (bchg_reg_reg, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
1285{
1286  code[0] = R ("0000rrr101000rrr");
1287}
1288
1289
1290TEST (bchg_const_reg, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
1291{
1292  code[0] = R ("0000100001000rrr");
1293  code[1] = randint (0, 65535);
1294}
1295
1296
1297TEST (bchg_reg_ind, ALL_CCS, 1, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1298{
1299  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 0);
1300  code[0] = R ("0000rrr101000rrr") | (randint (2, 4) << 3);
1301}
1302
1303
1304TEST (bchg_const_ind, ALL_CCS, 2, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1305{
1306  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 0);
1307  code[0] = R ("0000100001000rrr") | (randint (2, 4) << 3);
1308  code[1] = randint (0, 65535);
1309}
1310
1311
1312TEST (bchg_reg_d16, ALL_CCS, 2, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1313{
1314  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 0);
1315  code[0] = R ("0000rrr101101rrr");
1316  code[1] = randint (-290, 290);
1317}
1318
1319
1320TEST (bchg_const_d16, ALL_CCS, 3, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1321{
1322  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 0);
1323  code[0] = R ("0000100001101rrr");
1324  code[1] = randint (0, 65535);
1325  code[2] = randint (-290, 290);
1326}
1327
1328
1329TEST (bchg_reg_absl, ALL_CCS, 3, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1330{
1331  code[0] = R ("0000rrr101111001");
1332  WRITE4 (1, randint (MEM + 4, MEMEND - 4));
1333}
1334
1335
1336TEST (bchg_const_absl, ALL_CCS, 4, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1337{
1338  code[0] = R ("0000100001111001");
1339  code[1] = randint (0, 65535);
1340  WRITE4 (2, randint (MEM + 4, MEMEND - 4));
1341}
1342
1343
1344TEST (bclr_reg_reg, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
1345{
1346  code[0] = R ("0000rrr110000rrr");
1347}
1348
1349
1350TEST (bclr_const_reg, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
1351{
1352  code[0] = R ("0000100010000rrr");
1353  code[1] = randint (0, 65535);
1354}
1355
1356
1357TEST (bclr_reg_ind, ALL_CCS, 1, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1358{
1359  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 0);
1360  code[0] = R ("0000rrr110000rrr") | (randint (2, 4) << 3);
1361}
1362
1363
1364TEST (bclr_const_ind, ALL_CCS, 2, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1365{
1366  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 0);
1367  code[0] = R ("0000100010000rrr") | (randint (2, 4) << 3);
1368  code[1] = randint (0, 65535);
1369}
1370
1371
1372TEST (bclr_reg_d16, ALL_CCS, 2, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1373{
1374  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 0);
1375  code[0] = R ("0000rrr110101rrr");
1376  code[1] = randint (-290, 290);
1377}
1378
1379
1380TEST (bclr_const_d16, ALL_CCS, 3, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1381{
1382  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 0);
1383  code[0] = R ("0000100010101rrr");
1384  code[1] = randint (0, 65535);
1385  code[2] = randint (-290, 290);
1386}
1387
1388
1389TEST (bclr_reg_absl, ALL_CCS, 3, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1390{
1391  code[0] = R ("0000rrr110111001");
1392  WRITE4 (1, randint (MEM + 4, MEMEND - 4));
1393}
1394
1395
1396TEST (bclr_const_absl, ALL_CCS, 4, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1397{
1398  code[0] = R ("0000100010111001");
1399  code[1] = randint (0, 65535);
1400  WRITE4 (2, randint (MEM + 4, MEMEND - 4));
1401}
1402
1403
1404TEST (bset_reg_reg, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
1405{
1406  code[0] = R ("0000rrr111000rrr");
1407}
1408
1409
1410TEST (bset_const_reg, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
1411{
1412  code[0] = R ("0000100011000rrr");
1413  code[1] = randint (0, 65535);
1414}
1415
1416
1417TEST (bset_reg_ind, ALL_CCS, 1, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1418{
1419  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 0);
1420  code[0] = R ("0000rrr111000rrr") | (randint (2, 4) << 3);
1421}
1422
1423
1424TEST (bset_const_ind, ALL_CCS, 2, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1425{
1426  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 0);
1427  code[0] = R ("0000100011000rrr") | (randint (2, 4) << 3);
1428  code[1] = randint (0, 65535);
1429}
1430
1431
1432TEST (bset_reg_d16, ALL_CCS, 2, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1433{
1434  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 0);
1435  code[0] = R ("0000rrr111101rrr");
1436  code[1] = randint (-290, 290);
1437}
1438
1439
1440TEST (bset_const_d16, ALL_CCS, 3, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1441{
1442  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 0);
1443  code[0] = R ("0000100011101rrr");
1444  code[1] = randint (0, 65535);
1445  code[2] = randint (-290, 290);
1446}
1447
1448
1449TEST (bset_reg_absl, ALL_CCS, 3, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1450{
1451  code[0] = R ("0000rrr111111001");
1452  WRITE4 (1, randint (MEM + 4, MEMEND - 4));
1453}
1454
1455
1456TEST (bset_const_absl, ALL_CCS, 4, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1457{
1458  code[0] = R ("0000100011111001");
1459  code[1] = randint (0, 65535);
1460  WRITE4 (2, randint (MEM + 4, MEMEND - 4));
1461}
1462
1463
1464TEST (btst_reg_reg, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
1465{
1466  code[0] = R ("0000rrr100000rrr");
1467}
1468
1469
1470TEST (btst_const_reg, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
1471{
1472  code[0] = R ("0000100000000rrr");
1473  code[1] = randint (0, 65535);
1474}
1475
1476
1477TEST (btst_reg_ind, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
1478{
1479  randomize_mem ();
1480  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 0);
1481  code[0] = R ("0000rrr100000rrr") | (randint (2, 4) << 3);
1482}
1483
1484
1485TEST (btst_const_ind, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
1486{
1487  randomize_mem ();
1488  randomize_regs (8, 8 + 7, MEM + 50, MEMEND - 50, 0);
1489  code[0] = R ("0000100000000rrr") | (randint (2, 4) << 3);
1490  code[1] = randint (0, 65535);
1491}
1492
1493
1494TEST (btst_reg_d16, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
1495{
1496  randomize_mem ();
1497  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 0);
1498  code[0] = R ("0000rrr100101rrr");
1499  code[1] = randint (-290, 290);
1500}
1501
1502
1503TEST (btst_const_d16, ALL_CCS, 3, WONT_CHANGE_MEMORY, NO_LIMIT)
1504{
1505  randomize_mem ();
1506  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 0);
1507  code[0] = R ("0000100000101rrr");
1508  code[1] = randint (0, 65535);
1509  code[2] = randint (-290, 290);
1510}
1511
1512
1513TEST (btst_reg_absl, ALL_CCS, 3, WONT_CHANGE_MEMORY, NO_LIMIT)
1514{
1515  randomize_mem ();
1516  code[0] = R ("0000rrr100111001");
1517  WRITE4 (1, randint (MEM + 4, MEMEND - 4));
1518}
1519
1520
1521TEST (btst_const_absl, ALL_CCS, 4, WONT_CHANGE_MEMORY, NO_LIMIT)
1522{
1523  randomize_mem ();
1524  code[0] = B ("0000100000111001");
1525  code[1] = randint (0, 65535);
1526  WRITE4 (2, randint (MEM + 4, MEMEND - 4));
1527}
1528
1529
1530TEST (bfchg_reg, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
1531{
1532  code[0] = R ("1110101011000rrr");
1533  code[1] = randint (0, 65535);
1534}
1535
1536
1537TEST (bfchg_ind, ALL_CCS, 2, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1538{
1539  randomize_regs (0, 7, -250 * 8, 250 * 8, 0);           /* Offset/width */
1540  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 0); /* Base */
1541  code[0] = R ("1110101011010rrr");
1542  code[1] = randint (0, 65535);
1543}
1544
1545
1546TEST (bfchg_d16, ALL_CCS, 3, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1547{
1548  randomize_regs (0, 7, -130 * 8, 130 * 8, 0);           /* Offset/width */
1549  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 0); /* Base */
1550  code[0] = R ("1110101011101rrr");
1551  code[1] = randint (0, 65535);
1552  code[2] = randint (-130, 130);
1553}
1554
1555
1556TEST (bfchg_absl, ALL_CCS, 4, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1557{
1558  randomize_regs (0, 7, -130 * 8, 130 * 8, 0);           /* Offset/width */
1559  code[0] = B ("1110101011111001");
1560  code[1] = randint (0, 65535);
1561  WRITE4 (2, randint (MEM + 200, MEMEND - 200));
1562}
1563
1564
1565TEST (bfclr_reg, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
1566{
1567  code[0] = R ("1110110011000rrr");
1568  code[1] = randint (0, 65535);
1569}
1570
1571
1572TEST (bfclr_ind, ALL_CCS, 2, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1573{
1574  randomize_regs (0, 7, -250 * 8, 250 * 8, 0);           /* Offset/width */
1575  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 0); /* Base */
1576  code[0] = R ("1110110011010rrr");
1577  code[1] = randint (0, 65535);
1578}
1579
1580
1581TEST (bfclr_d16, ALL_CCS, 3, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1582{
1583  randomize_regs (0, 7, -130 * 8, 130 * 8, 0);           /* Offset/width */
1584  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 0); /* Base */
1585  code[0] = R ("1110110011101rrr");
1586  code[1] = randint (0, 65535);
1587  code[2] = randint (-130, 130);
1588}
1589
1590
1591TEST (bfclr_absl, ALL_CCS, 4, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1592{
1593  randomize_regs (0, 7, -130 * 8, 130 * 8, 0);           /* Offset/width */
1594  code[0] = B ("1110110011111001");
1595  code[1] = randint (0, 65535);
1596  WRITE4 (2, randint (MEM + 200, MEMEND - 200));
1597}
1598
1599
1600TEST (bfset_reg, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
1601{
1602  code[0] = R ("1110111011000rrr");
1603  code[1] = randint (0, 65535);
1604}
1605
1606
1607TEST (bfset_ind, ALL_CCS, 2, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1608{
1609  randomize_regs (0, 7, -250 * 8, 250 * 8, 0);           /* Offset/width */
1610  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 0); /* Base */
1611  code[0] = R ("1110111011010rrr");
1612  code[1] = randint (0, 65535);
1613}
1614
1615
1616TEST (bfset_d16, ALL_CCS, 3, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1617{
1618  randomize_regs (0, 7, -130 * 8, 130 * 8, 0);           /* Offset/width */
1619  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 0); /* Base */
1620  code[0] = R ("1110111011101rrr");
1621  code[1] = randint (0, 65535);
1622  code[2] = randint (-130, 130);
1623}
1624
1625
1626TEST (bfset_absl, ALL_CCS, 4, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1627{
1628  randomize_regs (0, 7, -130 * 8, 130 * 8, 0);           /* Offset/width */
1629  code[0] = B ("1110111011111001");
1630  code[1] = randint (0, 65535);
1631  WRITE4 (2, randint (MEM + 200, MEMEND - 200));
1632}
1633
1634
1635TEST (bftst_reg, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
1636{
1637  code[0] = R ("1110100011000rrr");
1638  code[1] = randint (0, 65535);
1639}
1640
1641
1642TEST (bftst_ind, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
1643{
1644  randomize_mem ();
1645  randomize_regs (0, 7, -250 * 8, 250 * 8, 0);           /* Offset/width */
1646  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 0); /* Base */
1647  code[0] = R ("1110100011010rrr");
1648  code[1] = randint (0, 65535);
1649}
1650
1651
1652TEST (bftst_d16, ALL_CCS, 3, WONT_CHANGE_MEMORY, NO_LIMIT)
1653{
1654  randomize_mem ();
1655  randomize_regs (0, 7, -130 * 8, 130 * 8, 0);           /* Offset/width */
1656  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 0); /* Base */
1657  code[0] = R ("1110100011101rrr");
1658  code[1] = randint (0, 65535);
1659  code[2] = randint (-130, 130);
1660}
1661
1662
1663TEST (bftst_absl, ALL_CCS, 4, WONT_CHANGE_MEMORY, NO_LIMIT)
1664{
1665  randomize_mem ();
1666  randomize_regs (0, 7, -130 * 8, 130 * 8, 0);           /* Offset/width */
1667  code[0] = B ("1110100011111001");
1668  code[1] = randint (0, 65535);
1669  WRITE4 (2, randint (MEM + 200, MEMEND - 200));
1670}
1671
1672
1673TEST (bfexts_reg, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
1674{
1675  code[0] = R ("1110101111000rrr");
1676  code[1] = randint (0, 65535);
1677}
1678
1679
1680TEST (bfexts_ind, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
1681{
1682  randomize_mem ();
1683  randomize_regs (0, 7, -250 * 8, 250 * 8, 0);           /* Offset/width */
1684  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 0); /* Base */
1685  code[0] = R ("1110101111010rrr");
1686  code[1] = randint (0, 65535);
1687}
1688
1689
1690TEST (bfexts_d16, ALL_CCS, 3, WONT_CHANGE_MEMORY, NO_LIMIT)
1691{
1692  randomize_mem ();
1693  randomize_regs (0, 7, -130 * 8, 130 * 8, 0);           /* Offset/width */
1694  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 0); /* Base */
1695  code[0] = R ("1110101111101rrr");
1696  code[1] = randint (0, 65535);
1697  code[2] = randint (-130, 130);
1698}
1699
1700
1701TEST (bfexts_absl, ALL_CCS, 4, WONT_CHANGE_MEMORY, NO_LIMIT)
1702{
1703  randomize_mem ();
1704  randomize_regs (0, 7, -130 * 8, 130 * 8, 0);           /* Offset/width */
1705  code[0] = B ("1110101111111001");
1706  code[1] = randint (0, 65535);
1707  WRITE4 (2, randint (MEM + 200, MEMEND - 200));
1708}
1709
1710
1711TEST (bfextu_reg, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
1712{
1713  code[0] = R ("1110100111000rrr");
1714  code[1] = randint (0, 65535);
1715}
1716
1717
1718TEST (bfextu_ind, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
1719{
1720  randomize_mem ();
1721  randomize_regs (0, 7, -250 * 8, 250 * 8, 0);           /* Offset/width */
1722  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 0); /* Base */
1723  code[0] = R ("1110100111010rrr");
1724  code[1] = randint (0, 65535);
1725}
1726
1727
1728TEST (bfextu_d16, ALL_CCS, 3, WONT_CHANGE_MEMORY, NO_LIMIT)
1729{
1730  randomize_mem ();
1731  randomize_regs (0, 7, -130 * 8, 130 * 8, 0);           /* Offset/width */
1732  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 0); /* Base */
1733  code[0] = R ("1110100111101rrr");
1734  code[1] = randint (0, 65535);
1735  code[2] = randint (-130, 130);
1736}
1737
1738
1739TEST (bfextu_absl, ALL_CCS, 4, WONT_CHANGE_MEMORY, NO_LIMIT)
1740{
1741  randomize_mem ();
1742  randomize_regs (0, 7, -130 * 8, 130 * 8, 0);           /* Offset/width */
1743  code[0] = B ("1110100111111001");
1744  code[1] = randint (0, 65535);
1745  WRITE4 (2, randint (MEM + 200, MEMEND - 200));
1746}
1747
1748
1749TEST (bfffo_reg, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
1750{
1751  code[0] = R ("1110110111000rrr");
1752  code[1] = randint (0, 65535);
1753}
1754
1755
1756TEST (bfffo_ind, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
1757{
1758  randomize_mem ();
1759  randomize_regs (0, 7, -250 * 8, 250 * 8, 0);           /* Offset/width */
1760  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 0); /* Base */
1761  code[0] = R ("1110110111010rrr");
1762  code[1] = randint (0, 65535);
1763}
1764
1765
1766TEST (bfffo_d16, ALL_CCS, 3, WONT_CHANGE_MEMORY, NO_LIMIT)
1767{
1768  randomize_mem ();
1769  randomize_regs (0, 7, -130 * 8, 130 * 8, 0);           /* Offset/width */
1770  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 0); /* Base */
1771  code[0] = R ("1110110111101rrr");
1772  code[1] = randint (0, 65535);
1773  code[2] = randint (-130, 130);
1774}
1775
1776
1777TEST (bfffo_absl, ALL_CCS, 4, WONT_CHANGE_MEMORY, NO_LIMIT)
1778{
1779  randomize_regs (0, 7, -130 * 8, 130 * 8, 0);           /* Offset/width */
1780  randomize_mem ();
1781  code[0] = B ("1110110111111001");
1782  code[1] = randint (0, 65535);
1783  WRITE4 (2, randint (MEM + 200, MEMEND - 200));
1784}
1785
1786
1787TEST (bfins_reg, ALL_CCS, 2, WONT_CHANGE_MEMORY, NO_LIMIT)
1788{
1789  code[0] = R ("1110111111000rrr");
1790  code[1] = randint (0, 65535);
1791}
1792
1793
1794TEST (bfins_ind, ALL_CCS, 2, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1795{
1796  randomize_regs (0, 7, -250 * 8, 250 * 8, 0);           /* Offset/width */
1797  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 0); /* Base */
1798  code[0] = R ("1110111111010rrr");
1799  code[1] = randint (0, 65535);
1800}
1801
1802
1803TEST (bfins_d16, ALL_CCS, 3, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1804{
1805  randomize_regs (0, 7, -130 * 8, 130 * 8, 0);           /* Offset/width */
1806  randomize_regs (8, 8 + 7, MEM + 300, MEMEND - 300, 0); /* Base */
1807  code[0] = R ("1110111111101rrr");
1808  code[1] = randint (0, 65535);
1809  code[2] = randint (-130, 130);
1810}
1811
1812
1813TEST (bfins_absl, ALL_CCS, 4, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1814{
1815  randomize_regs (0, 7, -130 * 8, 130 * 8, 0);           /* Offset/width */
1816  code[0] = B ("1110111111111001");
1817  code[1] = randint (0, 65535);
1818  WRITE4 (2, randint (MEM + 200, MEMEND - 200));
1819}
1820
1821
1822TEST (bsr_b, ALL_CCS, 6, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1823{
1824  randomize_regs (15, 15, MEM + 50, MEMEND - 50, 1);  /* random sp */
1825  code[0] = 0x6104;                  /* bsr * + 4   */
1826  code[1] = 0x5280;                  /* addql #1,d0 */
1827  code[2] = 0x6004;                  /* bra * + 4 */
1828  code[3] = R ("01110000rrrrrrrr");  /* moveq #<random>,d0 */
1829  code[4] = 0x4E75;                  /* rts */
1830  code[5] = NOP_OPCODE;              /* nop */
1831}
1832
1833
1834TEST (bsr_w, ALL_CCS, 7, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1835{
1836  randomize_regs (15, 15, MEM + 50, MEMEND - 50, 1);  /* random sp */
1837  code[0] = 0x6100;                  /* bsr * + 6   */
1838  code[1] = 0x0006;
1839  code[2] = 0x5280;                  /* addql #1,d0 */
1840  code[3] = 0x6004;                  /* bra * + 4 */
1841  code[4] = R ("01110000rrrrrrrr");  /* moveq #<random>,d0 */
1842  code[5] = 0x4E75;                  /* rts */
1843  code[6] = NOP_OPCODE;              /* nop */
1844}
1845
1846
1847TEST (bsr_l, ALL_CCS, 8, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1848{
1849  randomize_regs (15, 15, MEM + 50, MEMEND - 50, 1);  /* random sp */
1850  code[0] = 0x61FF;                  /* bsr * + 8   */
1851  code[1] = 0x0000;
1852  code[2] = 0x0008;
1853  code[3] = 0x5280;                  /* addql #1,d0 */
1854  code[4] = 0x6004;                  /* bra * + 4 */
1855  code[5] = R ("01110000rrrrrrrr");  /* moveq #<random>,d0 */
1856  code[6] = 0x4E75;                  /* rts */
1857  code[7] = NOP_OPCODE;              /* nop */
1858}
1859
1860
1861TEST (cas_ind, ALL_CCS, 2, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1862{
1863  randomize_regs (7, 7 + 8, MEM + 50, MEMEND - 50, 1);
1864  code[0] = (R ("0000100011000rrr")
1865	     | (randint (1, 3) << 9)    /* Random size */
1866	     | (randint (2, 4) << 3));  /* Random amode [2, 4] */
1867  code[1] = randint (0, 65535);
1868}
1869
1870
1871TEST (cas2_areg, ALL_CCS, 3, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1872{
1873  randomize_regs (7, 7 + 8, MEM + 50, MEMEND - 50, 1);
1874  code[0] = R ("000011r011111100");  /* Randomly either word or long. */
1875  code[1] = R ("1rrr000rrr000rrr");
1876  code[2] = R ("1rrr000rrr000rrr");
1877}
1878
1879
1880TEST (cas2_anyreg, ALL_CCS, 3, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1881{
1882  randomize_regs (0, 7 + 8, MEM + 50, MEMEND - 50, 1);
1883  code[0] = R ("000011r011111100");  /* Randomly either word or long. */
1884  code[1] = R ("rrrr000rrr000rrr");
1885  code[2] = R ("rrrr000rrr000rrr");
1886}
1887
1888
1889TEST (clr_reg, ALL_CCS, 1, WONT_CHANGE_MEMORY, NO_LIMIT)
1890{
1891  code[0] = R ("0100001000000rrr") | RANDOM_SIZE ();
1892}
1893
1894
1895TEST (clrb_ind, ALL_CCS, 1, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1896{
1897  randomize_regs (7, 7 + 8, MEM + 50, MEMEND - 50, 0);
1898  code[0] = R ("0100001000000rrr") | (randint (2, 4) << 3);
1899}
1900
1901
1902TEST (clrwl_ind, ALL_CCS, 1, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1903{
1904  randomize_regs (7, 7 + 8, MEM + 50, MEMEND - 50, 1);
1905  code[0] = (R ("0100001000000rrr")
1906	     | (randint (1, 2) << 6)   /* Randomly either word or long. */
1907	     | (randint (2, 4) << 3)); /* Random amode [2, 4] */
1908}
1909
1910
1911TEST (clrb_absl, ALL_CCS, 3, MIGHT_CHANGE_MEMORY, NO_LIMIT)
1912{
1913  code[0] = B ("0100001000111001");
1914  WRITE4 (1, randint

Large files files are truncated, but you can click here to view the full file