home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 (Developer) / NS_dev_3.2.iso / NextDeveloper / Source / GNU / cctools / as / m88k-check.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-01-31  |  2.0 KB  |  128 lines

  1. #include "m88k-opcode.h"
  2. main()
  3. {
  4.     long i, j;
  5.  
  6.     for(i = 0; i < NUMOPCODES - 1; i++){
  7.         printf("\t%s\t", m88k_opcodes[i].name);
  8.         if(m88k_opcodes[i].op[0].type == NIL)
  9.         printf("\n");
  10.         for(j = 0; j < 3 && m88k_opcodes[i].op[j].type != NIL; j++){
  11.         switch(m88k_opcodes[i].op[j].type){
  12.         case CNST:
  13. #ifdef SIGNED_IMMEDIATES
  14.         case SCNST:
  15. #endif
  16.             printf("0x%04x", cnst() );
  17.             break;
  18.         case REG:
  19.             printf("r%d", reg() );
  20.             break;
  21.         case BF:
  22.             printf("%d<%d>", reg(), reg() );
  23.             break;
  24.         case REGSC:
  25.             printf("[r%d]", reg() );
  26.             break;
  27.         case CRREG:
  28.             printf("cr%d", creg() );
  29.             break;
  30.         case FCRREG:
  31.             printf("fcr%d", creg() );
  32.             break;
  33.         case PCREL:
  34.             printf("undef");
  35.             break;
  36.         case CONDMASK:
  37.             print_cond();
  38.             break;
  39.         case CMPRSLT:
  40.             print_cmp();
  41.             break;
  42.         case ROT:
  43.             printf("<%d>", reg() );
  44.             break;
  45.         case E4ROT:
  46.             printf("<%d>", creg() & ~0x3);
  47.             break;
  48.         case EREG:
  49.             printf("r%d", reg() & ~0x1);
  50.             break;
  51.         case XREG:
  52.             printf("x%d", reg());
  53.             break;
  54.         }
  55.         if(j == 2 || m88k_opcodes[i].op[j+1].type == NIL)
  56.             printf("\n");
  57.         else if(m88k_opcodes[i].op[j+1].type != REGSC)
  58.             printf(",");
  59.         }
  60.     }
  61. }
  62.  
  63. reg()
  64. {
  65.      static int x = 1;
  66.  
  67.     x = (x + 1) & 0x1f;
  68.     return(x);
  69. }
  70.  
  71. creg()
  72. {
  73.      static int x = 1;
  74.  
  75.     x = (x + 1) & 0x3f;
  76.     return(x);
  77. }
  78.  
  79. cnst()
  80. {
  81.      static int x = 1;
  82.  
  83.     x = (x + 1) & 0xffff;
  84.     return(x);
  85. }
  86.  
  87. print_cond()
  88. {
  89.      static int x = 1;
  90.  
  91.     x = (x + 1) & 0x1f;
  92.     switch(x){
  93.     case 0x02:
  94.         printf("eq0");
  95.         break;
  96.     case 0x0d:
  97.         printf("ne0");
  98.         break;
  99.     case 0x01:
  100.         printf("gt0");
  101.         break;
  102.     case 0x0c:
  103.         printf("lt0");
  104.         break;
  105.     case 0x03:
  106.         printf("ge0");
  107.         break;
  108.     case 0x0e:
  109.         printf("le0");
  110.         break;
  111.     default:
  112.         printf("%d", x);
  113.     }
  114. }
  115.  
  116. char *cmpslot[] = { "**", "**", "eq", "ne", "gt", "le", "lt", "ge",
  117.             "hi", "ls", "lo", "hs", "be", "nb", "he", "nh" };
  118. print_cmp()
  119. {
  120.      static int x = 1;
  121.  
  122.     x = (x + 1) & 0x1f;
  123.     if(x < 2 || x > 15)
  124.         printf("%d", x);
  125.     else
  126.         printf("%s", cmpslot[x]);
  127. }
  128.