home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / OBJASM.ZIP / ODISFP.C < prev    next >
C/C++ Source or Header  |  1990-11-15  |  4KB  |  115 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "o.h"
  4.  
  5. char *esc_0x0X[];
  6. char *esc_0x1C[];
  7.  
  8. void esc_special( opcode, operand, esc_byte, reg )
  9.     char            *opcode;
  10.     char            *operand;
  11.     int             esc_byte;
  12.     int             reg;
  13. {
  14.     int             element;
  15.  
  16.     strcpy( opcode, "" );
  17.     strcpy( operand, "" );
  18.     
  19.     /*
  20.     ** This routine is bad, but it would make no more sense if it listed
  21.     ** out all of the possible esc_byte and register combinations!
  22.     */
  23.     if ( esc_byte == 0x0A ) {
  24.         if ( reg == 0x00 ) {
  25.             strcpy( opcode, "fnop" );
  26.         }
  27.         return;
  28.     }
  29.     if ( esc_byte == 0x0B ) {
  30.         return;
  31.     }
  32.     if ( esc_byte >= 0x0C && esc_byte <= 0x0F ) {
  33.         element = (esc_byte - 0x0C) * 8 + reg;
  34.         strcpy( opcode, esc_0x0X[element] );
  35.         return;
  36.     }
  37.     if ( esc_byte >= 0x10 && esc_byte <= 0x1F ) {
  38.         if ( esc_byte == 0x15 && reg == 0x01 ) {
  39.             strcpy( opcode, "fucompp" );
  40.         }
  41.         if ( esc_byte == 0x1C ) {
  42.             strcpy( opcode, esc_0x1C[reg] );
  43.         }
  44.         return;
  45.     }
  46.     if ( esc_byte == 0x22 || esc_byte == 0x23 || esc_byte == 0x29 
  47.          || (esc_byte >= 0x2C && esc_byte <= 0x2F) ) {
  48.         return;
  49.     }
  50.     if ( esc_byte == 0x33 ) {
  51.         if ( reg == 0x01 ) {
  52.             strcpy( opcode, "fcompp" );
  53.         }
  54.         return;
  55.     }   
  56.     if ( esc_byte == 0x32 ) {
  57.         return;
  58.     }
  59.     if ( esc_byte == 0x38 || esc_byte == 0x39
  60.       || esc_byte == 0x3A || esc_byte == 0x3B ) {
  61.         return;
  62.     }
  63.     if ( esc_byte == 0x3C ) {
  64.         if ( reg == 0x00 ) {
  65.             strcpy( opcode, "fstsw" );
  66.             strcpy( operand, "ax" );
  67.         }
  68.         return;
  69.     }
  70.     if ( esc_byte == 0x3D || esc_byte == 0x3E || esc_byte == 0x3F ) {
  71.         return;
  72.     }
  73.     element = esc_byte & 0x0F;
  74.     if (    element == 0x02 || element == 0x03 || element == 0x08
  75.          || element == 0x09 || element == 0x0A || element == 0x0B ) {
  76.         sprintf( operand, "st(%d)", reg );
  77.     } else {
  78.         if ( esc_byte >= 0x10 ) {
  79.             sprintf( operand, "st(%d),st", reg );
  80.         } else {
  81.             sprintf( operand, "st,st(%d)", reg );
  82.         }
  83.     }
  84.     if (    esc_byte == 0x24 || esc_byte == 0x34
  85.          || esc_byte == 0x26 || esc_byte == 0x36 ) {
  86.         element++;
  87.     }
  88.     if (    esc_byte == 0x25 || esc_byte == 0x35
  89.          || esc_byte == 0x27 || esc_byte == 0x37 ) {
  90.         --element;
  91.     }
  92.     if ( esc_byte == 0x09 ) {
  93.         strcpy( opcode, "fxch" );
  94.     } else {
  95.         strcpy( opcode, esc_inst[element] );
  96.     }
  97.     if ( esc_byte >= 0x30 ) {
  98.         strcat( opcode, "p" );
  99.     }
  100. }
  101.  
  102. char *esc_0x0X[] = {
  103.     "fchs"   , "fabs"   ,  ""      , "",            /* [0C:0] - [0C:3] */
  104.     "ftst"   , "fxam"   ,  ""      , "",            /* [0C:4] - [0C:7] */
  105.     "fld1"   , "fldl2t" , "fldl2e" , "fldpi",       /* [0D:0] - [0D:3] */
  106.     "fldlg2" , "fldln2" , "fldz"   , "",            /* [0D:4] - [0D:7] */
  107.     "f2xm1"  , "fyl2x"  , "fptan"  , "fpatan",      /* [0E:0] - [0E:3] */
  108.     "fxtract", "fprem1" , "fdecstp", "fincstp",     /* [0E:4] - [0E:7] */
  109.     "fprem"  , "fyl2xp1", "fsqrt"  , "fsincos",     /* [0F:0] - [0F:3] */
  110.     "frndint", "fscale" , "fsin"   , "fcos"     };  /* [0F:4] - [0F:7] */
  111.  
  112. char *esc_0x1C[] = {
  113.     "fneni"  , "fndisi" , "fnclex" , "fninit",      /* [1C:0] - [1C:3] */
  114.     ""       , ""       , ""       , ""         };  /* [1C:4] - [1C:7] */
  115.