home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sd386v50.zip / sd386src.zip / DAVETOLL.C < prev    next >
Text File  |  1995-04-20  |  139KB  |  3,202 lines

  1. /******************************************************************************\
  2. ***                                                                          ***
  3. ***        COPYRIGHT   I B M   CORPORATION  1983, 1984, 1985                 ***
  4. ***                                   1986, 1987, 1988, 1989                 ***
  5. ***                                                                          ***
  6. ***        LICENSED MATERIAL  -  PROGRAM PROPERTY OF I B M                   ***
  7. ***                                                                          ***
  8. ***        REFER TO COPYRIGHT INSTRUCTIONS: FORM G120-2083                   ***
  9. ***                                                                          ***
  10. ********************************************************************************
  11. *                                                                              *
  12. *                                                                              *
  13. *   MODULE-NAME      = DISASM.C                                                *
  14. *                                                                              *
  15. *   DESCRIPTIVE-NAME = Disassembler for 8086 family processors                 *
  16. *                                                                              *
  17. *   STATUS           = Version 1 Release 1                                     *
  18. *                                                                              *
  19. *   FUNCTION         = to disassemble one instruction into MASM or             *
  20. *                      ASM/86 mnemonics and instruction formats.               *
  21. *                                                                              *
  22. *   Compiler         = IBM C/2 ver 1.1                                         *
  23. *                                                                              *
  24. *   HISTORY          = written in PLS/88 March 1983 by D. C. Toll              *
  25. *                      for use with IWSDEB and CP/88.                          *
  26. *                                                                              *
  27. *                      CP/386 version (for 386 32-bit order code)              *
  28. *                      started July 1987                                       *
  29. *                                                                              *
  30. *                      translated to MetaWare's High C and 387 support added   *
  31. *                      March 1989 by                                           *
  32. *                      D. C. Toll, IBM Research, Yorktown Heights              *
  33. *                                                                              *
  34. *                      IBM C/2 version converted by                            *
  35. *                      Stephen Luk, CASS, Lexington, Ky  (Aug, 1989)           *
  36. *                                                                              *
  37. * ... 02/12/92  521   Srinivas  Port to C-Set/2.                               *
  38. *                                                                              *
  39. *                                                                              *
  40. \******************************************************************************/
  41.  
  42. #if 0
  43. char far * far pascal bcopy(void far *,void far * ,unsigned);/* Joe C.     504*/
  44. #endif
  45.  
  46.                                         /* typedefs for PM convention         */
  47. typedef char           CHAR;
  48. typedef short          SHORT;
  49. typedef long           LONG;
  50. typedef unsigned       BIT;
  51. typedef unsigned char  UCHAR;
  52. typedef unsigned short USHORT;
  53. typedef unsigned long  ULONG;
  54. typedef unsigned int   UINT;            /* this is not a PM convention but to */
  55.                                         /* eliminate compiler warning, use    */
  56.                                         /* USHORT when port to 32 bits        */
  57.  
  58.  
  59.  
  60. typedef struct parlist {                /* the parameter area                 */
  61.   UCHAR  *iptr;                         /* machine code ->                    */
  62.   UCHAR  *hbuffer;                      /* hex output buffer ->               */
  63.   UCHAR  *mbuffer;                      /* mnemonic output buffer ->          */
  64.   UCHAR  *ibuffer;                      /* operand output buffer ->           */
  65.   ULONG  instr_EIP;                     /* EIP value @ this instruction       */
  66.   UINT   flagbits;                      /* flag bits :
  67.                                             bit 2 (1) => MASM format decode
  68.                                                   (0) => ASM/86 format decode
  69.  
  70.                                            NOTE: if the ASM/86 mnemonic table is
  71.                                                  omitted, this bit is ignored.
  72.  
  73.                                             bit 1 (1) => ESC orders are decoded
  74.                                                          287/387 orders
  75.                                                   (0) => decoded as "ESC"
  76.  
  77.                                             bit 0 (1) => do 386 32-bit decode
  78.                                                   (0) => do 16-bit decode     */
  79.   UCHAR  retleng;                       /* length of dis-assembled instr      */
  80.   UCHAR  rettype;                       /* type of returned operand info      */
  81.   UCHAR  retreg;                        /* returned register field            */
  82.   ULONG  retoffset;                     /* returned displacement/offset       */
  83.   USHORT  retseg;                       /* returned segment field             */
  84.   UCHAR  retbase;                       /* returned base register field       */
  85.   UCHAR  retindex;                      /* returned index register field      */
  86.   UCHAR  retscale;                      /* returned scale factor field        */
  87.   UINT   retbits;                       /* returned bit flags:
  88.                                            bit 0 (1) => operand size is 32 bits
  89.                                                  (0) => otherwise 16 bits
  90.                                            bit 1 (1) => address size is 32 bits
  91.                                                  (0) => otherwiseis 16 bits   */
  92.   USHORT  retescape;                    /* ESC instructions opcode            */
  93.   ULONG retimmed;                       /* immediate value if any             */
  94. } PARLIST;
  95.                                         /* bit masks for "flagbits"           */
  96. static UCHAR *disbyte(UCHAR,UCHAR *);                                   /*521*/
  97. static UCHAR *hexbyte(UCHAR,UCHAR *);                                   /*521*/
  98. static UCHAR *hexdword(ULONG,UCHAR *);                                  /*521*/
  99. static UCHAR *hexword(ULONG,UCHAR *);                                   /*521*/
  100. static UCHAR *printitem(ULONG,char *,UCHAR *);                          /*521*/
  101. static void printmnem(USHORT);                                          /*521*/
  102. static void print387m(USHORT);                                          /*521*/
  103. static void prt8reg16(UCHAR);                                           /*521*/
  104. static void prtbyte(void);                                              /*521*/
  105. static void prtdword(void);                                             /*521*/
  106. static void prtovseg(void);                                             /*521*/
  107. static void prtword(void);                                              /*521*/
  108. static void prtimmed(void);                                             /*521*/
  109. static void putpar(void);                                               /*521*/
  110. static void putstr(char *);                                             /*521*/
  111. static void r1(void);                                                   /*521*/
  112. static void setdw(void);                                                /*521*/
  113. static void setrm(void);                                                /*521*/
  114. void DisAsm (PARLIST *);                                                /*521*/
  115.  
  116. #define use32mask   1
  117. #define N387mask    2
  118. #define MASMmask    4
  119.  
  120. static PARLIST *parm = 0;               /* pointer to the parameter block    */
  121.                                         /* values returned in rettype        */
  122. #define  membtype       1
  123. #define  memwtype       2
  124. #define  memwwtype      3
  125. #define  jreltype       4
  126. #define  jnearmemtype   5
  127. #define  jnearregtype   6
  128. #define  jfartype       7
  129. #define  jfarimmtype    8
  130. #define  intntype       9
  131. #define  xlattype       10
  132. #define  retneartype    11
  133. #define  retfartype     12
  134. #define  intrettype     13
  135. #define  illegtype      14
  136. #define  LEAtype        15
  137. #define  escmemtype     16
  138. #define  escapetype     17
  139. #define  BOUNDtype      18
  140. #define  LGDTtype       19
  141. #define  segovtype      20
  142. #define  regimmedtype   21
  143. #define  creltype       22
  144. #define  cnearmemtype   23
  145. #define  cnearregtype   24
  146. #define  cfartype       25
  147. #define  cfarimmtype    26
  148. #define  reptype        27              /*                               1.01 */
  149. #define  strbtype       28              /*                               1.01 */
  150. #define  strwtype       29              /*                               1.01 */
  151.  
  152. #include "masmmnem.c"
  153. #include "a86mnem.c"
  154. #include <string.h>                     /*                                101*/
  155.                                         /*segment register names             */
  156. char segreg[] = {
  157.        2,2,'E','S',
  158.        2,2,'C','S',
  159.        2,2,'S','S',
  160.        2,2,'D','S',
  161.        2,2,'F','S',
  162.        2,2,'G','S',
  163.        0            };
  164.                                         /* 8-bit register names               */
  165. char reg8[] = {
  166.        2,2,'A','L',
  167.        2,2,'C','L',
  168.        2,2,'D','L',
  169.        2,2,'B','L',
  170.        2,2,'A','H',
  171.        2,2,'C','H',
  172.        2,2,'D','H',
  173.        2,2,'B','H',
  174.        0            };
  175.                                         /* 16-bit register names              */
  176. char reg16[] = {
  177.        2,2,'A','X',
  178.        2,2,'C','X',
  179.        2,2,'D','X',
  180.        2,2,'B','X',
  181.        2,2,'S','P',
  182.        2,2,'B','P',
  183.        2,2,'S','I',
  184.        2,2,'D','I',
  185.        0            };
  186.                                         /* 32-bit register names              */
  187. char reg32[] = {
  188.        3,3,'E','A','X',
  189.        3,3,'E','C','X',
  190.        3,3,'E','D','X',
  191.        3,3,'E','B','X',
  192.        3,3,'E','S','P',
  193.        3,3,'E','B','P',
  194.        3,3,'E','S','I',
  195.        3,3,'E','D','I',
  196.        0            };
  197.                                         /* CRn, DRn and TRn register names    */
  198. char specialreg[] = {
  199.        3,3,'C','R','0',
  200.        3,3,'C','R','1',
  201.        3,3,'C','R','2',
  202.        3,3,'C','R','3',
  203.        3,3,'D','R','0',
  204.        3,3,'D','R','1',
  205.        3,3,'D','R','2',
  206.        3,3,'D','R','3',
  207.        3,3,'D','R','4',
  208.        3,3,'D','R','5',
  209.        3,3,'D','R','6',
  210.        3,3,'D','R','7',
  211.        3,3,'T','R','6',
  212.        3,3,'T','R','7',
  213.        0            };
  214.                                         /* instruction buffer format          */
  215. char bytevec[] = "BYTE_";
  216. char wordvec[] = "WORD_";
  217. char dwordvec[] = "DWORD_";
  218.                                         /* vectors to convert 16-bit format
  219.                                            mod-r/m bytes to base and
  220.                                            index register forms               */
  221. UCHAR basereg16[8] = { 4,4,6,6,7,8,6,4 };
  222. UCHAR indexreg16[8] = { 7,8,7,8,0,0,0,0 };
  223.  
  224.                                         /* local variables                    */
  225.  
  226. static UCHAR   *startiptr;              /* instruction stream pointer         */
  227. static UCHAR   *hbuff = 0;              /* hex output buffer pointer          */
  228. static UCHAR   *mbuff = 0;              /* mnemonic output buffer pointer     */
  229. static UCHAR   *ibuff = 0;              /* operand output buffer pointer      */
  230. static UCHAR instr = 0;                 /* holds the current instruction      */
  231. static UCHAR ESCinstr = 0;              /* holds the current 387 instruction  */
  232. static UCHAR ovseg = 0;                 /* non-zero if there is a current
  233.                                            segment override instr pending     */
  234. static UCHAR defseg = 0;                /* default segment for operands       */
  235. static UCHAR wbit = 0;                  /* holds "w" bit from instruction     */
  236. static UCHAR dbit = 0;                  /* holds "d" bit from instruction.
  237.                                            This may take the following values:
  238.                                            0   => register is second operand
  239.                                            2   => register is first operand
  240.                                            244 => BT/BTC/BTR/BTS reg/mem,reg
  241.                                            245 => MOVSX/MOVZX reg,word
  242.                                            246 => MOVSX/MOVZX reg,byte
  243.                                            247 => SHLD/SHRD mem/reg,reg,immed
  244.                                            248 => SHLD/SHRD mem/reg,reg,CL
  245.                                            249 => there is no register or
  246.                                                   second operand
  247.                                            (used for some '0F'X 286 orders)
  248.                                            250 => for a shift n instruction
  249.                                                   - the second
  250.                                                   operand is an 8-bit immediate,
  251.                                                   regardless of the type of the
  252.                                                   first operand.
  253.                                                   This is also used for 0F BA
  254.                                                   instructions, which also
  255.                                                   always have an 8-bit immediate
  256.                                                   operand.
  257.                                            251 => first operand is register
  258.                                                   field, printed as a number
  259.                                                   (used for escape instructions)
  260.                                            252 => second operand is "1" used
  261.                                                   for shift orders
  262.                                            253 => second operand is "CL" used
  263.                                                   for shift orders
  264.                                            254 => only 1 (memory) operand
  265.                                            255 => first operand is mem/reg,
  266.                                                    second is immediate
  267.                                                                               */
  268. static UCHAR  regf = 0;                 /* holds "reg" field from instruction */
  269. static UCHAR  mod = 0;                  /* holds "mod" field from instruction */
  270. static UCHAR  rm = 0;                   /* holds "r/m" field from instruction */
  271. static UCHAR  eee = 0;                  /* holds "eee" field from instruction */
  272. static UCHAR  basereg = 0;              /* index into register names of the
  273.                                            base register, 0 if none           */
  274. static UCHAR  indexreg = 0;             /* index into register names of the
  275.                                            index register, 0 if none          */
  276. static UCHAR  scalefactor = 0;          /* scale factor, possible values are:
  277.                                             0 => none
  278.                                             1 => *2
  279.                                             2 => *4
  280.                                             3 => *8                           */
  281. static ULONG opdisp = 0;                /* operand displacement from instr    */
  282. static long  signeddisp = 0;            /* holds a signed displacement:
  283.                                            if signedflag is set,then this holds
  284.                                            meaningfull contents, and opdisp will
  285.                                            be set to zero when the instruction
  286.                                            displacement is examined           */
  287. static ULONG f1 = 0, f2 = 0;
  288. static UCHAR  ic, *p = 0;
  289. static union {
  290.   ULONG flagbytes;
  291.   struct {
  292.     BIT IODXbit       : 1;              /* if 1, I/O instruction uses DX,
  293.                                            if 0, it has an immediate operand  */
  294.     BIT signextbit    : 1;              /* if 1, we have a sign extended
  295.                                            byte-> word immediate operand (for
  296.                                            opcode @83)                        */
  297.     BIT parflagbit    : 1;              /* if non-zero, we have printed a left
  298.                                            parenthesis                        */
  299.     BIT segrflagbit   : 1;              /* if non-zero, "reg" is actually a
  300.                                            segment register                   */
  301.     BIT segsflagbit   : 1;              /* if set, "prt8reg16" will print a
  302.                                            segment register name, rather than an
  303.                                            ordinary register                  */
  304.     BIT quoteflagbit  : 1;              /* set non-zero if a closing quote
  305.                                            is required after a hex value      */
  306.     BIT disppresbit   : 1;              /* set non-zero if a displacement is
  307.                                            present in this instruction        */
  308.     BIT signedflagbit : 1;              /* if 1, we have a signed displacement*/
  309.     BIT negflagbit    : 1;              /* if 1, the signed displacement is - */
  310.     BIT use32bit      : 1;              /* if set, we are performing 32-bit
  311.                                            decode                             */
  312.     BIT addroverbit   : 1;              /* if set, an address override
  313.                                            prefix has been found              */
  314.     BIT opsizeoverbit : 1;              /* if set, an operand size override
  315.                                            prefix has been found              */
  316.     BIT opsize32bit   : 1;              /* set if operand size is 32-bits
  317.                                            (this is exclusive-OR of use32 and
  318.                                            opsizeover)                        */
  319.     BIT addr32bit     : 1;              /* set if address size is 32-bits
  320.                                            (this is exclusive-OR of use32 and
  321.                                            addrover)                          */
  322.     BIT nocommabit    : 1;              /* if set, prtimmed does not
  323.                                            output a leading comma             */
  324.     BIT sibbase5bit   : 1;              /* set if mod=0 and we have a SIB
  325.                                            byte and the SIB base = 5 (which
  326.                                            implies no base, but there is a
  327.                                            disp32)                            */
  328.   } flgbits;
  329. } flags = { 0 };
  330.                                         /* short hand for the stru above      */
  331.  
  332. #define  IODX        flags.flgbits.IODXbit
  333. #define  signext     flags.flgbits.signextbit
  334. #define  parflag     flags.flgbits.parflagbit
  335. #define  segrflag    flags.flgbits.segrflagbit
  336. #define  segsflag    flags.flgbits.segsflagbit
  337. #define  quoteflag   flags.flgbits.quoteflagbit
  338. #define  disppres    flags.flgbits.disppresbit
  339. #define  signedflag  flags.flgbits.signedflagbit
  340. #define  negflag     flags.flgbits.negflagbit
  341. #define  use32       flags.flgbits.use32bit
  342. #define  addrover    flags.flgbits.addroverbit
  343. #define  opsizeover  flags.flgbits.opsizeoverbit
  344. #define  opsize32    flags.flgbits.opsize32bit
  345. #define  addr32      flags.flgbits.addr32bit
  346. #define  nocomma     flags.flgbits.nocommabit
  347. #define  sibbase5    flags.flgbits.sibbase5bit
  348.  
  349. static struct {
  350.   char *mnemstrptr;                     /* mnemonic table pointer             */
  351.   char *mnem387ptr;                     /* 387 mnemonic table pointer         */
  352.   USHORT *mnemnumptr;                   /* mnemonic number table pointers     */
  353.   USHORT *mnem8081ptr;
  354.   USHORT *mnemAAptr;
  355.   USHORT *mnemC6C7ptr;
  356.   USHORT *mnemF6F7ptr;
  357.   USHORT *mnemFFptr;
  358.   USHORT *shiftmnemptr;
  359.   USHORT *repmnemptr;
  360.   USHORT *mnem0F00ptr;
  361.   USHORT *mnem0F01ptr;
  362.   USHORT *m387memptr;
  363.   USHORT *m387regptr;
  364.   USHORT *mnemD94ptr;
  365.   USHORT *mnemDB4ptr;
  366.   USHORT *mnem0Fptr;
  367.   USHORT *mnem0FBAptr;
  368.   USHORT escmnemval;                    /* index of mnemonic ESCAPE/ESC       */
  369.   USHORT popmnemval;                    /* index of mnemonic POP              */
  370.   USHORT popmnem_16val;                 /* index of mnemonic POP word         */
  371.   USHORT popmnem_32val;                 /* index of mnemonic POP dword        */
  372.   USHORT segovmnemval;                  /* index of mnemonic SEGOV/SEG        */
  373.   USHORT lmnemval;                      /* index of mnemonic L/MOV            */
  374.   USHORT stmnemval;                     /* index of mnemonic ST/MOV           */
  375.   USHORT illegmnemval;                  /* index of mnemonic ???? (illegal)   */
  376.   USHORT timnemval;                     /* index of mnemonic TI/TEST          */
  377.   USHORT tibmnemval;                    /* index of mnemonic TIB/TEST         */
  378.   USHORT tiwmnemval;                    /* index of mnemonic TIW/TEST         */
  379.   USHORT pushmnemval;                   /* index of mnemonic PUSH             */
  380.   USHORT bswapmnemval;                  /* index of mnemonic BSWAP            */
  381.   USHORT fabsmnemval;                   /* index of 387 mnemonic FABS         */
  382.   USHORT fnopmnemval;                   /* index of 387 mnemonic FNOP         */
  383.   USHORT fcomppmnemval;                 /* index of 387 mnemonic FCOMPP       */
  384.   USHORT fucomppmnemval;                /* index of 387 mnemonic FUCOMPP      */
  385.   USHORT fstswmnemval;                  /* index of 387 mnemonic FSTSW        */
  386.   USHORT fillegmnemval;                 /* index of 387 mnemonic ????
  387.                                            (illegal)                          */
  388.   char masmval;                         /* set if we are dis-assembling to MASM,
  389.                                            unset for ASM/286                  */
  390. } z = { 0 };
  391.  
  392.                                         /* short hand for z structure         */
  393. #define  mnemstr     z.mnemstrptr
  394. #define  mnem387     z.mnem387ptr
  395. #define  mnemnum     z.mnemnumptr
  396. #define  mnem8081    z.mnem8081ptr
  397. #define  mnemAA      z.mnemAAptr
  398. #define  mnemC6C7    z.mnemC6C7ptr
  399. #define  mnemF6F7    z.mnemF6F7ptr
  400. #define  mnemFF      z.mnemFFptr
  401. #define  shiftmnem   z.shiftmnemptr
  402. #define  repmnem     z.repmnemptr
  403. #define  mnem0F00    z.mnem0F00ptr
  404. #define  mnem0F01    z.mnem0F01ptr
  405. #define  m387mem     z.m387memptr
  406. #define  m387reg     z.m387regptr
  407. #define  mnemD94     z.mnemD94ptr
  408. #define  mnemDB4     z.mnemDB4ptr
  409. #define  mnem0F      z.mnem0Fptr
  410. #define  mnem0FBA    z.mnem0FBAptr
  411. #define  escmnem     z.escmnemval
  412. #define  popmnem     z.popmnemval
  413. #define  popmnem_16  z.popmnem_16val
  414. #define  popmnem_32  z.popmnem_32val
  415. #define  segovmnem   z.segovmnemval
  416. #define  lmnem       z.lmnemval
  417. #define  movmnem     z.lmnemval
  418. #define  stmnem      z.stmnemval
  419. #define  illegmnem   z.illegmnemval
  420. #define  timnem      z.timnemval
  421. #define  testmnem    z.timnemval
  422. #define  tibmnem     z.tibmnemval
  423. #define  tiwmnem     z.tiwmnemval
  424. #define  pushmnem    z.pushmnemval
  425. #define  bswapmnem   z.bswapmnemval
  426. #define  fabsmnem    z.fabsmnemval
  427. #define  fnopmnem    z.fnopmnemval
  428. #define  fcomppmnem  z.fcomppmnemval
  429. #define  fucomppmnem z.fucomppmnemval
  430. #define  fstswmnem   z.fstswmnemval
  431. #define  fillegmnem  z.fillegmnemval
  432. #define  masm        z.masmval
  433.  
  434. /******************************************************************************/
  435. /****************************** disbyte ***************************************/
  436. /******************************************************************************/
  437. /*                                                                            */
  438. /*  DESCRIPTION:                                                              */
  439. /*              print the specified byte in hex, in the supplied buffer.      */
  440. /*              If the first digit is 0, it is suppressed .                   */
  441. /*                                                                            */
  442. /*  PARAMETERS:                                                               */
  443. /*              byte            Input:  current byte at instr stream          */
  444. /*              *buff           Input:  buffer -> to hold the output          */
  445. /*                                                                            */
  446. /*  RETURNS:                                                                  */
  447. /*              buffer ->       next position at the buffer                   */
  448. /*                                                                            */
  449. /*  GLOBAL DATA:                                                              */
  450. /*              none                                                          */
  451. /*                                                                            */
  452. /******************************************************************************/
  453. static UCHAR *disbyte(UCHAR byte, UCHAR *buff)
  454. {
  455.   *buff = (UCHAR)(((byte >> 4) & 0x0F) + '0');
  456.   if (*buff != 0x30)
  457.     {
  458.       if (*buff > 0x39) *buff += 7;
  459.       buff++;
  460.     }
  461.   *buff = (UCHAR)((byte & 0x0F) + '0');
  462.   if (*buff > 0x39)
  463.     *buff += 7;
  464.   buff++;
  465.   return(buff);
  466. }
  467. /******************************************************************************/
  468. /****************************** hexbyte ***************************************/
  469. /******************************************************************************/
  470. /*                                                                            */
  471. /*  DESCRIPTION:                                                              */
  472. /*              print the specified byte in hex, in the supplied buffer.      */
  473. /*                                                                            */
  474. /*  PARAMETERS:                                                               */
  475. /*              byte            Input:  current byte at instr stream          */
  476. /*              *buff           Input:  buffer -> to hold the output          */
  477. /*                                                                            */
  478. /*  RETURNS:                                                                  */
  479. /*              buffer ->       next position at the buffer                   */
  480. /*                                                                            */
  481. /*  GLOBAL DATA:                                                              */
  482. /*              none                                                          */
  483. /*                                                                            */
  484. /******************************************************************************/
  485. static UCHAR *hexbyte(UCHAR byte, UCHAR *buff)
  486. {
  487.   UCHAR c;
  488.   c = (UCHAR)(((byte >> 4) & 0x0F) + '0');
  489.   if (c > 0x39)
  490.     {
  491.       c += 7;
  492.       #if defined(_ASM86_)
  493.       if (masm)
  494.         {
  495.       #endif
  496.                                         /*  for the MASM case, add a leading 0
  497.                                         if the number starts with a letter    */
  498.       *buff++ = '0';
  499.       #if defined(_ASM86_)
  500.         }
  501.       #endif
  502.     }
  503.   *buff++ = c;
  504.   *buff = (UCHAR)((byte & 0x0F) + '0');
  505.   if (*buff > 0x39)
  506.     *buff += 7;
  507.   buff++;
  508.   return(buff);
  509. }
  510. /******************************************************************************/
  511. /****************************** hexdword **************************************/
  512. /******************************************************************************/
  513. /*                                                                            */
  514. /*  DESCRIPTION:                                                              */
  515. /*              print the specified dword in hex, in the supplied buffer.     */
  516. /*                                                                            */
  517. /*  PARAMETERS:                                                               */
  518. /*              val             Input:  current dword at instr stream         */
  519. /*              *buff           Input:  buffer -> to hold the output          */
  520. /*                                                                            */
  521. /*  RETURNS:                                                                  */
  522. /*              buffer ->       next position at the buffer                   */
  523. /*                                                                            */
  524. /*  GLOBAL DATA:                                                              */
  525. /*              none                                                          */
  526. /*                                                                            */
  527. /******************************************************************************/
  528. static UCHAR *hexdword(ULONG val, UCHAR *buff)
  529. {
  530.   ULONG hi;
  531.   UCHAR c, d;
  532.   hi = 4;
  533.   while (hi > 0)
  534.     {
  535.       hi--;
  536.       d = (UCHAR)((val >> (hi * 8)) & 0xFF);
  537.       c = (UCHAR)(((d >> 4) & 0x0F) + '0');
  538.       if (c > 0x39)
  539.          {
  540.            c += 7;
  541.            #if defined(_ASM86_)
  542.            if (masm)
  543.               {
  544.            #endif
  545.                                         /* for the MASM case, add a leading 0
  546.                                         if the number starts with a letter    */
  547.            if (hi == 3)
  548.              *buff++ = '0';
  549.            #if defined(_ASM86_)
  550.               }
  551.            #endif
  552.          }
  553.       *buff++ = c;
  554.       *buff = (UCHAR)((d & 0x0F) + '0');
  555.       if (*buff > 0x39)
  556.         *buff += 7;
  557.       buff++;
  558.     }
  559.   return(buff);
  560. }
  561. /******************************************************************************/
  562. /****************************** hexword ***************************************/
  563. /******************************************************************************/
  564. /*                                                                            */
  565. /*  DESCRIPTION:                                                              */
  566. /*              print the specified word in hex, in the supplied buffer.      */
  567. /*                                                                            */
  568. /*  PARAMETERS:                                                               */
  569. /*              val             Input:  current dword at instr stream         */
  570. /*              *buff           Input:  buffer -> to hold the output          */
  571. /*                                                                            */
  572. /*  RETURNS:                                                                  */
  573. /*              buffer ->       next position at the buffer                   */
  574. /*                                                                            */
  575. /*  GLOBAL DATA:                                                              */
  576. /*              none                                                          */
  577. /*                                                                            */
  578. /******************************************************************************/
  579. static UCHAR *hexword(ULONG val, UCHAR *buff)
  580. {
  581.   ULONG hi;
  582.   UCHAR c, d;
  583.   hi = 2;
  584.   while (hi > 0)
  585.     {
  586.       hi--;
  587.       d = (UCHAR)((val >> (hi * 8)) & 0xFF);
  588.       c = (UCHAR)(((d >> 4) & 0x0F) + '0');
  589.       if (c > 0x39)
  590.         {
  591.           c += 7;
  592.           #if defined(_ASM86_)
  593.           if (masm)
  594.             {
  595.           #endif
  596.                                         /* for the MASM case, add a leading 0
  597.                                         if the number starts with a letter    */
  598.           if (hi == 1)
  599.             *buff++ = '0';
  600.           #if defined(_ASM86_)
  601.             }
  602.           #endif
  603.         }
  604.       *buff++ = c;
  605.       *buff = (UCHAR)((d & 0x0F) + '0');
  606.       if (*buff > 0x39)
  607.         *buff += 7;
  608.       buff++;
  609.     }
  610.   return(buff);
  611. }
  612. /******************************************************************************/
  613. /****************************** printitem *************************************/
  614. /******************************************************************************/
  615. /*                                                                            */
  616. /*  DESCRIPTION:                                                              */
  617. /*              print the specified item from the table pointed by ptr        */
  618. /*              item starts with index 0                                      */
  619. /*                                                                            */
  620. /*  PARAMETERS:                                                               */
  621. /*              item            Input:  the item_th object in the table       */
  622. /*              *ptr            Input:  the table pointer                     */
  623. /*              *buff           Input:  output buffer pointer                 */
  624. /*                                                                            */
  625. /*  RETURNS:                                                                  */
  626. /*              buffer ->       next position at the buffer                   */
  627. /*                                                                            */
  628. /*  GLOBAL DATA:                                                              */
  629. /*              none                                                          */
  630. /*                                                                            */
  631. /******************************************************************************/
  632. static UCHAR *printitem(ULONG item, char *ptr, UCHAR *buff)
  633. {
  634.   ULONG leng;
  635.   while (item != 0)
  636.     {
  637.       ptr += (*ptr + 2);
  638.       item--;
  639.     }
  640.   leng = *ptr++;
  641.   ptr++;
  642.   while (leng-- != 0)
  643.     *buff++ = *ptr++;
  644.   return(buff);
  645. }
  646. /******************************************************************************/
  647. /****************************** printmnem *************************************/
  648. /******************************************************************************/
  649. /*                                                                            */
  650. /*  DESCRIPTION:                                                              */
  651. /*              prints a mnemonic - due to relic from the PLS version of this */
  652. /*              code, the mnemonic numbers in the tables count from 1, not 0. */
  653. /*              This routine corrects for this, rather than changing all the  */
  654. /*              tables (which would be no small task)                         */
  655. /*                                                                            */
  656. /*  PARAMETERS:                                                               */
  657. /*              mnem_num        Input:  the desired object in the table       */
  658. /*                                                                            */
  659. /*  RETURNS:                                                                  */
  660. /*              none                                                          */
  661. /*                                                                            */
  662. /*  GLOBAL DATA:                                                              */
  663. /*              none                                                          */
  664. /*                                                                            */
  665. /******************************************************************************/
  666. static void printmnem(USHORT mnem_num)
  667. {
  668.   mbuff = printitem((ULONG)mnem_num-1, mnemstr, mbuff);
  669.   return;
  670. }
  671. /******************************************************************************/
  672. /****************************** print387m *************************************/
  673. /******************************************************************************/
  674. /*                                                                            */
  675. /*  DESCRIPTION:                                                              */
  676. /*              prints a 387 mnem - due to relic from the PLS version of this */
  677. /*              code, the mnemonic numbers in the tables count from 1, not 0. */
  678. /*              This routine corrects for this, rather than changing all the  */
  679. /*              tables (which would be no small task)                         */
  680. /*                                                                            */
  681. /*  PARAMETERS:                                                               */
  682. /*              mnem_num        Input:  the desired object in the table       */
  683. /*                                                                            */
  684. /*  RETURNS:                                                                  */
  685. /*              none                                                          */
  686. /*                                                                            */
  687. /*  GLOBAL DATA:                                                              */
  688. /*              none                                                          */
  689. /*                                                                            */
  690. /******************************************************************************/
  691. static void print387m(USHORT mnem_num)
  692. {
  693.   mbuff = printitem((ULONG)mnem_num-1, mnem387, mbuff);
  694.   return;
  695. }
  696. /******************************************************************************/
  697. /****************************** prt8reg16 *************************************/
  698. /******************************************************************************/
  699. /*                                                                            */
  700. /*  DESCRIPTION:                                                              */
  701. /*              prints an 8, 16 or 32 bit register name, according to wbit    */
  702. /*              and the current mode                                          */
  703. /*                                                                            */
  704. /*  PARAMETERS:                                                               */
  705. /*              regnum          Input:  register number                       */
  706. /*                                                                            */
  707. /*  RETURNS:                                                                  */
  708. /*              none                                                          */
  709. /*                                                                            */
  710. /*  GLOBAL DATA:                                                              */
  711. /*              none                                                          */
  712. /*                                                                            */
  713. /******************************************************************************/
  714. static void prt8reg16(UCHAR regnum)
  715. {
  716.   if (segsflag)
  717.     {
  718.                                         /* register is really a segment
  719.                                            register                           */
  720.       ibuff = printitem((ULONG)regnum,segreg,ibuff);
  721.       segsflag = 0;
  722.     }
  723.   else
  724.     {
  725.                                         /* it is an ordinary register         */
  726.       if (!wbit)
  727.         {
  728.           ibuff = printitem((ULONG)regnum,reg8,ibuff);
  729.         }
  730.       else
  731.         {
  732.           if (opsize32)
  733.             ibuff = printitem((ULONG)regnum,reg32,ibuff);
  734.           else
  735.             ibuff = printitem((ULONG)regnum,reg16,ibuff);
  736.         }
  737.     }
  738.   return;
  739. }
  740. /******************************************************************************/
  741. /****************************** prtbyte ***************************************/
  742. /******************************************************************************/
  743. /*                                                                            */
  744. /*  DESCRIPTION:                                                              */
  745. /*              set ic to next byte of the instruction, and print it in hex   */
  746. /*                                                                            */
  747. /*  PARAMETERS:                                                               */
  748. /*              none                                                          */
  749. /*                                                                            */
  750. /*  RETURNS:                                                                  */
  751. /*              none                                                          */
  752. /*                                                                            */
  753. /*  GLOBAL DATA:                                                              */
  754. /*              ic, hbuff                                                     */
  755. /*                                                                            */
  756. /******************************************************************************/
  757. static void prtbyte()
  758. {
  759.   ic = *(parm->iptr)++;
  760.   if (hbuff)
  761.     {
  762.       *hbuff = (UCHAR)(((ic >> 4) & 0x0F) + '0');
  763.       if (*hbuff > 0x39)
  764.         *hbuff += 7;
  765.       hbuff++;
  766.       *hbuff = (UCHAR)((ic & 0x0F) + '0');
  767.       if (*hbuff > 0x39)
  768.         *hbuff += 7;
  769.       hbuff++;
  770.     }
  771.   return;
  772. }
  773. /******************************************************************************/
  774. /****************************** prtdword **************************************/
  775. /******************************************************************************/
  776. /*                                                                            */
  777. /*  DESCRIPTION:                                                              */
  778. /*              set f1 to next dwoed of the instruction, and print it in hex  */
  779. /*                                                                            */
  780. /*  PARAMETERS:                                                               */
  781. /*              none                                                          */
  782. /*                                                                            */
  783. /*  RETURNS:                                                                  */
  784. /*              none                                                          */
  785. /*                                                                            */
  786. /*  GLOBAL DATA:                                                              */
  787. /*              hbuff                                                         */
  788. /*                                                                            */
  789. /******************************************************************************/
  790. static void prtdword()
  791. {
  792.   ULONG hi, val;
  793.   UCHAR c;
  794.   f1 = *(parm->iptr)++;
  795.   f1 |= (*(parm->iptr)++ << 8);         /* note - the bytes are reversed!     */
  796.   f1 |= (*(parm->iptr)++ << 16);        /* note - the bytes are reversed!     */
  797.   f1 |= (*(parm->iptr)++ << 24);        /* note - the bytes are reversed!     */
  798.   if (hbuff)
  799.     {
  800.                                         /* Print the instruction word in hex,
  801.                                            byte reversed                      */
  802.       hi = 0;
  803.       val = f1;
  804.       while (hi < 4)
  805.         {
  806.           c = (UCHAR)((val >> (hi * 8)) & 0xFF);
  807.           *hbuff = (UCHAR)(((c >> 4) & 0x0F) + '0');
  808.           if (*hbuff > 0x39)
  809.             *hbuff += 7;
  810.           hbuff++;
  811.           *hbuff = (UCHAR)((c & 0x0F) + '0');
  812.           if (*hbuff > 0x39)
  813.             *hbuff += 7;
  814.           hbuff++;
  815.           hi++;
  816.         }
  817.     }
  818.   return;
  819. }
  820. /******************************************************************************/
  821. /****************************** prtovseg **************************************/
  822. /******************************************************************************/
  823. /*                                                                            */
  824. /*  DESCRIPTION:                                                              */
  825. /*              prints the override segment name, if it is set up             */
  826. /*                                                                            */
  827. /*  PARAMETERS:                                                               */
  828. /*              none                                                          */
  829. /*                                                                            */
  830. /*  RETURNS:                                                                  */
  831. /*              none                                                          */
  832. /*                                                                            */
  833. /*  GLOBAL DATA:                                                              */
  834. /*              ibuff                                                         */
  835. /*                                                                            */
  836. /******************************************************************************/
  837. static void prtovseg()
  838. {
  839.   if (ovseg)
  840.     {
  841.       ibuff = printitem((ULONG)ovseg-1, segreg, ibuff);
  842.     }
  843.   return;
  844. }
  845. /******************************************************************************/
  846. /****************************** prtword ***************************************/
  847. /******************************************************************************/
  848. /*                                                                            */
  849. /*  DESCRIPTION:                                                              */
  850. /*              set f1 to next word of the instr, and print it in hex         */
  851. /*                                                                            */
  852. /*  PARAMETERS:                                                               */
  853. /*              none                                                          */
  854. /*                                                                            */
  855. /*  RETURNS:                                                                  */
  856. /*              none                                                          */
  857. /*                                                                            */
  858. /*  GLOBAL DATA:                                                              */
  859. /*              hbuff                                                         */
  860. /*                                                                            */
  861. /******************************************************************************/
  862. static void prtword()
  863. {
  864.   ULONG hi, val;
  865.   UCHAR c;
  866.   f1 = *(parm->iptr)++;
  867.   f1 |= (*(parm->iptr)++ << 8);         /* note - the bytes are reversed!     */
  868.   if (hbuff)
  869.     {
  870.       hi = 0;
  871.       val = f1;
  872.       while (hi < 2)
  873.         {
  874.           c = (UCHAR)((val >> (hi * 8)) & 0xFF);
  875.           *hbuff = (UCHAR)(((c >> 4) & 0x0F) + '0');
  876.           if (*hbuff > 0x39)
  877.             *hbuff += 7;
  878.           hbuff++;
  879.           *hbuff = (UCHAR)((c & 0x0F) + '0');
  880.           if (*hbuff > 0x39)
  881.             *hbuff += 7;
  882.           hbuff++;
  883.           hi++;
  884.         }
  885.     }
  886.   return;
  887. }
  888. /******************************************************************************/
  889. /****************************** prtimmed **************************************/
  890. /******************************************************************************/
  891. /*                                                                            */
  892. /*  DESCRIPTION:                                                              */
  893. /*              to print the immediate operand to ibuff                       */
  894. /*                                                                            */
  895. /*  PARAMETERS:                                                               */
  896. /*              none                                                          */
  897. /*                                                                            */
  898. /*  RETURNS:                                                                  */
  899. /*              none                                                          */
  900. /*                                                                            */
  901. /*  GLOBAL DATA:                                                              */
  902. /*              ibuff                                                         */
  903. /*                                                                            */
  904. /******************************************************************************/
  905. static void prtimmed()
  906. {
  907.   if (!nocomma)
  908.     *ibuff++ = ',';
  909.   #if defined(_ASM86_)
  910.   if (!masm)
  911.     {
  912.       *ibuff++ = 'X';
  913.       *ibuff++ = '\'';
  914.     }
  915.   #endif
  916.   if (wbit == 0)
  917.     {
  918.                                         /* a byte operand                     */
  919.       prtbyte();
  920.       ibuff = hexbyte(ic,ibuff);
  921.     }
  922.   else
  923.     {
  924.                                         /* a word or double word operand      */
  925.       if (opsize32)
  926.         {
  927.                                         /* it is a double word instruction    */
  928.           if (signext)
  929.             {
  930.                                         /* sign extend the (byte) operand     */
  931.               prtbyte();
  932.               f1 = (signed long) ((signed char) ic);
  933.             }
  934.           else
  935.             prtdword();
  936.           ibuff = hexdword(f1,ibuff);
  937.         }
  938.       else
  939.         {
  940.           if (signext)
  941.             {
  942.                                         /* sign extend the (byte) operand     */
  943.               prtbyte();
  944.               f1 = (signed long) ((signed char) ic);
  945.             }
  946.           else
  947.             prtword();
  948.           ibuff = hexword(f1,ibuff);
  949.         }
  950.     }
  951.   #if defined(_ASM86_)
  952.   if (masm)
  953.   #endif
  954.     *ibuff++ = 'H';
  955.   #if defined(_ASM86_)
  956.   else
  957.     *ibuff++ = '\'';
  958.   #endif
  959.   return;
  960. }
  961. /******************************************************************************/
  962. /****************************** putpar ****************************************/
  963. /******************************************************************************/
  964. /*                                                                            */
  965. /*  DESCRIPTION:                                                              */
  966. /*              outputs a left parenthesis (ASM/286) or left backet (MASM),   */
  967. /*              and sets the flag, unless the flag is already set, in which   */
  968. /*              case it outputs a comma (ASM/286) or plus (MASM)              */
  969. /*                                                                            */
  970. /*  PARAMETERS:                                                               */
  971. /*              none                                                          */
  972. /*                                                                            */
  973. /*  RETURNS:                                                                  */
  974. /*              none                                                          */
  975. /*                                                                            */
  976. /*  GLOBAL DATA:                                                              */
  977. /*              ibuff                                                         */
  978. /*                                                                            */
  979. /******************************************************************************/
  980. static void putpar()
  981. {
  982.   if (parflag == 0)
  983.     {
  984.                                         /* no parenthesis so far              */
  985.       parflag = 1;
  986.       #if defined(_ASM86_)
  987.       if (masm)
  988.       #endif
  989.         *ibuff++ = '[';
  990.       #if defined(_ASM86_)
  991.       else
  992.         *ibuff++ = '(';
  993.       #endif
  994.     }
  995.   else
  996.     {
  997.                                         /* we have a parenthesis - output a
  998.                                            comma                              */
  999.       #if defined(_ASM86_)
  1000.       if (masm)
  1001.       #endif
  1002.         *ibuff++ = '+';
  1003.       #if defined(_ASM86_)
  1004.       else
  1005.         *ibuff++ = ',';
  1006.       #endif
  1007.     }
  1008.   return;
  1009. }
  1010. /******************************************************************************/
  1011. /****************************** putpar ****************************************/
  1012. /******************************************************************************/
  1013. /*                                                                            */
  1014. /*  DESCRIPTION:                                                              */
  1015. /*              print the specified string                                    */
  1016. /*                                                                            */
  1017. /*  PARAMETERS:                                                               */
  1018. /*              *str            Input:  string ->                             */
  1019. /*                                                                            */
  1020. /*  RETURNS:                                                                  */
  1021. /*              none                                                          */
  1022. /*                                                                            */
  1023. /*  GLOBAL DATA:                                                              */
  1024. /*              ibuff                                                         */
  1025. /*                                                                            */
  1026. /******************************************************************************/
  1027. static void putstr(char *str)
  1028. {
  1029.   while (*str != 0)
  1030.     *ibuff++ = *str++;
  1031.   return;
  1032. }
  1033. /******************************************************************************/
  1034. /****************************** r1 ********************************************/
  1035. /******************************************************************************/
  1036. /*                                                                            */
  1037. /*  DESCRIPTION:                                                              */
  1038. /*              init all parameters and assign buffer for output              */
  1039. /*                                                                            */
  1040. /*  PARAMETERS:                                                               */
  1041. /*              none                                                          */
  1042. /*                                                                            */
  1043. /*  RETURNS:                                                                  */
  1044. /*              none                                                          */
  1045. /*                                                                            */
  1046. /*  GLOBAL DATA:                                                              */
  1047. /*              hbuff, ibuff, mbuff, parm's                                   */
  1048. /*                                                                            */
  1049. /******************************************************************************/
  1050. static void r1()
  1051. {
  1052.   hbuff = parm->hbuffer;
  1053.   ibuff = parm->ibuffer;
  1054.   mbuff = parm->mbuffer;
  1055.   dbit = 0;
  1056.   parm->retbits = 0;
  1057.   parm->rettype = 0;
  1058.   parm->retreg = 0;
  1059.   parm->retseg = 0;
  1060.   parm->retoffset = 0;
  1061.   parm->retscale = 0;
  1062.   parm->retbase = 255;
  1063.   parm->retindex = 255;
  1064.   return;
  1065. }
  1066. /******************************************************************************/
  1067. /****************************** setdw *****************************************/
  1068. /******************************************************************************/
  1069. /*                                                                            */
  1070. /*  DESCRIPTION:                                                              */
  1071. /*              set the 'd' and 'w' bits from the instruction                 */
  1072. /*                                                                            */
  1073. /*  PARAMETERS:                                                               */
  1074. /*              none                                                          */
  1075. /*                                                                            */
  1076. /*  RETURNS:                                                                  */
  1077. /*              none                                                          */
  1078. /*                                                                            */
  1079. /*  GLOBAL DATA:                                                              */
  1080. /*                                                                            */
  1081. /*                                                                            */
  1082. /******************************************************************************/
  1083. static void setdw()
  1084. {
  1085.   wbit = (UCHAR)(instr & 1);            /* set 8/16/32 bit marker:
  1086.                                            0 => 8 bit, 1 => 16 or 32 bit      */
  1087.   dbit = (UCHAR)(instr & 2);            /* set direction bit:
  1088.                                                2 => mem -> regf
  1089.                                                0 => regf -> mem               */
  1090.   return;
  1091. }
  1092. /******************************************************************************/
  1093. /****************************** setrm *****************************************/
  1094. /******************************************************************************/
  1095. /*                                                                            */
  1096. /*  DESCRIPTION:                                                              */
  1097. /*              set trm-regf-mod from byte after instruction                  */
  1098. /*                                                                            */
  1099. /*  PARAMETERS:                                                               */
  1100. /*              none                                                          */
  1101. /*                                                                            */
  1102. /*  RETURNS:                                                                  */
  1103. /*              none                                                          */
  1104. /*                                                                            */
  1105. /*  GLOBAL DATA:                                                              */
  1106. /*                                                                            */
  1107. /*                                                                            */
  1108. /******************************************************************************/
  1109. static void setrm()
  1110. {
  1111.   prtbyte();
  1112.   rm = (UCHAR)(ic & 0x07);
  1113.   regf = (UCHAR)((UCHAR)(ic & 0x038) >> 3);    /* added uchar cast inside  521*/
  1114.   mod = (UCHAR)((UCHAR)(ic & 0xC0) >> 6);      /* added uchar cast inside  521*/
  1115.   sibbase5 = 0;
  1116.   if (addr32)
  1117.     {
  1118.                                         /* interpret this as a 32-bit instr   */
  1119.       if (mod != 3)
  1120.         basereg = (UCHAR)(rm + 1);
  1121.       indexreg = 0;
  1122.       scalefactor = 0;
  1123.       if (mod == 0 && rm == 5)
  1124.         basereg = 0;
  1125.       if (mod != 3 && rm == 4)
  1126.         {
  1127.                                         /* we have a SIB byte                 */
  1128.           prtbyte();
  1129.           basereg = (UCHAR)((ic & 0x07) + 1);
  1130.           indexreg = (UCHAR)(((UCHAR)(ic & 0x38) >> 3) + 1);             /*521*/
  1131.           scalefactor = (UCHAR)((UCHAR)(ic & 0xC0) >> 6);                /*521*/
  1132.           if (indexreg == 5)
  1133.             {
  1134.                                         /* index=4 -> no index                */
  1135.               indexreg = 0;
  1136.               scalefactor = 0;
  1137.             }
  1138.           if (mod == 0 && basereg == 6)
  1139.             {
  1140.                                         /* a special case, no base            */
  1141.               basereg = 0;
  1142.               sibbase5 = 1;             /* remember what we have done         */
  1143.             }
  1144.         }
  1145.         if (basereg == 6 ||             /* EBP                                */
  1146.           basereg == 5  )               /* ESP                                */
  1147.         defseg = 3;                     /* SS                                 */
  1148.     }
  1149.   else
  1150.     {
  1151.                                         /* interpret this as a 16-bit instr   */
  1152.        basereg = basereg16[rm];
  1153.        indexreg = indexreg16[rm];
  1154.        if (mod == 0 && rm == 6)
  1155.          basereg = 0;
  1156.        if (basereg == 6)                /* BP                                 */
  1157.          defseg = 3;                    /* SS                                 */
  1158.        scalefactor = 0;
  1159.     }
  1160.   return;
  1161. }
  1162. /******************************************************************************/
  1163. /****************************** DisAsm ****************************************/
  1164. /******************************************************************************/
  1165. /*                                                                            */
  1166. /*  DESCRIPTION:                                                              */
  1167. /*              main routine                                                  */
  1168. /*                                                                            */
  1169. /*  PARAMETERS:                                                               */
  1170. /*              parmptr              Input:  interface pointer                */
  1171. /*                                                                            */
  1172. /*  RETURNS:                                                                  */
  1173. /*              none                                                          */
  1174. /*                                                                            */
  1175. /*  GLOBAL DATA:                                                              */
  1176. /*                                                                            */
  1177. /*                                                                            */
  1178. /******************************************************************************/
  1179.  
  1180.  
  1181. void DisAsm (PARLIST * parmptr)         /* removed pascal                 521*/
  1182. {
  1183.   parm = parmptr;
  1184.   startiptr = parm->iptr;
  1185.   ovseg = 0;
  1186.   defseg = 4;                           /* DS                                 */
  1187.   flags.flagbytes = 0;
  1188.   if (parm->flagbits & use32mask)
  1189.     use32 = 1;                          /* 32-bit dis-assembly mode           */
  1190.   r1();
  1191.  
  1192.   restart:                              /* return to here if we find a segment
  1193.                                            override                           */
  1194.   parm->retbits = 0;
  1195.   opsize32 = use32 ^ opsizeover;
  1196.   if (opsize32)
  1197.     parm->retbits |= 1;
  1198.   addr32 = use32 ^ addrover;
  1199.   if (addr32)
  1200.     parm->retbits |= 2;
  1201.   #if defined(_ASM86_)
  1202.     if ((parm->flagbits & MASMmask) == 0)
  1203.       {
  1204.                                         /* ASM/86 decode                      */
  1205.       if (opsize32)
  1206.         p = (UCHAR *)&ASM286_32;
  1207.       else
  1208.         p = (UCHAR *)&ASM286_16;
  1209.       goto restart_1;
  1210.       }
  1211.   #endif
  1212.                                         /* use MASM                           */
  1213.   if (opsize32)
  1214.     p = (UCHAR *)&MASM_32;
  1215.   else
  1216.     p = (UCHAR *)&MASM_16;
  1217.  
  1218.   restart_1:
  1219.  
  1220. /*bcopy( p, &z, sizeof(z)); */          /* added by Joe C.                 504*/
  1221.   memcpy(&z, p, sizeof(z));             /* added by Joe C.                 504*/
  1222.   prtbyte();                            /* get next byte of instruction       */
  1223.   instr = ic;
  1224.                                         /* in many cases we can print the
  1225.                                            instruction mnemonic now           */
  1226.   if (mnemnum[instr] != odd)
  1227.       printmnem(mnemnum[instr]);
  1228.                                         /* jump according to the instruction
  1229.                                            opcode                             */
  1230.   switch (instr)
  1231.     {
  1232.       case   0:
  1233.       case   1:
  1234.       case   2:
  1235.       case   3:  goto memop;            /* 00 - 03                            */
  1236.       case   4:
  1237.       case   5:  goto aregimop;         /* 04, 05                             */
  1238.       case   6:
  1239.       case   7:  goto segop;            /* 06, 07                             */
  1240.       case   8:
  1241.       case   9:
  1242.       case  10:
  1243.       case  11:  goto memop;            /* 08 - 0B                            */
  1244.       case  12:
  1245.       case  13:  goto aregimop;         /* 0C, 0D                             */
  1246.       case  14:  goto segop;            /* 0E                                 */
  1247.       case  15:  goto zerofop;          /* 0F                                 */
  1248.       case  16:
  1249.       case  17:
  1250.       case  18:
  1251.       case  19:  goto memop;            /* 10 - 13                            */
  1252.       case  20:
  1253.       case  21:  goto aregimop;         /* 14, 15                             */
  1254.       case  22:
  1255.       case  23:  goto segop;            /* 16, 17                             */
  1256.       case  24:
  1257.       case  25:
  1258.       case  26:
  1259.       case  27:  goto memop;            /* 18 - 1B                            */
  1260.       case  28:
  1261.       case  29:  goto aregimop;         /* 1C, 1D                             */
  1262.       case  30:
  1263.       case  31:  goto segop;            /* 1E, 1F                             */
  1264.       case  32:
  1265.       case  33:
  1266.       case  34:
  1267.       case  35:  goto memop;            /* 20 - 23                            */
  1268.       case  36:
  1269.       case  37:  goto aregimop;         /* 24, 25                             */
  1270.       case  38:  goto segovop;          /* 26                                 */
  1271.       case  39:  goto nulop;            /* 27                                 */
  1272.       case  40:
  1273.       case  41:
  1274.       case  42:
  1275.       case  43:  goto memop;            /* 28 - 2B                            */
  1276.       case  44:
  1277.       case  45:  goto aregimop;         /* 2C, 2D                             */
  1278.       case  46:  goto segovop;          /* 2E                                 */
  1279.       case  47:  goto nulop;            /* 2F                                 */
  1280.       case  48:
  1281.       case  49:
  1282.       case  50:
  1283.       case  51:  goto memop;            /* 30 - 33                            */
  1284.       case  52:
  1285.       case  53:  goto aregimop;         /* 34, 35                             */
  1286.       case  54:  goto segovop;          /* 36                                 */
  1287.       case  55:  goto nulop;            /* 37                                 */
  1288.       case  56:
  1289.       case  57:
  1290.       case  58:
  1291.       case  59:  goto memop;            /* 38 - 3B                            */
  1292.       case  60:
  1293.       case  61:  goto aregimop;         /* 3C, 3D                             */
  1294.       case  62:  goto segovop;          /* 3E                                 */
  1295.       case  63:  goto nulop;            /* 3F                                 */
  1296.       case  64:
  1297.       case  65:
  1298.       case  66:
  1299.       case  67:
  1300.       case  68:
  1301.       case  69:
  1302.       case  70:
  1303.       case  71:
  1304.       case  72:
  1305.       case  73:
  1306.       case  74:
  1307.       case  75:
  1308.       case  76:
  1309.       case  77:
  1310.       case  78:
  1311.       case  79:
  1312.       case  80:
  1313.       case  81:
  1314.       case  82:
  1315.       case  83:
  1316.       case  84:
  1317.       case  85:
  1318.       case  86:
  1319.       case  87:
  1320.       case  88:
  1321.       case  89:
  1322.       case  90:
  1323.       case  91:
  1324.       case  92:
  1325.       case  93:
  1326.       case  94:
  1327.       case  95:  goto reg16op;          /* 40 - 5F                            */
  1328.       case  96:
  1329.       case  97:  goto nulop;            /* 60, 61                             */
  1330.       case  98:  goto boundop;          /* 62                                 */
  1331.       case  99:  goto ARPLop;           /* 63                                 */
  1332.       case 100:
  1333.       case 101:  goto segovfsgs;        /* 64, 65                             */
  1334.       case 102:  goto overoper;         /* 66                                 */
  1335.       case 103:  goto overaddr;         /* 67                                 */
  1336.       case 104:  goto pushiop;          /* 68                                 */
  1337.       case 105:  goto MSIop;            /* 69                                 */
  1338.       case 106:  goto pushiop2;         /* 6A                                 */
  1339.       case 107:  goto MSIop2;           /* 6B                                 */
  1340.       case 108:
  1341.       case 109:
  1342.       case 110:
  1343.       case 111:  goto nulop;            /* 6C - 6F                            */
  1344.       case 112:
  1345.       case 113:
  1346.       case 114:
  1347.       case 115:
  1348.       case 116:
  1349.       case 117:
  1350.       case 118:
  1351.       case 119:
  1352.       case 120:
  1353.       case 121:
  1354.       case 122:
  1355.       case 123:
  1356.       case 124:
  1357.       case 125:
  1358.       case 126:
  1359.       case 127:  goto jdispop;          /* 70 - 7F                            */
  1360.       case 128:
  1361.       case 129:  goto memimop;          /* 80, 81                             */
  1362.       case 130:  goto memimop;          /* 82                              526*/
  1363.       case 131:  goto memimop2;         /* 83                                 */
  1364.       case 132:
  1365.       case 133:
  1366.       case 134:
  1367.       case 135:
  1368.       case 136:
  1369.       case 137:
  1370.       case 138:
  1371.       case 139:  goto memop;            /* 84 - 8B                            */
  1372.       case 140:  goto memsegop;         /* 8C                                 */
  1373.       case 141:  goto laddrop;          /* 8D                                 */
  1374.       case 142:  goto memsegop;         /* 8E                                 */
  1375.       case 143:  goto mempopop;         /* 8F                                 */
  1376.       case 144:  goto nulop;            /* 90                                 */
  1377.       case 145:
  1378.       case 146:
  1379.       case 147:
  1380.       case 148:
  1381.       case 149:
  1382.       case 150:
  1383.       case 151:  goto aregxop;          /* 91 - 97                            */
  1384.       case 152:
  1385.       case 153:  goto nulop;            /* 98, 99                             */
  1386.       case 154:  goto c32op;            /* 9A                                 */
  1387.       case 155:
  1388.       case 156:
  1389.       case 157:
  1390.       case 158:
  1391.       case 159:  goto nulop;            /* 9B - 9F                            */
  1392.       case 160:
  1393.       case 161:
  1394.       case 162:
  1395.       case 163:  goto AXmemop;          /* A0 - A3                            */
  1396.       case 164:
  1397.       case 165:
  1398.       case 166:
  1399.       case 167:  goto lostrop;          /* A4 - A7                            */
  1400.       case 168:
  1401.       case 169:  goto aregimop;         /* A8, A9                             */
  1402.       case 170:
  1403.       case 171:  goto stoscanop;        /* AA, AB                             */
  1404.       case 172:
  1405.       case 173:  goto lostrop;          /* AC, AD                             */
  1406.       case 174:
  1407.       case 175:  goto stoscanop;        /* AE, AF                             */
  1408.       case 176:
  1409.       case 177:
  1410.       case 178:
  1411.       case 179:
  1412.       case 180:
  1413.       case 181:
  1414.       case 182:
  1415.       case 183:
  1416.       case 184:
  1417.       case 185:
  1418.       case 186:
  1419.       case 187:
  1420.       case 188:
  1421.       case 189:
  1422.       case 190:
  1423.       case 191:  goto regimop;          /* B0 - BF                            */
  1424.       case 192:
  1425.       case 193:  goto shiftop;          /* C0, C1                             */
  1426.       case 194:  goto retop;            /* C2                                 */
  1427.       case 195:  goto ret0op;           /* C3                                 */
  1428.       case 196:
  1429.       case 197:  goto laddrop;          /* C4, C5                             */
  1430.       case 198:
  1431.       case 199:  goto MVImemop;         /* C6, C7                             */      case 200:  goto enterop;          /* C8                                 */
  1432.       case 201:  goto nulop;            /* C9                                 */
  1433.       case 202:  goto retop;            /* CA                                 */
  1434.       case 203:  goto retfop;           /* CB                                 */
  1435.       case 204:  goto int3op;           /* CC                                 */
  1436.       case 205:  goto intop;            /* CD                                 */
  1437.       case 206:  goto intoop;           /* CE                                 */
  1438.       case 207:  goto intretop;         /* CF                                 */
  1439.       case 208:
  1440.       case 209:
  1441.       case 210:
  1442.       case 211:  goto shiftop;          /* D0 - D3                            */
  1443.       case 212:
  1444.       case 213:  goto AAop;             /* D4, D5                             */
  1445.       case 214:  goto illegop;          /* D6                                 */
  1446.       case 215:  goto xlatop;           /* D7                                 */
  1447.       case 216:
  1448.       case 217:
  1449.       case 218:
  1450.       case 219:
  1451.       case 220:
  1452.       case 221:
  1453.       case 222:
  1454.       case 223:  goto escapeop;         /* D8 - DF                            */
  1455.       case 224:
  1456.       case 225:
  1457.       case 226:
  1458.       case 227:  goto jdispop;          /* E0 - E3                            */
  1459.       case 228:
  1460.       case 229:
  1461.       case 230:
  1462.       case 231:  goto IOimop;           /* E4 - E7                            */
  1463.       case 232:  goto c16op;            /* E8                                 */
  1464.       case 233:  goto j16op;            /* E9                                 */
  1465.       case 234:  goto j32op;            /* EA                                 */
  1466.       case 235:  goto jdispop;          /* EB                                 */
  1467.       case 236:
  1468.       case 237:
  1469.       case 238:
  1470.       case 239:  goto IODXop;           /* EC - EF                            */
  1471.       case 240:  goto nulop;            /* F0                                 */
  1472.       case 241:  goto illegop;          /* F1                                 */
  1473.       case 242:
  1474.       case 243:  goto repop;            /* F2, F3                             */
  1475.       case 244:
  1476.       case 245:  goto nulop;            /* F4, F5                             */
  1477.       case 246:
  1478.       case 247:  goto memF6F7op;        /* F6, F7                             */
  1479.       case 248:
  1480.       case 249:
  1481.       case 250:
  1482.       case 251:
  1483.       case 252:
  1484.       case 253:  goto nulop;            /* F8 - FD                            */
  1485.       case 254:
  1486.       case 255:  goto FEFFop;           /* FE, FF                             */
  1487.   }
  1488.                                         /* D4, D5                             */
  1489. AAop:                                   /* AAD and AAM instructions           */
  1490.   prtbyte();
  1491.   if (ic != 0x0A)
  1492.     goto illegop;
  1493.                                         /* second byte is @0A                 */
  1494.   printmnem(mnemAA[instr-0xD4]);        /* for these instructions, we
  1495.                                             have not printed the mnemonic     */
  1496.   goto exit;
  1497.                                         /*  04, 05, 0C, 0D
  1498.                                             14, 15, 1C, 1D
  1499.                                             24, 25, 2C, 2D
  1500.                                             34, 35, 3C, 3D
  1501.                                             A8, A9                            */
  1502. aregimop:                               /* operations between AX/AL (EAX/AL in
  1503.                                            32-bit mode) and immediate operands*/
  1504.   wbit = (UCHAR)(instr & 1);            /* set 8/16/32 bit marker:
  1505.                                            0 => 8 bit, 1 => 16/32 bit.        */
  1506.   regf = 0;                             /* the register is EAX/AX/AL          */
  1507. aregiml1:                               /* jump to here for other
  1508.                                            register/immediate ops             */
  1509.   prt8reg16(regf);
  1510.   *ibuff++ = ',';
  1511.   #if defined(_ASM86_)
  1512.     if (!masm)
  1513.       {
  1514.         *ibuff++ = 'X';
  1515.         *ibuff++ = '\'';
  1516.         quoteflag = 1;
  1517.       }
  1518.   #endif
  1519.  
  1520. /* aregiml2:                                                                  */
  1521.  
  1522.   parm->retreg = regf;
  1523.   if (!wbit)
  1524.     parm->retreg += 16;
  1525.   else
  1526.     {
  1527.       if (opsize32)
  1528.         parm->retreg += 8;
  1529.     }
  1530.   parm->rettype = regimmedtype;
  1531.   if (!wbit)
  1532.     {
  1533.       prtbyte();                        /* get next byte of instruction       */
  1534.       ibuff = hexbyte(ic,ibuff);
  1535.       parm->retimmed = ic;
  1536.     }
  1537.   else
  1538.     {
  1539.                                         /* set f1 to next word (opsize32 = 0)
  1540.                                         or double word (orsize32 = 1) of the
  1541.                                         instruction, and print it in hex      */
  1542.       if (opsize32)
  1543.         {
  1544.           prtdword();
  1545.           ibuff = hexdword(f1,ibuff);
  1546.         }
  1547.       else
  1548.         {
  1549.           prtword();
  1550.           ibuff = hexword(f1,ibuff);
  1551.         }
  1552.       parm->retimmed = f1;
  1553.     }
  1554.  
  1555.   #if defined(_ASM86_)
  1556.     if (masm)
  1557.   #endif
  1558.       *ibuff++ = 'H';
  1559.   #if defined(_ASM86_)
  1560.     else
  1561.       {
  1562.         if (quoteflag)
  1563.           *ibuff++ = '\'';
  1564.       }
  1565.   #endif
  1566.   goto exit;
  1567.                                         /* 91 - 97                            */
  1568. aregxop:                                /* XCHG (E)AX,rr orders               */
  1569.   if (opsize32)
  1570.     ibuff = printitem((ULONG)0,reg32,ibuff);
  1571.   else
  1572.     ibuff = printitem((ULONG)0,reg16,ibuff);
  1573.   *ibuff++ = ',';
  1574.   goto reg16op;
  1575.                                         /* 63                                 */
  1576. ARPLop:                                 /* ARPL                               */
  1577.   dbit = 0;                             /* register is second operand         */
  1578.   wbit = 1;                             /* word operand                       */
  1579.   opsize32 = 0;                         /* this is always a 16-bit operation  */
  1580.   parm->retbits &= 0xFFFE;
  1581.   setrm();
  1582.   goto memop0;
  1583.                                         /* A0 - A3                            */
  1584. AXmemop:                                /* single byte MOV orders, with 16-bit
  1585.                                            displacement                       */
  1586.   setdw();
  1587.   #if defined(_ASM86_)
  1588.     if (masm)
  1589.   #endif
  1590.       dbit = (UCHAR)(dbit ^ 2);
  1591.   #if defined(_ASM86_)
  1592.     else                                /* force the register to be the first */
  1593.       dbit = 2;                         /* operand for these instructions     */
  1594.   #endif
  1595.   if (addr32)
  1596.     {
  1597.       prtdword();
  1598.       opdisp = f1;
  1599.     }
  1600.   else
  1601.     {
  1602.       prtword();
  1603.       opdisp = f1;
  1604.     }
  1605.   regf = 0;
  1606.   mod = 0;
  1607.   rm = 6;
  1608.   basereg = 0;
  1609.   indexreg = 0;
  1610.   scalefactor = 0;
  1611.   disppres = 1;
  1612.   goto memop2;
  1613.                                         /* 62                                 */
  1614. boundop:                                /* BOUND                              */
  1615.   dbit = 2;                             /* register is first operand          */
  1616.   wbit = 1;                             /* word operation                     */
  1617.   setrm();
  1618.   if (mod == 3)
  1619.     goto illegop;                       /* illegal if second operand
  1620.                                            would be a register                */
  1621.   parm->rettype = BOUNDtype;
  1622.   goto memop0;
  1623.                                         /* C8                                 */
  1624. enterop:                                /* procedure ENTER instruction        */
  1625.   wbit = 1;                             /* a word immediate operand           */
  1626.   nocomma = 1;                          /* no leading comma for operand field */
  1627.   opsize32 = 0;                         /* this is always a 16-bit operation  */
  1628.   prtimmed();
  1629.   wbit = 0;                             /* then a byte immediate operand      */
  1630.   nocomma = 0;                          /* leading comma now wanted           */
  1631.   prtimmed();
  1632.   goto exit;
  1633.                                         /* D8 - DF                            */
  1634. escapeop:                               /* escape orders - for 287/387        */
  1635.   setrm();
  1636.   wbit = 1;                             /* force a word operation             */
  1637.   if (mod == 3)
  1638.     {
  1639.       parm->rettype = escapetype;
  1640.       parm->retescape = (USHORT)(((((USHORT)(instr & 0x07) << 3) + regf) << 3) + rm);
  1641.     }                                   /* added ushort cast               521*/
  1642.   else
  1643.     {
  1644.       parm->rettype = escmemtype;
  1645.       parm->retescape = (USHORT)(((USHORT)(instr & 0x07) << 3) + regf);
  1646.     }                                   /* added ushort cast               521*/
  1647.   if ((parm->flagbits & N387mask) == 0)
  1648.     {
  1649.                                         /* do not perform 287/387 decode      */
  1650.     printmnem(escmnem);                 /* ESCAPE/ESC                         */
  1651.     dbit = 251;                         /* a special case                     */
  1652.     goto memop0;
  1653.   }
  1654.                                         /* we are to perform 287/387 decode   */
  1655.   ESCinstr = (UCHAR)(((UCHAR)(instr & 7) << 3) + regf);
  1656.                                         /* added uchar cast                521*/
  1657.   if (mod != 3)
  1658.   {
  1659.                                         /* it is an operation that accesses
  1660.                                            memory                             */
  1661.     if (m387mem[ESCinstr] == fillegmnem)
  1662.       goto illegop;
  1663.                                         /* trap the illegal cases             */
  1664.     print387m(m387mem[ESCinstr]);
  1665.     dbit = 249;                         /* so only the memory operand is
  1666.                                            printed                            */
  1667.     goto memop0;
  1668.   }
  1669.                                         /* it is a non-memory operation - jump
  1670.                                            according to opcode                */
  1671.   switch (ESCinstr)
  1672.     {
  1673.      case  0:
  1674.      case  1:  goto ESCreg1;            /* D8, 0,1                            */
  1675.      case  2:
  1676.      case  3:  goto ESCreg0;            /* D8, 2,3                            */
  1677.      case  4:
  1678.      case  5:
  1679.      case  6:
  1680.      case  7:  goto ESCreg1;            /* D8, 4-7                            */
  1681.      case  8:
  1682.      case  9:  goto ESCreg0;            /* D9, 0,1                            */
  1683.      case 10:  goto ESCD92;             /* D9, 2                              */
  1684.      case 11:  goto ESCreg0;            /* D9, 3                              */
  1685.      case 12:
  1686.      case 13:
  1687.      case 14:
  1688.      case 15:  goto ESCD94;             /* D9, 4-7                            */
  1689.      case 16:
  1690.      case 17:
  1691.      case 18:
  1692.      case 19:
  1693.      case 20:  goto illegop;            /* DA, 0-4                            */
  1694.      case 21:  goto ESCDA5;             /* DA, 5                              */
  1695.      case 22:
  1696.      case 23:  goto illegop;            /* DA, 6,7                            */
  1697.      case 24:
  1698.      case 25:
  1699.      case 26:
  1700.      case 27:  goto illegop;            /* DB, 0-3                            */
  1701.      case 28:  goto ESCDB4;             /* DB, 4                              */
  1702.      case 29:
  1703.      case 30:
  1704.      case 31:  goto illegop;            /* DB, 5-7                            */
  1705.      case 32:
  1706.      case 33:  goto ESCreg2;            /* DC, 0,1                            */
  1707.      case 34:
  1708.      case 35:  goto ESCreg0;            /* DC, 2,3                            */
  1709.      case 36:
  1710.      case 37:
  1711.      case 38:
  1712.      case 39:  goto ESCreg2;            /* DC, 4-7                            */
  1713.      case 40:
  1714.      case 41:
  1715.      case 42:
  1716.      case 43:
  1717.      case 44:
  1718.      case 45:  goto ESCreg0;            /* DD, 0-5                            */
  1719.      case 46:
  1720.      case 47:  goto illegop;            /* DD, 6,7                            */
  1721.      case 48:
  1722.      case 49:  goto ESCreg2;            /* DE, 0,1                            */
  1723.      case 50:  goto ESCreg0;            /* DE, 2                              */
  1724.      case 51:  goto ESCDE3;             /* DE, 3                              */
  1725.      case 52:
  1726.      case 53:
  1727.      case 54:
  1728.      case 55:  goto ESCreg2;            /* DE, 4-7                            */
  1729.      case 56:
  1730.      case 57:
  1731.      case 58:
  1732.      case 59:  goto ESCreg0;            /* DF, 0-3                            */
  1733.      case 60:  goto ESCDF4;             /* DF, 4                              */
  1734.      case 61:
  1735.      case 62:
  1736.      case 63:  goto illegop;            /* DF, 5-7                            */
  1737.   }
  1738.                                         /* instructions with a reg field      */
  1739. ESCreg0:  dbit = 0;                     /* no ST operand                      */
  1740.   goto ESCreg;
  1741. ESCreg1:  dbit = 1;                     /* ST is the first operand            */
  1742.   goto ESCreg;
  1743. ESCreg2:  dbit = 2;                     /* ST is the second operand           */
  1744. ESCreg:  print387m(m387reg[ESCinstr]);
  1745.   if (dbit == 1)
  1746.     {
  1747.                                         /* print ST as the first operand      */
  1748.       *ibuff++ = 'S';
  1749.       *ibuff++ = 'T';
  1750.       *ibuff++ = ',';
  1751.     }
  1752.   *ibuff++ = 'S';
  1753.   *ibuff++ = 'T';
  1754.   *ibuff++ = '(';
  1755.   ibuff = disbyte(rm, ibuff);           /* print register number              */
  1756.   *ibuff++ = ')';
  1757.   if (dbit == 2)
  1758.     {
  1759.                                         /* print ST as the second operand     */
  1760.  
  1761.       *ibuff++ = ',';
  1762.       *ibuff++ = 'S';
  1763.       *ibuff++ = 'T';
  1764.     }
  1765.   goto exit;
  1766.                                         /* the following are special cases    */
  1767. ESCD92:                                 /* D9 op code, mod=3, regf=2          */
  1768.   if (rm == 0)
  1769.     {
  1770.       rm = (UCHAR)(fnopmnem);
  1771.  
  1772. ESCnoopand:  print387m(rm);
  1773.       goto exit;
  1774.     }
  1775.   goto illegop;
  1776.  
  1777. ESCD94:                                 /* D9 op code, mod = 3, regf = 4-7    */
  1778.                                         /* jump according to the mod and reg
  1779.                                            field                              */
  1780.   rm = (UCHAR)(((regf-4) << 3) + rm);
  1781.   switch (rm)
  1782.     {
  1783.       case  0:
  1784.       case  1:  goto ESCD95;            /* regf=4, rm=0,1                     */
  1785.       case  2:
  1786.       case  3:  goto illegop;           /* regf=4, rm=2,3                     */
  1787.       case  4:
  1788.       case  5:  goto ESCD95;            /* regf=4, rm=4,5                     */
  1789.       case  6:
  1790.       case  7:  goto illegop;           /* regf=4, rm=6,7                     */
  1791.       case  8:
  1792.       case  9:
  1793.       case 10:
  1794.       case 11:
  1795.       case 12:
  1796.       case 13:
  1797.       case 14:  goto ESCD95;            /* regf=5, rm=0-6                     */
  1798.       case 15:  goto illegop;           /* regf=5, rm=7                       */
  1799.       case 16:
  1800.       case 17:
  1801.       case 18:
  1802.       case 19:
  1803.       case 20:
  1804.       case 21:
  1805.       case 22:
  1806.       case 23:  goto ESCD95;            /* regf=6, rm=0-7                     */
  1807.       case 24:
  1808.       case 25:
  1809.       case 26:
  1810.       case 27:
  1811.       case 28:
  1812.       case 29:
  1813.       case 30:
  1814.       case 31:  goto ESCD95;            /* regf=7, rm=0-7                     */
  1815.   }
  1816. ESCD95:  rm = (UCHAR)(mnemD94[rm]);
  1817.   goto ESCnoopand;
  1818. ESCDA5:  if (rm != 1) goto illegop;
  1819.   rm = (UCHAR)(fucomppmnem);
  1820.   goto ESCnoopand;
  1821. ESCDB4:                                 /* DB op code, mod = 3, regf = 4      */
  1822.                                         /* jump according to the mod and reg
  1823.                                            field                              */
  1824.   rm = (UCHAR)(((regf-4) << 3) + rm);
  1825.   if (rm < 5)                           /* regf=4, rm=0-4                     */
  1826.     goto ESCDB4a;
  1827.   else                                  /* regf=4, rm=5-7                     */
  1828.     goto illegop;
  1829. ESCDB4a:  rm = (UCHAR)(mnemDB4[rm]);
  1830.   goto ESCnoopand;
  1831. ESCDE3:                                 /* DE op code, mod=3, regf=3          */
  1832.   if (rm == (UCHAR)(fabsmnem))
  1833.     {
  1834.       rm = (UCHAR)(fcomppmnem);
  1835.       goto ESCnoopand;
  1836.     }
  1837.   goto illegop;
  1838. ESCDF4:                                 /* DF op code, mod=3, regf=4          */
  1839.   if (rm == 0)
  1840.     {
  1841.       print387m(fstswmnem);
  1842.       ibuff = printitem((ULONG)0, reg16, ibuff);
  1843.       goto exit;
  1844.     }
  1845.   goto illegop;
  1846.                                         /* FE, FF                             */
  1847. FEFFop:                                 /* miscellaneous operations:  all
  1848.                                             have mod/rm byte
  1849.                                             and possible displacement bytes   */
  1850.   setdw();
  1851.   setrm();
  1852.   if (regf == 0 || regf == 1)
  1853.     goto F6F7l1;
  1854.   if (instr == 0xFE || regf == 7)
  1855.     goto illegop;
  1856.   dbit = 254;                           /* no second operand                  */
  1857.   wbit = 1;                             /* force a word operation             */
  1858.   if (regf == 6)
  1859.     printmnem(pushmnem);
  1860.   else
  1861.     {
  1862.       if (mod == 3)
  1863.         {
  1864.           if (regf == 3 || regf == 5)
  1865.             goto illegop;
  1866.           if (regf == 2 )
  1867.             parm->rettype = cnearregtype;
  1868.           else                          /* regf = 4                           */
  1869.           parm->rettype = jnearregtype;
  1870.         }
  1871.       else
  1872.         {
  1873.           if (regf == 2)
  1874.             parm->rettype = cnearmemtype;
  1875.           if (regf == 3)
  1876.             parm->rettype = cfartype;
  1877.           if (regf == 4)
  1878.             parm->rettype = jnearmemtype;
  1879.           if (regf == 5)
  1880.             parm->rettype = jfartype;
  1881.         }
  1882.       printmnem(mnemFF[regf - 2]);
  1883.     }
  1884.   goto memop0;
  1885.                                         /* illegal instructions               */
  1886. illegop:
  1887.   parm->iptr = startiptr + 1;
  1888.   printmnem(illegmnem);
  1889.   parm->rettype = illegtype;
  1890.   goto exit;
  1891.                                         /* CC                                 */
  1892. int3op:                                 /* INT3  instruction                  */
  1893.   ic = 3;
  1894.   #if defined(_ASM86_)
  1895.     if (!masm)
  1896.       goto intop_2;
  1897.   #endif
  1898.   goto intop_1;
  1899.                                         /* CE                                 */
  1900. intoop:                                 /* INTO  instruction                  */
  1901.   ic = 4;
  1902.   goto intop_2;
  1903.                                         /* CD                                 */
  1904. intop:                                  /* INT n instructions                 */
  1905.   prtbyte();                            /* get next byte of instruction       */
  1906.  
  1907. intop_1:
  1908.   #if defined(_ASM86_)
  1909.     if (!masm)
  1910.       {
  1911.         *ibuff++ = 'X';
  1912.         *ibuff++ = '\'';
  1913.         quoteflag = 1;
  1914.       }
  1915.   #endif
  1916.   ibuff = hexbyte(ic,ibuff);
  1917.   #if defined(_ASM86_)
  1918.     if (masm)
  1919.   #endif
  1920.       *ibuff++ = 'H';
  1921.   #if defined(_ASM86_)
  1922.     else
  1923.       {
  1924.         if (quoteflag)
  1925.           *ibuff++ = '\'';
  1926.       }
  1927.   #endif
  1928.  
  1929. intop_2:
  1930.   parm->retoffset = ic;
  1931.   parm->rettype = intntype;
  1932.   goto exit;
  1933.                                         /* CF                                 */
  1934. intretop:                               /* IRET  instruction                  */
  1935.   parm->rettype = intrettype;
  1936.   parm->retoffset = 0;
  1937.   goto exit;
  1938.                                         /* EC - EF                            */
  1939. IODXop:                                 /* IN DX and OUT DX instructions      */
  1940.   IODX = 1;                             /* mark it as DX type                 */
  1941. IODXl1:
  1942.   setdw();
  1943.  
  1944.   #if defined(_ASM86_)
  1945.     if (masm)
  1946.       {
  1947.   #endif
  1948.         if (dbit == 0)
  1949.           {
  1950.              prt8reg16(0);
  1951.              *ibuff++ = ',';
  1952.           }
  1953.   #if defined(_ASM86_)
  1954.       }
  1955.     else
  1956.       {
  1957.         if (!IODX)
  1958.           {
  1959.             *ibuff++ = 'X';
  1960.             *ibuff++ = '\'';
  1961.             quoteflag = 1;
  1962.           }
  1963.       }
  1964.   #endif
  1965.   if (IODX)
  1966.     ibuff = printitem((ULONG)2,reg16,ibuff);
  1967.     else
  1968.       {
  1969.         ibuff = hexbyte(ic,ibuff);
  1970.         #if defined(_ASM86_)
  1971.           if (masm)
  1972.             {
  1973.         #endif
  1974.         *ibuff++ = 'H';
  1975.         if (dbit != 0)
  1976.           {
  1977.             *ibuff++ = ',';
  1978.             prt8reg16(0);          }
  1979.          #if defined(_ASM86_)
  1980.             }
  1981.           else
  1982.             {
  1983.               if (quoteflag)
  1984.                 *ibuff++ = '\'';
  1985.             }
  1986.          #endif
  1987.  
  1988.       }
  1989.   goto exit;
  1990.                                         /* E4 - E7                            */
  1991. IOimop:                                 /* IN xx and OUT xx instructions      */
  1992.   prtbyte();
  1993.   goto IODXl1;
  1994.                                         /* E8                                 */
  1995. c16op:                                  /* single byte call instructions with
  1996.                                            16 bit relative displacements      */
  1997.   parm->rettype = creltype;
  1998.   goto j16op0;
  1999.                                         /* E9                                 */
  2000. j16op:                                  /* single byte jump instructions with
  2001.                                            16 bit relative displacements      */
  2002.   parm->rettype = jreltype;
  2003. j16op0:
  2004.   if (opsize32)
  2005.     prtdword();
  2006.   else
  2007.     prtword();
  2008.   if (parm->instr_EIP == 0xFFFFFFFF)
  2009.     *ibuff++ = '+';
  2010.   #if defined(_ASM86_)
  2011.     if (!masm)
  2012.       {
  2013.         *ibuff++ = 'X';
  2014.         *ibuff++ = '\'';
  2015.         quoteflag = 1;
  2016.       }
  2017.   #endif
  2018.   if (!opsize32)
  2019.     f1 = (signed long) ((short) f1);
  2020.                                         /* sign extend the lower 16 bits      */
  2021.   if (parm->instr_EIP == 0xFFFFFFFF)
  2022.     {
  2023.       if (opsize32)
  2024.         ibuff = hexdword(f1,ibuff);
  2025.       else
  2026.         {
  2027.           ibuff = hexword(f1,ibuff);
  2028.         }
  2029.     }
  2030.   else
  2031.     {
  2032.                                         /* we have an EIP value - print
  2033.                                            resultant address                  */
  2034.     f2 = (parm->iptr - startiptr) + parm->instr_EIP + f1;
  2035.     if (opsize32)
  2036.       ibuff = hexdword(f2,ibuff);
  2037.     else
  2038.       ibuff = hexword(f2,ibuff);
  2039.     }
  2040. j16op1:
  2041.   #if defined(_ASM86_)
  2042.     if (masm)
  2043.   #endif
  2044.       *ibuff++ = 'H';
  2045.   #if defined(_ASM86_)
  2046.     else
  2047.       {
  2048.         if (quoteflag)
  2049.           *ibuff++ = '\'';
  2050.       }
  2051.   #endif
  2052.   parm->retoffset = f1;
  2053.   goto exit;
  2054.                                         /* 9A                                 */
  2055. c32op:                                  /* call instructions with 32-bit
  2056.                                            operands                           */
  2057.   parm->rettype = cfarimmtype;
  2058.   goto j32op_1;
  2059.                                         /* EA                                 */
  2060. j32op:                                  /* jump instructions with 32-bit
  2061.                                            operands                           */
  2062.   parm->rettype = jfarimmtype;
  2063. j32op_1:                                /* get new (E)IP value                */
  2064.   if (opsize32)
  2065.     prtdword();
  2066.   else
  2067.     prtword();
  2068.   f2 = f1;                              /* save it so the next line does not
  2069.                                            overwrite it                       */
  2070.   prtword();                            /* get new CS value                   */
  2071.   #if defined(_ASM86_)
  2072.     if (!masm)
  2073.       {
  2074.         *ibuff++ = 'X';
  2075.         *ibuff++ = '\'';
  2076.         quoteflag = 1;
  2077.       }
  2078.   #endif
  2079.   ibuff = hexword(f1,ibuff);
  2080.   #if defined(_ASM86_)
  2081.     if (masm)
  2082.   #endif
  2083.       *ibuff++ = 'H';
  2084.   #if defined(_ASM86_)
  2085.     else
  2086.       {
  2087.         if (quoteflag)
  2088.           *ibuff++ = '\'';
  2089.       }
  2090.   #endif
  2091.   *ibuff++ = ':';
  2092.   #if defined(_ASM86_)
  2093.     if (!masm)
  2094.       {
  2095.         *ibuff++ = 'X';
  2096.         *ibuff++ = '\'';
  2097.         quoteflag = 1;
  2098.       }
  2099.   #endif
  2100.   if (opsize32)
  2101.     ibuff = hexdword(f2,ibuff);
  2102.   else
  2103.     ibuff = hexword(f2,ibuff);
  2104.   #if defined(_ASM86_)
  2105.     if (masm)
  2106.   #endif
  2107.       *ibuff++ = 'H';
  2108.   #if defined(_ASM86_)
  2109.     else
  2110.       {
  2111.         if (quoteflag) *ibuff++ = '\'';
  2112.       }
  2113.   #endif
  2114.   parm->retoffset = f2;
  2115.   parm->retseg = (USHORT)f1;
  2116.   goto exit;
  2117.                                         /* 70 - 7F, E0 - E3, EB               */
  2118. jdispop:                                /* single byte jump instructions with
  2119.                                            single byte signed displacements   */
  2120.   prtbyte();
  2121.   if (ic > 127)
  2122.     {
  2123.                                         /* the displacement is negative       */
  2124.       if (parm->instr_EIP == 0xFFFFFFFF)
  2125.         *ibuff++ = '-';
  2126.       ic = (UCHAR)(256 - ic);
  2127.       f1 = 0 - ic;
  2128.     }
  2129.   else
  2130.     {
  2131.       if (parm->instr_EIP == 0xFFFFFFFF)
  2132.         *ibuff++ = '+';
  2133.       f1 = ic;
  2134.     }
  2135.   #if defined(_ASM86_)
  2136.     if (!masm)
  2137.       {
  2138.         *ibuff++ = 'X';
  2139.         *ibuff++ = '\'';
  2140.         quoteflag = 1;
  2141.       }
  2142.   #endif
  2143.   if (parm->instr_EIP == 0xFFFFFFFF)
  2144.     {
  2145.       ibuff = hexbyte(ic,ibuff);
  2146.     }
  2147.   else
  2148.     {
  2149.                                         /* we have an EIP value - print
  2150.                                            resultant address                  */
  2151. jdisp_1:
  2152.     f2 = (parm->iptr - startiptr) + parm->instr_EIP + f1;
  2153. jdisp_2:
  2154.     if (opsize32)
  2155.       ibuff = hexdword(f2,ibuff);
  2156.     else
  2157.       ibuff = hexword(f2,ibuff);
  2158.     }
  2159.   parm->rettype = jreltype;
  2160.   goto j16op1;
  2161.                                         /* 0F 80-8F                           */
  2162. jfulldispop:                            /* two byte jump instructions with
  2163.                                            full signed displacements          */
  2164.   if (opsize32)
  2165.     {
  2166.                                         /* there is a 4-byte operand          */
  2167.       prtdword();
  2168.     }
  2169.   else
  2170.     {
  2171.                                         /* there is a 2-byte operand          */
  2172.       prtword();
  2173.       f1 = (signed long) ((short) f1);  /* sign extend the lower 16 bits      */
  2174.     }
  2175.   f2 = f1;
  2176.   if (f1 > 0x7FFFFFFF)
  2177.     {
  2178.                                         /* the displacement is negative       */
  2179.     if (parm->instr_EIP == 0xFFFFFFFF)
  2180.       *ibuff++ = '-';
  2181.     f2 = 0 - f2;
  2182.     }
  2183.   else
  2184.     {
  2185.       if (parm->instr_EIP == 0xFFFFFFFF)
  2186.         *ibuff++ = '+';
  2187.     }
  2188.   #if defined(_ASM86_)
  2189.     if (!masm)
  2190.       {
  2191.         *ibuff++ = 'X';
  2192.         *ibuff++ = '\'';
  2193.         quoteflag = 1;
  2194.       }
  2195.   #endif
  2196.   if (parm->instr_EIP != 0xFFFFFFFF)
  2197.     goto jdisp_1;
  2198.   goto jdisp_2;
  2199.                                         /* 8D, C4, C5                         */
  2200. laddrop:                                /* load address - also LES and LDS    */
  2201.   setrm();
  2202.   dbit = 2;                             /* register is first operand          */
  2203.   wbit = 1;                             /* force a word operation             */
  2204.   if (instr != 0x8D)
  2205.     parm->rettype = memwwtype;
  2206.   else
  2207.     parm->rettype = LEAtype;
  2208.   goto memop0;
  2209.                                         /* 0F 02,03                           */
  2210. LARop:                                  /* load access rights                 */
  2211.   dbit = 2;                             /* register is first operand          */
  2212.   wbit = 1;                             /* word operation                     */
  2213.   goto memop00;
  2214.                                         /* AC, AD                             */
  2215. lostrop:                                /* load string orders                 */
  2216.   if (ovseg == 0)
  2217.     parm->retreg = defseg;
  2218.   else
  2219.     parm->retreg = ovseg;
  2220.   if (addr32)
  2221.     parm->retbase = 14;                 /* ESI                                */
  2222.   else
  2223.     parm->retbase = 6;                  /* SI                                 */
  2224.   goto stscl1;
  2225.                                         /* F6, F7                             */
  2226. memF6F7op:                              /* further memory operations:  all have
  2227.                                            mod/rm byte and possible displacement
  2228.                                            or immediate operand               */
  2229.   setdw();
  2230.   setrm();
  2231.   if (regf == 1)
  2232.     goto illegop;
  2233.   if (regf == 0)
  2234.     {
  2235.                                         /* it is TIB/TIW(TEST) mem,xx         */
  2236.       dbit = 255;
  2237.       #if defined(_ASM86_)
  2238.         f1 = timnem;
  2239.         if (mod != 3)
  2240.           {
  2241.             if (wbit == 0)
  2242.               f1 = tibmnem;
  2243.             else
  2244.               f1 = tiwmnem;
  2245.           }
  2246.         if (masm)
  2247.       #endif
  2248.       f1 = testmnem;
  2249.       printmnem((USHORT)f1);
  2250.       goto memop0;
  2251.     }
  2252.                                         /* other versions of these operations
  2253.                                            have only one operand              */
  2254.  
  2255. F6F7l1:
  2256.   dbit = 254;
  2257.   #if defined(_ASM86_)
  2258.     f1 = wbit * 8;
  2259.     if (mod == 3)
  2260.       f1 = 16;
  2261.     if (masm)
  2262.   #endif
  2263.   f1 = 0;
  2264.   printmnem(mnemF6F7[regf + f1]);
  2265.   goto memop0;
  2266.                                         /* 82, 83                             */
  2267. memimop2:                               /* as memimop, but word operations have
  2268.                                            8-bit sign extended immediate
  2269.                                            operands (i.e. not a 16-bit
  2270.                                            operand)                           */
  2271.   setdw();                              /* d bit is not significant in this
  2272.                                            case                               */
  2273.   setrm();
  2274.   if (wbit != 0)
  2275.   signext = 1;                          /* if a word order, the immediate
  2276.                                            operand is 8 bit sign extended     */
  2277.   goto memimopa;
  2278.                                         /* 80, 81                             */
  2279. memimop:                                /* a single byte instruction with
  2280.                                            mem-regf-r/m, followed by 1 or 2
  2281.                                            byte immediate operand:
  2282.                                            the regf field further defines the
  2283.                                            operation                          */
  2284.   setdw();                              /* d bit is not significant in this
  2285.                                            case                               */
  2286.   setrm();
  2287. memimopa:
  2288.   dbit = 255;
  2289.   f2 = (ULONG)(instr & 1) << 3;         /* added ulong cast                521*/
  2290.   if (mod == 3) f2 = 16;
  2291.   printmnem(mnem8081[f2 + regf]);
  2292.   goto memop0;                                        /*  00 - 03, 08 - 0B
  2293.                                             10 - 13, 18 - 1B
  2294.                                             20 - 23, 28 - 2B
  2295.                                             30 - 33, 38 - 3B
  2296.                                             84 - 8B                           */
  2297.  
  2298. memop:                                  /* single byte instructions with
  2299.                                            mem-regf-r/m byte plus possible
  2300.                                            displacement bytes                 */
  2301.   setdw();
  2302. memop00:
  2303.   setrm();
  2304.   #if defined(_ASM86_)
  2305.     if (!masm && (instr == 0x88 || instr == 0x89))
  2306.       {
  2307.                                         /* bodge the d bit for these (STore)
  2308.                                            instructions                       */
  2309.         dbit = 2;
  2310.       }
  2311.   #endif
  2312.                                         /* look for operand displacement      */
  2313. memop0:
  2314.   opdisp = 0;
  2315.   signeddisp = 0;
  2316.   if ((mod == 2) || ((mod == 0) && (rm == 6) && !addr32) ||
  2317.        ((mod == 0) && (rm == 5) && addr32) ||
  2318.        (addr32 && mod == 0 && sibbase5))
  2319.     {
  2320.                                         /* we have a displacement             */
  2321.       if (addr32)
  2322.         prtdword();
  2323.       else
  2324.         prtword();
  2325.       opdisp = f1;
  2326.       disppres = 1;
  2327.     }
  2328.   if (mod == 1)
  2329.     {
  2330.                                         /* we have 8-bit signed displacement  */
  2331.       prtbyte();
  2332.       signedflag = 1;
  2333.       opdisp = (signed long) ((signed char) ic);
  2334.                                         /* sign extend operand                */
  2335.       signeddisp = ic;
  2336.       if (ic > 127)
  2337.         {
  2338.  
  2339.                                         /* it is negative                     */
  2340.           negflag = 1;
  2341.           signeddisp = 256 - ic;
  2342.         }
  2343.       disppres = 1;
  2344.     }
  2345.  
  2346.                                         /* apart from the above cases, there
  2347.                                            are no displacement bytes          */
  2348. memop2:
  2349.   if (mod != 3)
  2350.     {
  2351.       if (disppres)
  2352.         parm->retoffset = opdisp;
  2353.       if (parm->rettype == 0)
  2354.         {
  2355.           if (wbit == 0)
  2356.             parm->rettype = membtype;
  2357.           else
  2358.             parm->rettype = memwtype;
  2359.         }
  2360.       if (basereg != 0)
  2361.         {
  2362.           parm->retbase = (UCHAR)(basereg - 1);
  2363.           if (addr32)
  2364.             parm->retbase = (UCHAR)(parm->retbase + 8);
  2365.         }
  2366.       if (indexreg != 0)
  2367.         {
  2368.           parm->retindex = (UCHAR)(indexreg - 1);
  2369.           if (addr32)
  2370.             parm->retindex = (UCHAR)(parm->retindex + 8);
  2371.             parm->retscale = scalefactor;
  2372.         }
  2373.       if (ovseg == 0)
  2374.         parm->retreg = defseg;
  2375.       else
  2376.         parm->retreg = ovseg;
  2377.     }
  2378.   if (dbit == 2 || dbit == 245 || dbit == 246)
  2379.     {
  2380.                                         /* register is first operand - print
  2381.                                            register name                      */
  2382.       if (dbit == 245 || dbit == 246)
  2383.         wbit = 1;
  2384.                                         /* MOVZX/MOVSX
  2385.                                            always have 16/32 bit registers    */
  2386.       segsflag = segrflag;
  2387.       prt8reg16(regf);
  2388.       segrflag = 0;
  2389.       *ibuff++ = ',';
  2390.     }
  2391.   if (dbit == 251)
  2392.     {
  2393.                                         /* register field is printed as a
  2394.                                         number for the first operand this is
  2395.                                         used for escape instructions          */
  2396.       if (mod == 3)
  2397.         {
  2398.           ibuff = hexword((ULONG)((((ULONG)(instr & 0x07) << 3) + regf) << 3) + rm,
  2399.                           ibuff);       /* added ulong cast                521*/
  2400.  
  2401.           #if defined(_ASM86_)
  2402.             if (masm)
  2403.           #endif
  2404.               *ibuff++ = 'H';
  2405.           goto exit;
  2406.         }
  2407.       ibuff = hexbyte((UCHAR)(((UCHAR)(instr & 0x07) << 3) + regf),ibuff);
  2408.                                         /* added uchar cast                521*/
  2409.       #if defined(_ASM86_)
  2410.         if (masm)
  2411.       #endif
  2412.           *ibuff++ = 'H';
  2413.       *ibuff++ = ',';
  2414.     }
  2415.   if (dbit == 246)
  2416.     wbit = 0;                           /* MOVZX/MOVSX may have byte
  2417.                                            second operand                     */
  2418.   if (dbit == 245 || dbit == 246)
  2419.     opsize32 = 0;                       /* MOVZX/MOVSX always has 16-bit size
  2420.                                            second operand                     */
  2421.   if (mod == 3)
  2422.     {
  2423.                                         /* operand is a register              */
  2424.     prt8reg16(rm);
  2425.     }
  2426.   else
  2427.     {
  2428.                                         /* operand is a memory location       */
  2429.       if (masm && (dbit == 245 || dbit == 246 || dbit == 244))
  2430.         goto memop3;
  2431.       if (masm && (dbit == 250 || dbit >= 252) &&
  2432.          (instr != 0xFF || regf < 2 || regf > 5))
  2433.         {
  2434.                                         /* we have a MASM memory operand for an
  2435.                                            instruction with no register operand
  2436.                                            (and not ESC) - output BYTE or WORD.
  2437.                                            But not for CALL and JMP indirect,
  2438.                                            and PUSH memory                    */
  2439. memop3:
  2440.           if (wbit == 1)
  2441.             {
  2442.               if (opsize32)
  2443.                 {
  2444.                   putstr(dwordvec);
  2445.                 }
  2446.               else
  2447.                 {
  2448.                   putstr(wordvec);
  2449.                 }
  2450.             }
  2451.           else
  2452.             {
  2453.               putstr(bytevec);
  2454.             }
  2455.         }
  2456.         if (masm && ovseg != 0)
  2457.           {
  2458.             prtovseg();
  2459.             *ibuff++ = ':';
  2460.           }
  2461.        if (disppres == 1)
  2462.          {
  2463.                                         /* there is a displacement            */
  2464.            #if defined(_ASM86_)
  2465.              if (masm)
  2466.            #endif
  2467.            putpar();                    /* for MASM, entire memory operand is
  2468.                                            in brackets, for compatibility with
  2469.                                            the assembler                      */
  2470.            if (signedflag == 0)
  2471.              {
  2472.                                         /* simple 16-bit case                 */
  2473.                if (addr32)
  2474.                  ibuff = hexdword(opdisp,ibuff);
  2475.                else
  2476.                  ibuff = hexword(opdisp,ibuff);
  2477.                #if defined(_ASM86_)
  2478.                if (masm)
  2479.                #endif
  2480.                  *ibuff++ = 'H';
  2481.              }
  2482.            else
  2483.              {
  2484.                                         /* 8-bit signed case                  */
  2485.                if (negflag)
  2486.                  *ibuff++ = '-';
  2487.                else
  2488.                  *ibuff++ = '+';
  2489.                ibuff = disbyte((UCHAR)(signeddisp),ibuff);
  2490.                #if defined(_ASM86_)
  2491.                  if (masm)
  2492.                #endif
  2493.                    *ibuff++ = 'H';
  2494.              }
  2495.          }
  2496.       if (basereg)
  2497.         {
  2498.                                         /* there is a base register - print it*/
  2499.           putpar();
  2500.           if (addr32)
  2501.             ibuff = printitem((ULONG)(basereg-1),reg32,ibuff);
  2502.           else
  2503.             ibuff = printitem((ULONG)(basereg-1),reg16,ibuff);
  2504.         }
  2505.       if (indexreg != 0)
  2506.         {
  2507.                                         /* there is a base register - print it*/
  2508.           putpar();
  2509.           if (addr32)
  2510.             ibuff = printitem((ULONG)(indexreg-1),reg32,ibuff);
  2511.           else
  2512.             ibuff = printitem((ULONG)(indexreg-1),reg16,ibuff);
  2513.           if (scalefactor != 0)
  2514.             {
  2515.               *ibuff++ = '*';
  2516.               if (scalefactor == 1)
  2517.                 *ibuff++ = '2';
  2518.               if (scalefactor == 2)
  2519.                 *ibuff++ = '4';
  2520.               if (scalefactor == 3)
  2521.                 *ibuff++ = '8';
  2522.             }
  2523.         }
  2524.       #if defined(_ASM86_)
  2525.         if (!masm && ovseg)
  2526.           {
  2527.             putpar();
  2528.             prtovseg();
  2529.           }
  2530.       #endif
  2531.       if (parflag == 1)
  2532.         {
  2533.                                         /* we have output a left parenthesis -
  2534.                                         therefore output a right parenthesis to
  2535.                                         match                                 */
  2536.           #if defined(_ASM86_)
  2537.             if (masm)
  2538.           #endif
  2539.               *ibuff++ = ']';
  2540.           #if defined(_ASM86_)
  2541.             else
  2542.               *ibuff++ = ')';
  2543.           #endif
  2544.         }
  2545.     }
  2546.   if (dbit == 0 || dbit == 244 || dbit == 247 || dbit == 248)
  2547.     {
  2548.                                         /* register is second operand - print
  2549.                                            register name                      */
  2550.       *ibuff++ = ',';
  2551.       segsflag = segrflag;
  2552.       prt8reg16(regf);
  2553.       segrflag = 0;
  2554.     }
  2555.   if (dbit == 252)
  2556.     {
  2557.                                         /* second operand is "1" (for shifts) */
  2558.       *ibuff++ = ',';
  2559.       *ibuff++ = '1';
  2560.     }
  2561.   if (dbit == 253 || dbit == 248)
  2562.     {
  2563.                                         /* second (or third) operand is "CL"
  2564.                                            (for shifts)                       */
  2565.       *ibuff++ = ',';
  2566.       ibuff = printitem((ULONG)1,reg8,ibuff);
  2567.     }
  2568.   if (dbit == 250 || dbit == 247)
  2569.     {
  2570.                                         /* shift n instruction                */
  2571.       wbit = 0;                         /* force to 8-bit operand             */
  2572.       dbit = 255;                       /* so it prints immediate operand     */
  2573.     }
  2574.   if (dbit == 255)
  2575.     {
  2576.                                         /* second operand is an immediate
  2577.                                            operand                            */
  2578.       prtimmed();    }
  2579.   if ((instr & 0xFD) == 0x69)
  2580.     prtimmed();                         /* print 3rd (immediate)
  2581.                                            operand for MSI                    */
  2582.   ovseg = 0;
  2583.   goto exit;
  2584.                                         /* 8F                                 */
  2585. mempopop:                               /* pop memory location (reg field = 0
  2586.                                            only - others are illegal          */
  2587.   setrm();
  2588.   dbit = 254;                           /* no register operand                */
  2589.   wbit = 1;                             /* force a word operation             */
  2590.   if (regf != 0)
  2591.     goto illegop;
  2592.   if (mod == 3)
  2593.     printmnem(popmnem);
  2594.   else
  2595.     {
  2596.       if (opsize32)
  2597.         printmnem(popmnem_32);
  2598.       else
  2599.         printmnem(popmnem_16);
  2600.     }
  2601.   goto memop0;
  2602.                                         /* 8C, 8E                             */
  2603. memsegop:                               /* load or store a segment register
  2604.                                            from or to memory or another
  2605.                                            register                           */
  2606.   setrm();
  2607.   if (regf > 5)
  2608.     goto illegop;
  2609.   #if defined(_ASM86_)
  2610.     if (!masm && mod != 3)
  2611.       {
  2612.                                         /* for operands to store, the register
  2613.                                            is always the first
  2614.                                            operand for ASM/86 format          */
  2615.         dbit = 2;
  2616.       }
  2617.     else
  2618.       {
  2619.   #endif
  2620.   dbit = (UCHAR)((instr & 2));
  2621.   #if defined(_ASM86_)
  2622.       }
  2623.   #endif
  2624.   wbit = 1;                             /* force to a word operand            */
  2625.   segrflag = 1;
  2626.   #if defined(_ASM86_)
  2627.     if (masm)
  2628.   #endif
  2629.       printmnem(movmnem);
  2630.   #if defined(_ASM86_)
  2631.     else
  2632.       {
  2633.         if (instr == 0x8E || mod == 3)
  2634.           printmnem(lmnem);
  2635.         else
  2636.           printmnem(stmnem);
  2637.       }
  2638.   #endif
  2639.  
  2640.   opsize32 = 0;                         /* these are always 16-bit operations */
  2641.   parm->retbits &= 0xFE;                /* clear reply 32-bit marker          */
  2642.   goto memop0;
  2643.                                         /* 6B                                 */
  2644. MSIop2:                                 /* multiply immediate, sign extended
  2645.                                            byte operand                       */
  2646.   signext = 1;                          /* sign extended                      */
  2647.                                         /* 69                                 */
  2648. MSIop:                                  /* multiply immediate, 16-bit operand */
  2649.   dbit = 2;                             /* register is first operand          */
  2650.   wbit = 1;                             /* word operation                     */
  2651.   setrm();
  2652.   goto memop0;
  2653.                                         /* C6, C7                             */
  2654. MVImemop:                               /* store immediate operations
  2655.                                            (regf = 0 only - others are illegal*/
  2656.   setrm();
  2657.   setdw();
  2658.   dbit = 255;                           /* immediate operand                  */
  2659.   if (regf != 0)
  2660.     goto illegop;
  2661.   #if defined(_ASM86_)
  2662.     if (masm)
  2663.   #endif
  2664.       printmnem(movmnem);
  2665.   #if defined(_ASM86_)
  2666.     else
  2667.       {
  2668.         if (mod == 3)                   /* it actually is a LI instruction,
  2669.                                            although this is not the best way of
  2670.                                            encoding this                      */
  2671.           printmnem(mnemC6C7[2]);
  2672.         else
  2673.           printmnem(mnemC6C7[wbit]);
  2674.       }
  2675.   #endif
  2676.   goto memop0;
  2677.                                         /* 67                                 */
  2678. overaddr:                               /* single byte address size override
  2679.                                            prefix                             */
  2680.   addrover = 1;                         /* note we have had this              */
  2681.   goto restart;
  2682.                                         /* 66                                 */
  2683. overoper:                               /* single byte operand size override
  2684.                                            prefix                             */
  2685.   opsizeover = 1;                       /* note we have had this              */
  2686.   goto restart;
  2687.                                         /* 6A                                 */
  2688. pushiop2:                               /* push immediate, sign extended byte
  2689.                                            operand                            */
  2690.   signext = 1;                          /* sign extended                      */
  2691.                                         /* 68                                 */
  2692. pushiop:                                /* push immediate, word operand       */
  2693.   wbit = 1;                             /* always a word operation            */
  2694.   nocomma = 1;                          /* no leading comma for operand field */
  2695.   prtimmed();
  2696.   goto exit;
  2697.                                         /* 40 - 4F, 50 - 5F                   */
  2698. reg16op:                                /* single byte 16-bit register orders */
  2699.   regf = (UCHAR)(instr & 0x07);         /* get register number                */
  2700.   wbit = 1;                             /* force 16 or 32 bit register        */
  2701.   prt8reg16(regf);
  2702.   goto exit;
  2703.                                         /* B0 - BF                            */
  2704. regimop:                                /* MOV immediate to 8/16 bit register */
  2705.   wbit = (UCHAR)(instr & 0x08);         /* get 8/16 bit operation marker      */
  2706.   regf = (UCHAR)(instr & 0x07);         /* get register number                */
  2707.   goto aregiml1;
  2708.                                         /* F2, F3                             */
  2709. repop:                                  /* single byte REP, REPZ, REPNZ orders*/
  2710.   f1 = 0;
  2711.   ic = *(parm->iptr);                   /* do not increment pointer since we
  2712.                                            wish to access the same instruction
  2713.                                            byte next time                     */
  2714.   if ((ic & 0xF6) == 0xA6)
  2715.     {
  2716.                                         /* the next instruction is scan or
  2717.                                            compare string order - hence this
  2718.                                            is a REPZ/REPNZ rather than just
  2719.                                            REP                                */
  2720.       f1 = (instr & 1) + 1;
  2721.     }
  2722.   printmnem(repmnem[f1]);
  2723.   parm->rettype = reptype;              /* add rettype for REP            1.01*/
  2724.   goto exit;
  2725.                                         /* C2, CA                             */
  2726. retop:                                  /* RET n instructions                 */
  2727.   prtword();
  2728.  
  2729.   #if defined(_ASM86_)
  2730.     if (!masm)
  2731.       {
  2732.         *ibuff++ = 'X';
  2733.         *ibuff++ = '\'';
  2734.         quoteflag = 1;
  2735.       }
  2736.   #endif
  2737.   ibuff = hexword(f1,ibuff);
  2738.   #if defined(_ASM86_)
  2739.     if (masm)
  2740.   #endif
  2741.       *ibuff++ = 'H';
  2742.   #if defined(_ASM86_)
  2743.     else
  2744.       {
  2745.         if (quoteflag) *ibuff++ = '\'';
  2746.       }
  2747.   #endif
  2748.   parm->retoffset = f1;
  2749.   if (instr == 0xC2  )                  /* RET                                */
  2750.     parm->rettype = retneartype;
  2751.   else
  2752.                                         /* assume instr = 0xCA - RETF/RET     */
  2753.     parm->rettype = retfartype;
  2754.   goto exit;
  2755.                                         /* C3                                 */
  2756. ret0op:                                 /* RET  instruction                   */
  2757.   parm->rettype = retneartype;
  2758.   parm->retoffset = 0;                  /* it is RET 0                        */
  2759.   goto exit;
  2760.                                         /* CB                                 */
  2761. retfop:                                 /* RETF  instruction                  */
  2762.   parm->rettype = retfartype;
  2763.   parm->retoffset = 0;                  /* it is RETF 0                       */
  2764.   goto exit;
  2765.                                         /* 06, 07, 0E, 16, 17, 1E, 1F         */
  2766. segop:                                  /* single byte segment register
  2767.                                            instructions                       */
  2768.   f1 = (ULONG)(instr & 0x18) >> 3;      /* get register number                */
  2769. segop_1:                                /* added ulong cast to above st    521*/
  2770.   segsflag = 1;                         /* so it prints segment register      */
  2771.   prt8reg16((UCHAR)f1);
  2772.   goto exit;
  2773.                                         /* 64, 65                             */
  2774. segovfsgs:                              /* single byte segment override
  2775.                                            instructions                       */
  2776.   if (ovseg != 0)
  2777.     goto exit;                          /* trap SEGOV on SEGOV                */
  2778.   ovseg = (UCHAR)(instr - 0x5F);        /* get register number                */
  2779.   goto restart;
  2780.                                         /* 26, 2E, 36, 3E                     */
  2781. segovop:                                /* single byte segment override
  2782.                                            instructions                       */
  2783.   if (ovseg != 0)
  2784.     goto exit;                          /* trap SEGOV on SEGOV                */
  2785.   ovseg = (UCHAR)(((UCHAR)(instr & 0x18) >> 3) + 1); /* get register number - +1
  2786.                                            since 0 signifies no extant
  2787.                                            override                           */
  2788.   goto restart;                         /* added uchar cast to above st    521*/
  2789.                                         /* D0 - D3, C0,  C1                   */
  2790. shiftop:                                /* shift (rotate) operations          */
  2791.   setdw();
  2792.   setrm();
  2793.   if (regf == 6)
  2794.     goto illegop;
  2795.   if (dbit == 0)
  2796.     dbit = 252;
  2797.   else
  2798.     dbit = 253;                         /* distinguish "1" and "CL" cases     */
  2799.   if (instr == 0xC0 || instr == 0xC1)
  2800.     dbit = 250;                         /* special case - shift n             */
  2801.   f2 = regf * 3;
  2802.   if (mod != 3)
  2803.     {
  2804.                                         /* it is a memory operand  */
  2805.       f2 = f2 + 1 + wbit;
  2806.     }
  2807.   printmnem(shiftmnem[f2]);
  2808.   goto memop0;
  2809.                                         /* AA, AB, AE, AF                     */
  2810.  
  2811. stoscanop:                              /* store and scan string orders       */
  2812.   if (ovseg == 0)
  2813.     parm->retreg = 1;                   /* ES                                 */
  2814.   else
  2815.     parm->retreg = ovseg;
  2816.   if (addr32)
  2817.     parm->retbase = 15;                 /* EDI                                */
  2818.   else
  2819.     parm->retbase = 7;                  /* DI                                 */
  2820. stscl1:
  2821.   setdw();
  2822.   if (wbit == 0)
  2823.     parm->rettype = strbtype;
  2824.   else
  2825.     parm->rettype = strwtype;
  2826.   goto exit;
  2827.                                         /* D7                                 */
  2828. xlatop:                                 /* XLAT instruction                   */
  2829.   if (ovseg == 0)
  2830.     parm->retreg = defseg;
  2831.   else
  2832.     parm->retreg = ovseg;
  2833.   if (addr32)
  2834.     parm->retbase = 11;                 /* EBX                                */
  2835.   else
  2836.   parm->retbase = 3;                    /* BX                                 */
  2837.   parm->rettype = xlattype;
  2838.   goto exit;
  2839.                                         /* 0F - two-byte opcodes              */
  2840. zerofop:
  2841.   prtbyte();                            /* get the second byte of the instr   */
  2842.   if (mnem0F[ic] != odd)
  2843.     {
  2844.                                         /* in many cases we can print the
  2845.                                            instruction mnemonic now           */
  2846.       printmnem(mnem0F[ic]);
  2847.     }
  2848.   switch (ic)
  2849.     {
  2850.       case   0:  goto zerof00;          /*  00                                */
  2851.       case   1:  goto zerof01;          /*  01                                */
  2852.       case   2:
  2853.       case   3:  goto LARop;            /*  02,03                             */
  2854.       case   4:
  2855.       case   5:  goto illegop;          /*  04,05                             */
  2856.       case   6:  goto nulop;            /*  06                                */
  2857.       case   7:  goto illegop;          /*  07                                */
  2858.       case   8:
  2859.       case   9:  goto nulop;            /*  08,09                             */
  2860.       case  32:  goto zerof20;          /*  20                                */
  2861.       case  33:  goto zerof21;          /*  21                                */
  2862.       case  34:  goto zerof22;          /*  22                                */
  2863.       case  35:  goto zerof23;          /*  23                                */
  2864.       case  36:  goto zerof24;          /*  24                                */
  2865.       case  37:  goto illegop;          /*  25                                */
  2866.       case  38:  goto zerof26;          /*  26                                */
  2867.       case 128:
  2868.       case 129:
  2869.       case 130:
  2870.       case 131:
  2871.       case 132:
  2872.       case 133:
  2873.       case 134:
  2874.       case 135:
  2875.       case 136:
  2876.       case 137:
  2877.       case 138:
  2878.       case 139:
  2879.       case 140:
  2880.       case 141:
  2881.       case 142:
  2882.       case 143:  goto jfulldispop;      /*  80-8F                             */
  2883.       case 144:
  2884.       case 145:
  2885.       case 146:
  2886.       case 147:
  2887.       case 148:
  2888.       case 149:
  2889.       case 150:
  2890.       case 151:
  2891.       case 152:
  2892.       case 153:
  2893.       case 154:
  2894.       case 155:
  2895.       case 156:
  2896.       case 157:
  2897.       case 158:
  2898.       case 159:  goto zerof90;          /*  90-9F                             */
  2899.       case 160:
  2900.       case 161:  goto zerofA0;          /*  A0,A1                             */
  2901.       case 162:  goto illegop;          /*  A2                                */
  2902.       case 163:  goto zerofA3;          /*  A3                                */
  2903.       case 164:
  2904.       case 165:  goto zerofA4;          /*  A4,A5                             */
  2905.       case 166:
  2906.       case 167:  goto zerofA6;          /*  A6,A7                             */
  2907.       case 168:
  2908.       case 169:  goto zerofA8;          /*  A8,A9                             */
  2909.       case 170:  goto illegop;          /*  AA                                */
  2910.       case 171:  goto zerofA3;          /*  AB                                */
  2911.       case 172:
  2912.       case 173:  goto zerofA4;          /*  AC,AD                             */
  2913.       case 174:  goto illegop;          /*  AE                                */
  2914.       case 175:  goto MSIop;            /*  AF                                */
  2915.       case 176:
  2916.       case 177:  goto illegop;          /*  B0,B1                             */
  2917.       case 178:  goto laddrop;          /*  B2                                */
  2918.       case 179:  goto zerofA3;          /*  B3                                */
  2919.       case 180:
  2920.       case 181:  goto laddrop;          /*  B4,B5                             */
  2921.       case 182:  goto zerofB6;          /*  B6                                */
  2922.       case 183:  goto zerofB7;          /*  B7                                */
  2923.       case 184:
  2924.       case 185:  goto illegop;          /*  B8,B9                             */
  2925.       case 186:  goto zerofBA;          /*  BA                                */
  2926.       case 187:  goto zerofA3;          /*  BB                                */
  2927.       case 188:
  2928.       case 189:  goto MSIop;            /*  BC,BD                             */
  2929.       case 190:  goto zerofBE;          /*  BE                                */
  2930.       case 191:  goto zerofBF;          /*  BF                                */
  2931.       case 192:
  2932.       case 193:  goto zerofA6;          /*  C0,C1                             */
  2933.       case 194:
  2934.       case 195:
  2935.       case 196:
  2936.       case 197:
  2937.       case 198:
  2938.       case 199:  goto illegop;          /*  C2-C7                             */
  2939.       case 200:
  2940.       case 201:
  2941.       case 202:
  2942.       case 203:
  2943.       case 204:
  2944.       case 205:
  2945.       case 206:
  2946.       case 207:  goto zerofC8;          /*  C8-CF                             */
  2947.  
  2948.       default:   goto illegop;          /*  0A-1F                             */
  2949.                                         /*  27-7F                             */
  2950.                                         /*  D0-FF                             */
  2951.     }
  2952.                                         /* 0F 00                              */
  2953. zerof00:
  2954.   dbit = 249;                           /* no register operand                */
  2955.   wbit = 1;                             /* word operation                     */
  2956.   setrm();
  2957.   if (regf > 5) goto illegop;
  2958.   opsize32 = 0;                         /* this is always a 16-bit operation  */
  2959.   parm->retbits &= 0xFE;
  2960.   printmnem(mnem0F00[regf]);
  2961.   goto memop0;
  2962.                                         /* 0F 01                              */
  2963. zerof01:
  2964.   dbit = 249;                           /* no register operand                */
  2965.   wbit = 1;                             /* word operation                     */
  2966.   setrm();
  2967.   if (regf == 5)
  2968.     goto illegop;
  2969.   if (regf == 7 && mod == 3)
  2970.     goto illegop;
  2971.   if (regf < 4 && mod == 3)
  2972.     goto illegop;
  2973.   if (regf == 4 || regf == 6)
  2974.     {
  2975.                                         /* this is always a 16-bit operation  */
  2976.       opsize32 = 0;
  2977.       parm->retbits &= 0xFE;
  2978.     }
  2979.   printmnem(mnem0F01[regf]);
  2980.   if (regf < 4)
  2981.     parm->rettype = LGDTtype;
  2982.   goto memop0;
  2983.                                         /* 0F 22                              */
  2984. zerof22:
  2985.   dbit = 2;                             /* GP register is first operand       */
  2986.                                         /* 0F 20                              */
  2987. zerof20:                                /* in this case, r1 initialise dbit
  2988.                                            to 0 (GP register is second operand)
  2989.                                                                               */
  2990.   prtbyte();                            /* get the third byte of the instr    */
  2991.   if ((ic >> 6) != 3)
  2992.     goto illegop;
  2993.   regf = (UCHAR)(ic & 7);
  2994.   eee = (UCHAR)((ic >> 3) & 7);
  2995.   if (eee == 1 || eee > 3)
  2996.     goto illegop;
  2997. zerof20_2:
  2998.   printmnem(lmnem);
  2999.   if (dbit == 2)
  3000.     {
  3001.                                         /* register is first operand - print
  3002.                                            register name                      */
  3003.       ibuff = printitem((ULONG)regf,reg32,ibuff);
  3004.       *ibuff++ = ',';
  3005.     }
  3006.   ibuff = printitem((ULONG)eee,specialreg,ibuff);
  3007.   if (dbit == 0)
  3008.     {
  3009.                                         /* register is second operand - print
  3010.                                            register name                      */
  3011.       *ibuff++ = ',';
  3012.       ibuff = printitem((ULONG)regf,reg32,ibuff);
  3013.     }
  3014.   goto exit;
  3015.                                         /* 0F 23                              */
  3016. zerof23:
  3017.   dbit = 2;                             /* GP register is first operand       */
  3018.                                         /* 0F 21                              */
  3019. zerof21:                                /* in this case, r1 initialise dbit to 0
  3020.                                            (GP register is second operand)    */
  3021.   prtbyte();                            /* get the third byte of the instr    */
  3022.   if ((ic >> 6) != 3)
  3023.     goto illegop;
  3024.   regf = (UCHAR)(ic & 7);
  3025.   eee = (UCHAR)((ic >> 3) & 7);
  3026.   if ((eee == 4) | (eee == 5))
  3027.     goto illegop;
  3028.   eee += 4;                             /* 0-3 are CRn, DR0 follows           */
  3029.   goto zerof20_2;
  3030.                                         /* 0F 26                              */
  3031. zerof26:
  3032.   dbit = 2;                             /* GP register is first operand       */
  3033.                                         /* 0F 24                              */
  3034. zerof24:                                /* in this case, r1 initialise dbit to 0
  3035.                                            (GP register is second operand)    */
  3036.   prtbyte();                            /* get the third byte of the instr    */
  3037.   if ((ic >> 6) != 3)
  3038.     goto illegop;
  3039.   regf = (UCHAR)(ic & 7);
  3040.   eee = (UCHAR)((ic >> 3) & 7);
  3041.   if ((eee != 6) & (eee != 7))
  3042.     goto illegop;
  3043.   eee += 6;                             /* 0-3 are CRn, 4-12 are DRn, and TR6,
  3044.                                            TR7 follow (TR0-TR5 are omitted)   */
  3045.   goto zerof20_2;
  3046.                                         /* 0F 90                              */
  3047. zerof90:
  3048.   dbit = 254;                           /* there is only 1 operand            */
  3049.   wbit = 0;                             /* these are always byte operands     */
  3050.   setrm();
  3051.   goto memop0;
  3052.                                         /* 0F A0,A1                           */
  3053. zerofA0:
  3054.   f1 = 4;                               /* register is FS                     */
  3055.   goto segop_1;
  3056.                                         /* 0F A3,B3,AB,BB                     */
  3057. zerofA3:
  3058.   dbit = 244;
  3059.   wbit = 1;
  3060.   setrm();
  3061.   goto memop0;
  3062.                                         /* 0F A4,A5,AC,AD                     */
  3063. zerofA4:
  3064.   dbit = (UCHAR)((ic & 1) + 247);       /* this gives 247 for immediate
  3065.                                            operand, 248 for CL                */
  3066.   wbit = 1;
  3067.   setrm();
  3068.   goto memop0;
  3069.                                         /* 0F A6,A7, 0F C0,C1                 */
  3070. zerofA6:                                /* special 486 instructions           */
  3071.   dbit = 0;
  3072.   wbit = (UCHAR)(ic & 1);
  3073.   setrm();
  3074.   goto memop0;
  3075.                                         /* 0F A8,A9                           */
  3076. zerofA8:                                /* special 386 instructions           */
  3077.   f1 = 5;                               /* register is GS                     */
  3078.   goto segop_1;
  3079.                                         /* 0F B6                              */
  3080. zerofB6:
  3081.   dbit = 246;                           /* always a byte operation            */
  3082.   setrm();
  3083.   if (mod != 3)
  3084.     parm->rettype = membtype;
  3085.  
  3086. zerofB6_1:
  3087.   parm->retbits &= 0xFE;
  3088.  
  3089.   #if defined(_ASM86_)
  3090.     if (!masm)
  3091.       {
  3092.                                         /* for ASM case, output mnemonic      */
  3093.         if (mod == 3)
  3094.           f1 = 2;
  3095.         else
  3096.           f1 = (dbit & 1);
  3097.         printmnem(a86mnem0FB6[f1]);
  3098.       }
  3099.   #endif
  3100.   goto memop0;
  3101.                                         /* 0F B7                              */
  3102. zerofB7:
  3103.   dbit = 245;                           /* a word operation                   */
  3104.   opsize32 = 1;                         /* always a 32-bit register           */
  3105.   setrm();
  3106.   if (mod != 3)
  3107.     parm->rettype = memwtype;
  3108.   goto zerofB6_1;
  3109.                                         /* 0F BA                              */
  3110. zerofBA:
  3111.   dbit = 250;                           /* always an 8-bit immediate operand  */
  3112.   wbit = 1;                             /* always a word/dword operation      */
  3113.   setrm();
  3114.   if (regf < 4)
  3115.     goto illegop;
  3116.   printmnem(mnem0FBA[regf-4]);
  3117.   goto memop0;
  3118.                                         /* 0F BE                              */
  3119. zerofBE:
  3120.   dbit = 246;                           /* always a byte operation            */
  3121.   setrm();
  3122.   if (mod != 3)
  3123.     parm->rettype = membtype;
  3124.  
  3125. zerofBE_1:
  3126.   parm->retbits &= 0xFE;
  3127.   #if defined(_ASM86_)
  3128.     if (!masm)
  3129.       {
  3130.                                         /* for ASM case, output mnemonic      */
  3131.         if (mod == 3)
  3132.           f1 = 2;
  3133.         else
  3134.           f1 = (dbit & 1);
  3135.         printmnem(a86mnem0FBE[f1]);
  3136.       }
  3137.   #endif
  3138.   goto memop0;
  3139.                                         /* 0F BF                              */
  3140.  
  3141. zerofBF:
  3142.   dbit = 245;                           /* a word operation/                  */
  3143.   opsize32 = 1;                         /* always a 32-bit register           */
  3144.   setrm();
  3145.   if (mod != 3)
  3146.     parm->rettype = memwtype;
  3147.   goto zerofBE_1;
  3148.                                         /* 0F C8 - 0F CF                      */
  3149. zerofC8:
  3150.   dbit = 245;                           /* a word operation                   */
  3151.   if (opsize32 != 1)
  3152.     goto illegop;                       /* always a 32-bit register           */
  3153.   printmnem(bswapmnem);
  3154.   regf = (UCHAR)(ic & 0x07);            /* get register number                */
  3155.   wbit = 1;                             /* force 16 or 32 bit register        */
  3156.   prt8reg16(regf);
  3157.   goto exit;
  3158.                                         /* 27, 2F
  3159.                                            37, 3F
  3160.                                            90, 98, 99, 9B - 9F
  3161.                                            A4 - A7
  3162.                                            F0, F4, F5, F8 - FD                */
  3163.  
  3164. nulop:                                  /* single byte instructions with no
  3165.                                            operands                           */
  3166.                                         /* drop throught to exit              */
  3167. /******************************************************************************/
  3168. /****************************** RETURN ****************************************/
  3169. /******************************************************************************/
  3170.  
  3171. exit:
  3172.   if (ovseg)
  3173.     {
  3174.                                         /* we had a segment override instruction
  3175.                                            which was not required - back track,
  3176.                                            and reply with that instead        */
  3177.       parm->iptr = startiptr;
  3178.       r1();
  3179.       prtbyte();                        /* get next byte of instruction       */
  3180.       instr = ic;
  3181.       printmnem(segovmnem);
  3182.                                         /* SEGOV or SEG                       */
  3183.       ibuff = printitem((ULONG)(ovseg-1),segreg,ibuff);
  3184.       parm->rettype = segovtype;
  3185.       parm->retreg = ovseg;
  3186.     }
  3187.  
  3188.                                         /* return updated buffer pointers     */
  3189.  
  3190.   parm->retleng = (UCHAR)(parm->iptr - startiptr);
  3191.   *mbuff = 0;
  3192.   parm->mbuffer = mbuff;
  3193.   if (hbuff)
  3194.     {
  3195.       *hbuff = 0;
  3196.       parm->hbuffer = hbuff;
  3197.     }
  3198.   *ibuff = 0;
  3199.   parm->ibuffer = ibuff;
  3200.   return;
  3201. }
  3202.