home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sd386v50.zip / sd386src.zip / PRNTSYMS.C < prev    next >
Text File  |  1993-05-21  |  28KB  |  743 lines

  1. /****** PrtHLSym *************************************************************/
  2. /*                                                                           */
  3. /*  Description:                                                             */
  4. /*      print to output stream                                               */
  5. /*                                                                           */
  6. /*  Parameters:                                                              */
  7. /*                                                                           */
  8. /*  Returns:                                                                 */
  9. /*      void                                                                 */
  10. /*                                                                           */
  11. /*  Global Data:                                                             */
  12. /*      o - options specified by user                                        */
  13. /*                                                                           */
  14. /*****************************************************************************/
  15. #include "prntsyms.h"
  16.  
  17. void PrtHLSym(UCHAR *, UCHAR * );
  18. FILE *ostream;                         /* text-style output                  */
  19. ULONG  bugpos = 0;                     /* offset into exe of debug info      */
  20. ULONG  currpos = 0;                    /* file ptr of item being displayed   */
  21. extern void   dumptext( char *, UINT);
  22.  
  23. typedef union                          /* input options from user            */
  24.   {                                    /* what to display                    */
  25.     struct                             /* if bit set then show it            */
  26.     {
  27.        UINT h :1;                       /* header (t.o.c.)                    */
  28.        UINT f :1;                       /* files & libs                       */
  29.        UINT p :1;                       /* pubs                               */
  30.        UINT t :1;                       /* types                              */
  31.        UINT s :1;                       /* symbols                            */
  32.        UINT y :1;                       /* symbols - old format               */
  33.        UINT l :1;                       /* line nums                          */
  34.        UINT x :1;                       /* hex output                     1.01*/
  35.        UINT q :1;                       /* dump debug info stats              */
  36.        UINT o :1;                       /* option specified                   */
  37.        UINT z :1;                       /* invalid option                     */
  38.     } opt;
  39.     UINT  w;
  40.   } options;
  41.        options o;                      /* input options from user            */
  42.  
  43. void PrtHLSym(UCHAR *TempBufPtr, UCHAR *TempBufEnd)
  44. {
  45.   UCHAR  *p, *pend, Type;
  46.   UINT    n, i;
  47.   ULONG   prevn;
  48.   ULONG   thisoff;
  49.   UINT    totn;                        /* total number of bytes in rec   1.01*/
  50.   UINT    RecordLen;
  51.  
  52.  
  53.   o.opt.y = 0;
  54.   o.opt.x = 0;
  55.   ostream = fopen( "symbols.dmp", "a" );
  56.   fprintf(ostream, "\n\nSymbolic information\n");
  57.   fprintf(ostream, "====================\n");
  58.           fprintf(ostream,
  59.             "  Offset           Rec/Frame                     Reg/  Relative   \n");
  60.           fprintf(ostream,
  61.             " in File  Record  Offset/Addr  Type Index   Len  Seg    Offset    \n");
  62.           fprintf(ostream,
  63.             "   (0x)    Type      (0x)       Dec  (Hex)  (0x) Num  Body Epilog Name\n");
  64.           fprintf(ostream,
  65.             " ======== ======= ============ ============ ==== ==== =========== ============\n");
  66.  
  67.   n = 0;
  68.   prevn = 0;
  69.   while (TempBufPtr < TempBufEnd)
  70.     {
  71.       RecordLen = 2;    /* xxx */
  72.       fprintf(ostream,"\n");
  73.  
  74.       /*
  75.       ** setup record len
  76.       ** setup pointer to record beginning
  77.       ** setup pointer to record end
  78.       ** setup offset of this record in file
  79.       */
  80.       p = TempBufPtr + 2; /* xxx */
  81.       n = *(USHORT*)TempBufPtr;   /* xxx */
  82.  
  83.  
  84.       totn = n;
  85.       pend = p + n;
  86.  
  87.       thisoff = currpos + bugpos + prevn;
  88.  
  89.       /*
  90.       ** get symbol type
  91.       ** point to symbol information
  92.       */
  93.       Type = *(p);
  94.       p += 1;
  95.  
  96.       /*
  97.       ** make sure we don't have a record that exceeds what we're supposed
  98.       ** to display.  If so, then dump the rest of the symbol information.
  99.       */
  100.       if (pend > TempBufEnd)
  101.         {
  102.           fprintf(ostream, " ");
  103.           dumptext(TempBufPtr, TempBufEnd-TempBufPtr);
  104.           fprintf(ostream, "\n");
  105.           fclose( ostream );
  106.           return;
  107.         }
  108.  
  109.       /* check for symbol in the table, if we find it then print symbol name */
  110.       for (i=0; i<NoOfHLSRecs; i++)
  111.         {
  112.           if (Type == recordsym[i].code)
  113.             {
  114.               if (o.opt.y)             /* straight format                   */
  115.                 fprintf(ostream, "  %s:", recordsym[i].name);
  116.               break;
  117.             }
  118.         }
  119.  
  120.       /* check to see if didn't find the symbol in the table */
  121.       if (i == NoOfHLSRecs)
  122.         {
  123.           /* don't know what to do, so dump whole record */
  124.           fprintf(ostream, " ");
  125.           dumptext(TempBufPtr, pend-TempBufPtr);
  126.           goto SkipSymRecord;
  127.         }
  128.  
  129.  
  130.       /* determine which symbol record we got */
  131.       switch (Type)
  132.         {
  133.           case SSBEGIN:                /* begin                              */
  134.             {
  135.               SSBegin  *bp;
  136.  
  137.               /* check to see we have a valid record */
  138.               if (n < sizeof(SSBegin) - 2) /* xxx */
  139.                 goto DumpSymRecord;
  140.  
  141.               /* display the record */
  142.               bp = (SSBegin *)(TempBufPtr);/* xxx */
  143.               if (o.opt.y)             /* straight format                    */
  144.                 {
  145.                   fprintf(ostream, " Offset=%lu  Bytes=%lu  Name=", bp->BlockOffset,
  146.                     bp->BlockLen);
  147.                 }
  148.               else                     /* columnar format                    */
  149.                 {
  150.                   fprintf(ostream,
  151.                     " %s  Begin     %.8X               ",
  152.                     "        ", bp->BlockOffset);
  153.                   fprintf(ostream,
  154.                     "%.4X",
  155.                     (USHORT)bp->BlockLen);
  156.                   fprintf(ostream, "                  ");
  157.                 }
  158.  
  159.               p = pend;
  160.               break;
  161.             }
  162.           case SSPROC:                 /* procedure                          */
  163.             {
  164.               SSProc  *pp;
  165.               USHORT     nlen;
  166.               USHORT     nbytes = 0;
  167. /* xxx        USHORT     nbytes = 1; */
  168.  
  169.               /* check to see we have a valid record */
  170.               if (n < sizeof(SSProc)-2 ) /* xxx */
  171.                 goto DumpSymRecord;
  172.  
  173.               /* display the record */
  174.               pp = (SSProc *)(TempBufPtr);
  175. /* xxx        pp = (SSProc *)(TempBufPtr + RecordLen); */
  176.               if (o.opt.y)             /* straight format                    */
  177.                 {
  178.                   fprintf(ostream,
  179.                     " Offset=%lu  Type=%u (0x%.4X)  Bytes=%lu\n",
  180.                     pp->ProcOffset, pp->TypeIndex, pp->TypeIndex, pp->ProcLen);
  181.                   fprintf(ostream,
  182.                     "              BodyOff=%u  EpilogOff=%u  Name=",
  183.                     pp->DebugStart, pp->DebugEnd);
  184.                 }
  185.               else                     /* columnar format                    */
  186.                 {
  187.                   if( pp->Flags == MEMBERFUNC )
  188.                   {
  189.                     fprintf(ostream,
  190.                       " %s  MemFcn    %.8lX   %4u (%.4X) ",
  191.                       "        ", pp->ProcOffset, pp->TypeIndex, pp->TypeIndex);
  192.                     fprintf(ostream,
  193.                       "%.4X      %.4X   ",
  194.                       (ushort)pp->ProcLen, pp->DebugStart);
  195.                     fprintf(ostream,
  196.                       "%.4X ",
  197.                       (ushort)pp->DebugEnd);
  198.                   }
  199.                   else
  200.                   {
  201.                     fprintf(ostream,
  202.                       " %s  Proc      %.8lX   %4u (%.4X) ",
  203.                       "        ", pp->ProcOffset, pp->TypeIndex, pp->TypeIndex);
  204.                     fprintf(ostream,
  205.                       "%.4X      %.4X   ",
  206.                       (USHORT)pp->ProcLen, pp->DebugStart);
  207.                     fprintf(ostream,
  208.                       "%.4X ",
  209.                       (USHORT)pp->DebugEnd);
  210.                   }
  211.                 }
  212.  
  213.               /* check to see name doesn't exceed record length */
  214.               p = pp->Name;
  215.               nlen = pp->NameLen;
  216. /* xxx        nlen = *p; */
  217.  
  218.               if (p + nlen + nbytes > pend)
  219.                 goto DumpSymRecord;
  220.  
  221.               /* check to see if we have a name */
  222.               if (nlen)
  223.                 {
  224.  
  225.                   if (nlen <= MAXNAMELEN)
  226.                     fprintf(ostream, "%.*s", nlen, p+nbytes);
  227.                   else
  228.                     fprintf(ostream, "%.*s", MAXNAMELEN, p+nbytes);
  229.                 }
  230.  
  231.               if (!o.opt.y && pp->Flags == MEMBERFUNC )
  232.                 {
  233.                   fprintf(ostream,
  234.                     "\n                                %4u (%.4X)",
  235.                     pp->ClassType, pp->ClassType);
  236.                 }
  237.  
  238.               p = pend;
  239.               break;
  240.             }
  241.           case SSEND:                /* end                                */
  242.             {
  243.               SSEnd  *ep;
  244.  
  245.               /* check to see we have a valid record */
  246.               if (n < sizeof(SSEnd) - 2 ) /* xxx */
  247.                 break;
  248.  
  249.               /* display the record */
  250.               ep = (SSEnd *)(TempBufPtr); /* xxx */
  251.               if (!o.opt.y)            /* columnar format                    */
  252.                 fprintf(ostream, " %s  End  ", "        " );
  253.  
  254.               p = pend;
  255.               break;
  256.             }
  257.           case SSDEF:               /* automatic variable                 */
  258.             {
  259.               SSDef  *ap;
  260.  
  261.               /* check to see we have a valid record */
  262.               if (n < sizeof(SSDef) - 2 ) /* xxx */
  263.                 goto DumpSymRecord;
  264.  
  265.               /* display the record */
  266.               ap = (SSDef *)(TempBufPtr); /* xxx */
  267.               if (o.opt.y)             /* straight format                    */
  268.                 {
  269.                   fprintf(ostream, " FrameOff=%ld  Type=%u (0x%.4X)  Name=",
  270.                     ap->FrameOffset, ap->TypeIndex, ap->TypeIndex);
  271.                 }
  272.               else                     /* columnar format                    */
  273.                 {
  274.                   fprintf(ostream,
  275.                     " %s  Auto      %.8lX   %4u (%.4X)",
  276.                     "        ", ap->FrameOffset, ap->TypeIndex, ap->TypeIndex);
  277.                   fprintf(ostream, "                       ");
  278.                 }
  279.  
  280.               /* check to see name doesn't exceed record length */
  281.               p = ap->Name;
  282. /* xxx        if ((p + *p + 1) > pend) */
  283.               if ((p + ap->NameLen ) > pend)
  284.                 goto DumpSymRecord;
  285.  
  286.               if ( (ap->NameLen))
  287.                 {
  288.  
  289.                   if ( (ap->NameLen) <= MAXNAMELEN)
  290.                     fprintf(ostream, "%.*s", (ap->NameLen), (ap->Name));
  291.                   else
  292.                     fprintf(ostream, "%.*s", MAXNAMELEN, (ap->Name));
  293.                 }
  294.  
  295.               p = pend;
  296.               break;
  297.             }
  298.           case SSVAR:             /* static variable                    */
  299.             {
  300.               SSVar  *sp;
  301.               USHORT       nlen;
  302.               USHORT       nbytes = 1;
  303.  
  304.               /* check to see we have a valid record */
  305.               if (n < sizeof(SSVar) - 2 ) /* xxx */
  306.                 goto DumpSymRecord;
  307.  
  308.               /* display the record */
  309.               sp = (SSVar *)(TempBufPtr ); /* xxx */
  310.               if (o.opt.y)             /* straight format                    */
  311.                 {
  312.                   fprintf(ostream, " Addr=%4.4hX:%8.8lX  Type=%u (0x%.4X)  Name=",
  313.                     sp->ObjectNum, sp->Offset, sp->TypeIndex, sp->TypeIndex);
  314.                 }
  315.               else                     /* columnar format                    */
  316.                 {
  317.                   fprintf(ostream,
  318.                     " %s  Static %4.4hX:%8.8lX %4u (%.4X)",
  319.                     "        ", sp->ObjectNum, sp->Offset, sp->TypeIndex,
  320.                     sp->TypeIndex);
  321.                   fprintf(ostream, "                       ");
  322.                 }
  323.  
  324.               /* check to see name doesn't exceed record length */
  325.               p = sp->Name;
  326.               nlen = sp->NameLen;
  327.  
  328.  
  329.               if (p + nlen > pend)
  330.                 goto DumpSymRecord;
  331.  
  332.               /* check to see if we have a name */
  333.               if (nlen)
  334.                 {
  335.  
  336.                   if (nlen <= MAXNAMELEN)
  337.                     fprintf(ostream, "%.*s", nlen, p);
  338.                   else
  339.                     fprintf(ostream, "%.*s", MAXNAMELEN, p);
  340.                 }
  341.  
  342.               p = pend;
  343.               break;
  344.             }
  345.           case SSREG:                /* register variable                  */
  346.             {
  347.               SSReg  *rp;
  348.  
  349.               /* check to see we have a valid record */
  350.               if (n < sizeof(SSReg) - 4 ) /* xxx */
  351.                 goto DumpSymRecord;
  352.  
  353.               /* display the record */
  354.               rp = (SSReg *)(TempBufPtr ); /* xxx */
  355.               if (o.opt.y)             /* straight format                    */
  356.                 {
  357.                   fprintf(ostream, " Type=%u (0x%.4X)  RegNum=",
  358.                     rp->TypeIndex, rp->TypeIndex);
  359.                   PrintRegType(rp->RegNum);
  360.                   fprintf(ostream, "  Name=");
  361.                 }
  362.               else                     /* columnar format                    */
  363.                 {
  364.                   fprintf(ostream,
  365.                     " %s  Reg                  %4u (%.4X)      %.4X",
  366.                     "        ", rp->TypeIndex, rp->TypeIndex, rp->RegNum);
  367.                   fprintf(ostream, "             ");
  368.                 }
  369.  
  370.               /* check to see name doesn't exceed record length */
  371.               p = rp->Name;
  372.               if ((p + rp->NameLen) > pend)
  373.                 goto DumpSymRecord;
  374.  
  375.               /* check to see if we have a name */
  376.               if (rp->NameLen)
  377.                 {
  378.  
  379.                   if (rp->NameLen <= MAXNAMELEN)
  380.                     fprintf(ostream, "%.*s", rp->NameLen, rp->Name);
  381.                   else
  382.                     fprintf(ostream, "%.*s", MAXNAMELEN, rp->Name);
  383.                 }
  384.  
  385.               p = pend;
  386.               break;
  387.             }
  388.           case SSCHGDEF:           /* change default segment          1.04*/
  389.             {
  390.               SSChgDef *cp;
  391.  
  392.               /* check to see if we have a valid record */
  393.               if (n < sizeof(SSChgDef) - 2 ) /* xxx */
  394.                 goto DumpSymRecord;
  395.  
  396.               /* display the record */
  397.               cp = (SSChgDef *)(TempBufPtr );/* xxx */
  398.               if (o.opt.y)             /* straight format                    */
  399.                 {
  400.                   fprintf(ostream, " ChDfSeg: Seg=%u  Reserved=%u",
  401.                     cp->SegNum , cp->Reserved );
  402.                 }
  403.               else                     /* columnar format                    */
  404.                 {
  405.                   fprintf(ostream,
  406.                     " %s  ChDfSeg                               %.4X",
  407.                     "        ", cp->SegNum);
  408.                   fprintf(ostream,
  409.                     "             Reserved=%u",
  410.                     cp->Reserved );
  411.                 }
  412.  
  413.               p = pend;
  414.               break;
  415.             }
  416.           case SSUSERDEF:            /* typedef                            */
  417.             {
  418.               SSUserDef  *tp;
  419.  
  420.               /* check to see we have a valid record */
  421.               if (n < sizeof(SSUserDef) - 2 ) /* xxx */
  422.                 goto DumpSymRecord;
  423.  
  424.               /* display the record */
  425.               tp = (SSUserDef *)(TempBufPtr ); /* xxx */
  426.               if (o.opt.y)             /* straight format                    */
  427.                 {
  428.                   fprintf(ostream, " Type=%u (0x%.4X)  Name=",
  429.                     tp->TypeIndex, tp->TypeIndex);
  430.                 }
  431.               else                     /* columnar format                    */
  432.                 {
  433.                   fprintf(ostream,
  434.                     " %s  TypeDef              %4u (%.4X)",
  435.                     "        ", tp->TypeIndex, tp->TypeIndex);
  436.                   fprintf(ostream, "                       ");
  437.                 }
  438.  
  439.               /* check to see name doesn't exceed record length */
  440.               p = tp->Name;
  441.               if ((p + tp->NameLen) > pend)
  442.                 goto DumpSymRecord;
  443.  
  444.               /* check to see if we have a name */
  445.               if ( (tp->NameLen))
  446.                 {
  447.  
  448.                   if ( (tp->NameLen) <= MAXNAMELEN)
  449.                     fprintf(ostream, "%.*s",  (tp->NameLen), (tp->Name));
  450.                   else
  451.                     fprintf(ostream, "%.*s", MAXNAMELEN, (tp->Name));
  452.                 }
  453.  
  454.               p = pend;
  455.               break;
  456.             }
  457.         }
  458.  
  459. DumpSymRecord:
  460.       if (p < pend)
  461.         {
  462.           fprintf(ostream, " ");
  463.           dumptext(p, pend-p);
  464.         }
  465.       else
  466.         {
  467.           fprintf(ostream, "\n");
  468.           /*
  469.           ** dump record in hex if hex output wanted
  470.           */
  471.           if (o.opt.x)
  472.             {
  473.               if (o.opt.y)
  474.                 {
  475.                   fprintf(ostream, "              ");
  476.                   dumphbuf(TempBufPtr, totn + 1, 14);
  477.                 }
  478.               else
  479.                 {
  480.                   fprintf(ostream, "           ");
  481.                   dumphbuf(TempBufPtr, totn + 1, 11);
  482.                 }
  483.               fprintf(ostream, "\n\n");
  484.             }
  485.  
  486.         }
  487.  
  488. SkipSymRecord:
  489.       prevn = prevn + totn + RecordLen;
  490.       TempBufPtr = (UCHAR *)NextHLSymRec(TempBufPtr);
  491.     }
  492.   fclose( ostream );
  493. }
  494.  
  495. /****** dumptext *************************************************************/
  496. /*                                                                           */
  497. /*  Description:                                                             */
  498. /*                                                                           */
  499. /*  Parameters:                                                              */
  500. /*                                                                           */
  501. /*  Returns:                                                                 */
  502. /*                                                                           */
  503. /*  Global Data:                                                             */
  504. /*                                                                           */
  505. /*****************************************************************************/
  506.  
  507.   void
  508. dumptext (char *p, UINT n)
  509. {
  510.   UINT i, once=0;
  511.   char *pend;
  512.  
  513.   for(pend=p+n; p < pend; p+=i)
  514.     {
  515.       if (once++)
  516.         fprintf(ostream, "\n       ");
  517.  
  518.       if ((i = pend-p) > 16)
  519.         i = 16;
  520.       dumpline(p, i);
  521.     }
  522. }
  523.  
  524. /****** dumpline *************************************************************/
  525. /*                                                                           */
  526. /*  Description:                                                             */
  527. /*                                                                           */
  528. /*  Parameters:                                                              */
  529. /*                                                                           */
  530. /*  Returns:                                                                 */
  531. /*                                                                           */
  532. /*  Global Data:                                                             */
  533. /*                                                                           */
  534. /*****************************************************************************/
  535.  
  536.   void
  537. dumpline(char *buf, UINT n)
  538. {
  539.   char *cp;
  540.   UINT i;
  541.  
  542.   for(i=0, cp=buf; i < 16; i++)
  543.     {
  544.       /* 1 is the spacer */
  545.       if ((i > 0) && ((i & 1) == 0) )
  546.         fprintf(ostream, " ");
  547.  
  548.       if (i < n)
  549.         dumphex(*cp++);
  550.       else
  551.         fprintf(ostream, "  ");
  552.     }
  553.  
  554.   fprintf(ostream, " ");
  555.  
  556.   for(i=0, cp=buf; i < n; i++, cp++)
  557.     fprintf(ostream, "%c", (*cp >= 0x20 && *cp < 0x7F) ? *cp : '.');
  558.   fprintf(ostream, "\n");
  559. }
  560.  
  561. /****** dumphbuf *************************************************************/
  562. /*                                                                           */
  563. /*  Description:                                                             */
  564. /*      Dumps a buffer of hex bytes (no ASCII side text).                    */
  565. /*                                                                           */
  566. /*  Parameters:                                                              */
  567. /*      p        ptr to buffer to be dumped                                  */
  568. /*      n        number of bytes to dump                                     */
  569. /*      space    white space amount before dumping line                      */
  570. /*                                                                           */
  571. /*  Returns:                                                                 */
  572. /*      void                                                                 */
  573. /*                                                                           */
  574. /*  Global Data:                                                             */
  575. /*      none                                                                 */
  576. /*                                                                           */
  577. /*****************************************************************************/
  578.  
  579.   void
  580. dumphbuf(char *p, UINT n, UINT space)
  581. {
  582.   char *cp;
  583.   UINT i, once=0;
  584.   char *pend;
  585.   char fakeit;
  586.  
  587.   for(pend=p+n; p < pend; p+=i)
  588.     {
  589.       if (once++)
  590.         {
  591.           fprintf(ostream, "\n");
  592.           fakeit = ' ';
  593.           fprintf(ostream, "%*c", space, fakeit);
  594.         }
  595.  
  596.       if ((i = pend-p) > 16)
  597.         i = 16;
  598.       dumphlin(p, i);
  599.     }
  600. }
  601.  
  602. /****** dumphlin *************************************************************/
  603. /*                                                                           */
  604. /*  Description:                                                             */
  605. /*      Dumps a line of hex bytes (no ASCII side text).                      */
  606. /*                                                                           */
  607. /*  Parameters:                                                              */
  608. /*      buf      ptr to buffer to be dumped                                  */
  609. /*      n        number of bytes to dump                                     */
  610. /*                                                                           */
  611. /*  Returns:                                                                 */
  612. /*      void                                                                 */
  613. /*                                                                           */
  614. /*  Global Data:                                                             */
  615. /*      none                                                                 */
  616. /*                                                                           */
  617. /*****************************************************************************/
  618.  
  619.   void
  620. dumphlin(char *buf, UINT n)
  621. {
  622.   char *cp;
  623.   UINT i;
  624.  
  625.   for(i=0, cp=buf; i < 16; i++)
  626.     {
  627.       /* 1 is the spacer */
  628.       if ((i > 0) && ((i & 1) == 0) )
  629.         fprintf(ostream, " ");
  630.  
  631.       if (i < n)
  632.         dumphex(*cp++);
  633.       else
  634.         fprintf(ostream, "  ");
  635.     }
  636.  
  637. }
  638.  
  639. /****** dumphex **************************************************************/
  640. /*                                                                           */
  641. /*  Description:                                                             */
  642. /*                                                                           */
  643. /*  Parameters:                                                              */
  644. /*                                                                           */
  645. /*  Returns:                                                                 */
  646. /*                                                                           */
  647. /*  Global Data:                                                             */
  648. /*                                                                           */
  649. /*****************************************************************************/
  650.  
  651.   void
  652. dumphex(UCHAR c)
  653. {
  654.   static char hexdig[16] = "0123456789ABCDEF";
  655.  
  656.   fprintf(ostream, "%c%c", hexdig[(c >> 4) & 0x0F], hexdig[c & 0x0F]);
  657. }
  658.  
  659. /****** PrintRegType *********************************************************/
  660. /*                                                                           */
  661. /*  Description:                                                             */
  662. /*      print to output stream                                               */
  663. /*                                                                           */
  664. /*  Parameters:                                                              */
  665. /*                                                                           */
  666. /*  Returns:                                                                 */
  667. /*      void                                                                 */
  668. /*                                                                           */
  669. /*  Global Data:                                                             */
  670. /*                                                                           */
  671. /*****************************************************************************/
  672.  
  673.   void
  674. PrintRegType (UINT n)
  675. {
  676.  
  677.   typedef struct recsymnames
  678.     {
  679.       int     code;
  680.       char    name[20];
  681.     };
  682.  
  683. static struct recsymnames
  684.        RegTypeNames[43] = {
  685.            0x00,   "AL",
  686.            0x01,   "CL",
  687.            0x02,   "DL",
  688.            0x03,   "BL",
  689.            0x04,   "CH",
  690.            0x05,   "DH",
  691.            0x06,   "BH",
  692.            0x07,   "AL",
  693.            0x08,   "AX",
  694.            0x09,   "CX",
  695.            0x0A,   "DX",
  696.            0x0B,   "BX",
  697.            0x0C,   "SP",
  698.            0x0D,   "BP",
  699.            0x0E,   "SI",
  700.            0x0F,   "DI",
  701.            0x10,   "EAX",
  702.            0x11,   "ECX",
  703.            0x12,   "EDX",
  704.            0x13,   "EBX",
  705.            0x14,   "ESP",
  706.            0x15,   "EBP",
  707.            0x16,   "ESI",
  708.            0x17,   "EDI",
  709.            0x18,   "SS",
  710.            0x19,   "CS",
  711.            0x1A,   "SS",
  712.            0x1B,   "DS",
  713.            0x1C,   "FS",
  714.            0x1D,   "GS",
  715.            0x20,   "DX:AX",
  716.            0x21,   "ES:BX",
  717.            0x22,   "IP",
  718.            0x23,   "FLAGS",
  719.            0x24,   "EFLAGS",
  720.            0x80,   "ST(0)",
  721.            0x81,   "ST(1)",
  722.            0x82,   "ST(2)",
  723.            0x83,   "ST(3)",
  724.            0x84,   "ST(4)",
  725.            0x85,   "ST(5)",
  726.            0x86,   "ST(6)",
  727.            0x87,   "ST(7)"
  728.   };
  729.  
  730.   UINT   i;
  731.  
  732.   for (i=0; i<43; i++)
  733.     {
  734.       if (n == RegTypeNames[i].code)
  735.         {
  736.           fprintf(ostream, "%s", RegTypeNames[i].name);
  737.           return;
  738.         }
  739.     }
  740.  
  741.   fprintf(ostream, "%u", n);
  742. }
  743.