home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sd386v50.zip / sd386src.zip / SHOWCORG.C < prev    next >
Text File  |  1995-11-30  |  27KB  |  630 lines

  1. /*****************************************************************************/
  2. /* File:                                              IBM INTERNAL USE ONLY  */
  3. /*      showcorg.c                                                           */
  4. /*                                                                           */
  5. /* Description:                                                              */
  6. /*                                                                           */
  7. /*      Display Co Processor registers                                       */
  8. /*                                                                           */
  9. /* History:                                                                  */
  10. /*                                                                           */
  11. /*...Revised 08/29/95                                                        */
  12. /*...                                                                        */
  13. /*****************************************************************************/
  14.  
  15. #include "all.h"
  16.  
  17. extern UINT          VideoCols;
  18. extern UINT          VideoRows;
  19. extern UCHAR         *VideoMap;
  20. extern UCHAR         VideoAtr;
  21. extern UCHAR        *BoundPtr;
  22. extern UCHAR         Reg_Display;
  23. extern UINT          ProcessID;
  24. extern UINT          VioStartOffSet;
  25.  
  26. static struct coregs
  27. {
  28.  UCHAR row;
  29. }regs[] = { 1,3,5,7,9,11,13,15,0};
  30.  
  31. static UCHAR Status[]   = {" Status:"};
  32. static UCHAR Control[]  = {" Control:"};
  33. static UCHAR Status1[]  = {"  C   CCCESPUOZDI"};
  34. static UCHAR Status2[]  = {" B3TOP210SFEEEEEE"};
  35. static UCHAR Control1[] = {"     RCPC  PUOZDI"};
  36.  
  37. static UCHAR BitString[18]     = { Attrib(vaRegWind) };
  38. static UCHAR HexDig[]          = "0123456789ABCDEF";
  39. static UCHAR RegValue[23]      = { Attrib(vaRegWind) };
  40. static UCHAR Blank[PRINTLEN+2] = { Attrib(vaRegWind) };
  41.  
  42. static COPROCESSORREGS  coproc_regs;
  43.  
  44. /*****************************************************************************/
  45. /* ShowCoRegs()                                                              */
  46. /*                                                                           */
  47. /* Description:                                                              */
  48. /*                                                                           */
  49. /*      Display the Co processor registers                                   */
  50. /*                                                                           */
  51. /* Parameters:                                                               */
  52. /*                                                                           */
  53. /* Return:                                                                   */
  54. /*                                                                           */
  55. /* Assumptions:                                                              */
  56. /*                                                                           */
  57. /*****************************************************************************/
  58. void ShowCoRegs()
  59. {
  60.  UINT   Start_Col;
  61.  struct coregs  *p;
  62.  UCHAR  Attribute;
  63.  UINT   x,y;
  64.  USHORT TagValue;
  65.  UCHAR  Buffer[PRINTLEN+2];
  66.  long double Value387;
  67.  int    Len;
  68.  APIRET rc;
  69.  
  70.  int    i,j;
  71.  USHORT tag[8];
  72.  char   DosDebugRegValue[8][23];
  73.  char   PhysRegValueString[8][23];
  74.  char   PhysRegValue[8][10];
  75.  char   RelativeRegString[8][4];
  76.  USHORT PhysRegStackTop;
  77.  UCHAR  PhysRegIndex[8];
  78.  
  79.  /****************************************************************************/
  80.  /* - Get the coprocessor registers.                                         */
  81.  /****************************************************************************/
  82.  memset( &coproc_regs, 0, sizeof(COPROCESSORREGS) );
  83.  
  84.  rc = xGetCoRegs(&coproc_regs);
  85.  if( rc != 0 )
  86.  {
  87.   SayMsgBox2("CoProcessor Not Loaded", 800UL);
  88.   Reg_Display = 0;
  89.   return;
  90.  }
  91.  
  92.  /****************************************************************************/
  93.  /* - Define tag fields. See 80387 reference.                                */
  94.  /****************************************************************************/
  95.  tag[0] = (coproc_regs.TagWord & 0x0003 );
  96.  tag[1] = (coproc_regs.TagWord & 0x000C );
  97.  tag[2] = (coproc_regs.TagWord & 0x0030 );
  98.  tag[3] = (coproc_regs.TagWord & 0x00C0 );
  99.  tag[4] = (coproc_regs.TagWord & 0x0300 );
  100.  tag[5] = (coproc_regs.TagWord & 0x0C00 );
  101.  tag[6] = (coproc_regs.TagWord & 0x3000 );
  102.  tag[7] = (coproc_regs.TagWord & 0xC000 );
  103.  
  104.  /****************************************************************************/
  105.  /* - Convert the coprocessor register values to displayable hex strings.    */
  106.  /****************************************************************************/
  107.  memset( DosDebugRegValue, 0 , sizeof(DosDebugRegValue) );
  108.  Converttox( (UCHAR*)(&coproc_regs.Stack[0]), DosDebugRegValue[0]);
  109.  Converttox( (UCHAR*)(&coproc_regs.Stack[1]), DosDebugRegValue[1]);
  110.  Converttox( (UCHAR*)(&coproc_regs.Stack[2]), DosDebugRegValue[2]);
  111.  Converttox( (UCHAR*)(&coproc_regs.Stack[3]), DosDebugRegValue[3]);
  112.  Converttox( (UCHAR*)(&coproc_regs.Stack[4]), DosDebugRegValue[4]);
  113.  Converttox( (UCHAR*)(&coproc_regs.Stack[5]), DosDebugRegValue[5]);
  114.  Converttox( (UCHAR*)(&coproc_regs.Stack[6]), DosDebugRegValue[6]);
  115.  Converttox( (UCHAR*)(&coproc_regs.Stack[7]), DosDebugRegValue[7]);
  116.  
  117.  /****************************************************************************/
  118.  /* - Define the physical register that contains the top of the stack.       */
  119.  /****************************************************************************/
  120.  PhysRegStackTop =  (USHORT)((coproc_regs.StatusWord >> 11) & 0x7);
  121.  
  122.  /****************************************************************************/
  123.  /* - Now, associate the display hex strings with their physical registers.  */
  124.  /*   We wiil be displaying physical registers from 0-7.                     */
  125.  /* - Define the physical display hex value. This will be converted by       */
  126.  /*   sprintf to a displayable real value.                                   */
  127.  /* - Define the logical register index associated with a physical register. */
  128.  /****************************************************************************/
  129.  memset( PhysRegValueString, 0 , sizeof(PhysRegValueString) );
  130.  i = PhysRegStackTop;
  131.  for( j=0; j<8; j++ )
  132.  {
  133.   strcpy(PhysRegValueString[i], DosDebugRegValue[j]);
  134.   memcpy(PhysRegValue[i], &coproc_regs.Stack[j], sizeof(REG80BIT) );
  135.   sprintf(RelativeRegString[i], "ST%c", HexDig[j] );
  136.  
  137.   (i==7)?i=0:i++;
  138.  }
  139.  
  140. /*****************************************************************************/
  141. /* The following block of code will printf the coprocessor registers.        */
  142. /* Remove the ifdefs and build to get it to print.                           */
  143. /*---------------------------------------------------------------------------*/
  144. #if 0
  145.  printf("\n\n");
  146.  printf("\nControlWord %x ",coproc_regs.ControlWord);
  147.  printf("\nReserved1   %x ",coproc_regs.Reserved1  );
  148.  printf("\nStatusWord  %x ",coproc_regs.StatusWord );
  149.  printf("\nReserved2   %x ",coproc_regs.Reserved2  );
  150.  printf("\nTagWord     %x ",coproc_regs.TagWord    );
  151.  printf("\nReserved3   %x ",coproc_regs.Reserved3  );
  152.  printf("\nIpOffset    %x ",coproc_regs.IpOffset   );
  153.  printf("\nCsSelector  %x ",coproc_regs.CsSelector );
  154.  printf("\nReserved4   %x ",coproc_regs.Reserved4  );
  155.  printf("\nOpOffset    %x ",coproc_regs.OpOffset   );
  156.  printf("\nOpSelector  %x ",coproc_regs.OpSelector );
  157.  printf("\nReserved5   %x ",coproc_regs.Reserved5  );
  158.  
  159.  printf("\n\nPhysical Register Stack Top = %d", PhysRegStackTop );
  160.  printf("\n\nLogical Registers");
  161.  for( i=0; i<8; i++ )
  162.  {
  163.   printf("\n%d, %s, ", i, DosDebugRegValue[i] );
  164.  }
  165.  
  166.  printf("\n\nPhysical Registers");
  167.  for( i=0; i<8; i++ )
  168.  {
  169.   int    bitval1;
  170.   int    bitval2;
  171.  
  172.   bitval1 =  (tag[i] >> (i*2)  )&0x0001 ;
  173.   bitval2 =  (tag[i] >> (i*2+1))&0x0001;
  174.  
  175.   printf("\n%d, %s, %1d%1d ", i, PhysRegValueString[i], bitval2, bitval1 );
  176.  }
  177.  fflush(0);
  178. #endif
  179. /*--end of print coprocessor registers--------------------------------------*/
  180.  
  181.  /****************************************************************************/
  182.  /* - Release the screen bounds.                                             */
  183.  /* - Display the register box + headers/footers.                            */
  184.  /****************************************************************************/
  185.  memset(Blank+1, SPACE, sizeof(Blank)-2);
  186.  memset(Buffer, 0, sizeof(Buffer) );
  187.  memset(BoundPtr+VioStartOffSet,VideoCols,VideoRows-VioStartOffSet);
  188.  Start_Col = VideoCols - COREGSWINWIDTH + 4;
  189.  VideoAtr  = vaRegWind;
  190.  if (TestBit(Reg_Display,REPAINT))
  191.  {
  192.   Vfmtbox( "",VioStartOffSet,
  193.            VideoCols - COREGSWINWIDTH,COREGSWINLENGTH,COREGSWINWIDTH );
  194.  
  195.   ResetBit(Reg_Display,REPAINT);
  196.   Status[0]   = Attrib(vaRegWind);
  197.   Status1[0]  = Attrib(vaRegWind);
  198.   Status2[0]  = Attrib(vaRegWind);
  199.   Control[0]  = Attrib(vaRegWind);
  200.   Control1[0] = Attrib(vaRegWind);
  201.   putrc( StatusRow + VioStartOffSet, Start_Col-2, Status );
  202.   putrc( StatusRow-2+VioStartOffSet, Start_Col+9, Status1 );
  203.   putrc( StatusRow-1+VioStartOffSet, Start_Col+9, Status2 );
  204.   putrc( ControlRow+VioStartOffSet, Start_Col-2, Control );
  205.   putrc( ControlRow-1+VioStartOffSet, Start_Col+9, Control1 );
  206.  }
  207.  
  208.  /****************************************************************************/
  209.  /* Find the Toggle attribute of the existing color attribute for register   */
  210.  /* window and put it in vaRegTogg position of videomap.                     */
  211.  /****************************************************************************/
  212.  Attribute            = VideoMap[vaRegWind];
  213.  Attribute           ^= HIGHLIGHT;
  214.  VideoMap[vaRegTogg]  = Attribute;
  215.  
  216.  /****************************************************************************/
  217.  /* - Now, display the registers.                                            */
  218.  /****************************************************************************/
  219.  for( p=regs, i=0; i < 8 ; p++, i++)
  220.  {
  221.   TagValue  = tag[i] >> (i*2) ;
  222.   TagValue &= 0x3;
  223.   switch(TagValue)
  224.   {
  225.    case TAG_VALID:
  226.    case TAG_INFIN:
  227.     strcpy( RegValue + 1, PhysRegValueString[i] );
  228.     break;
  229.  
  230.    case TAG_ZERO:
  231.     FillIn(RegValue + 1,ZERO);
  232.     break;
  233.  
  234.    case TAG_EMPTY:
  235.     FillIn(RegValue + 1,EMPTY);
  236.     break;
  237.   }
  238.  
  239.   /***************************************************************************/
  240.   /* - highlight the top-of-stack                                            */
  241.   /***************************************************************************/
  242.   if(PhysRegStackTop == i )
  243.   {
  244.     Buffer[0]   = Attrib(vaRegTogg);
  245.     RegValue[0] = Attrib(vaRegTogg);
  246.   }
  247.   else
  248.   {
  249.     Buffer[0]   = Attrib(vaRegWind);
  250.     RegValue[0] = Attrib(vaRegWind);
  251.   }
  252.  
  253.   memset(PhysRegIndex, 0, sizeof(PhysRegIndex) );
  254.   PhysRegIndex[0] = Attrib(vaRegWind);
  255.   PhysRegIndex[1] = HexDig[i];
  256.  
  257.   putrc( p->row+VioStartOffSet, Start_Col-2, PhysRegIndex );
  258.   putrc( p->row+VioStartOffSet, Start_Col ,  RelativeRegString[i] );
  259.   putrc( p->row+VioStartOffSet, Start_Col+4, RegValue );
  260.  
  261.   /***************************************************************************/
  262.   /* - display a blank or the floating register value in real format.        */
  263.   /***************************************************************************/
  264.   if (TagValue == TAG_EMPTY)
  265.   {
  266.    putrc( p->row+1+VioStartOffSet, Start_Col , Blank );
  267.   }
  268.   else
  269.   {
  270.    /************************************************************************/
  271.    /* - Store the value of long double from co proceesor into a local var  */
  272.    /* - Call sprintf.                                                      */
  273.    /* - stuff in the spaces at the end of the buffer.                      */
  274.    /************************************************************************/
  275.    Value387 = *(long double*)&PhysRegValue[i];
  276.    Len = sprintf(Buffer+1,"%+1.18LE",Value387);
  277.    while (Len < PRINTLEN)
  278.      Buffer[Len++ + 1] = SPACE;
  279.    putrc( p->row+1+VioStartOffSet, Start_Col , Buffer );
  280.   }
  281.  }
  282.  
  283.  /****************************************************************************/
  284.  /* Move the statuswords bit pattern into a temp array and display it        */
  285.  /****************************************************************************/
  286.  for (x = 0,y = 16; x < 16; x++, y--)
  287.     BitString[y] = (UCHAR)'0' + (UCHAR)((coproc_regs.StatusWord>>x) & 1);
  288.  putrc( StatusRow+VioStartOffSet, Start_Col+9, BitString );
  289.  
  290.  /****************************************************************************/
  291.  /* Move the Controlwords bit pattern into a temp array and display it       */
  292.  /****************************************************************************/
  293.  for (x = 0,y = 16; x < 16; x++, y--)
  294.     BitString[y] = (UCHAR)'0' + (UCHAR)((coproc_regs.ControlWord>>x) & 1);
  295.  putrc( ControlRow+VioStartOffSet, Start_Col+9, BitString );
  296.  
  297.  /****************************************************************************/
  298.  /* Set the screen bounds.                                                   */
  299.  /****************************************************************************/
  300.  memset(BoundPtr+VioStartOffSet, VideoCols-COREGSWINWIDTH, COREGSWINLENGTH);
  301. }
  302.  
  303. /*****************************************************************************/
  304. /* Converttox()                                                              */
  305. /*                                                                           */
  306. /* Description:                                                              */
  307. /*      Convert an 80 bit real to an hex string.                             */
  308. /* Parameters:                                                               */
  309. /*      Input  -> to input value                                             */
  310. /*      x      -> to Hex String                                              */
  311. /* Return:                                                                   */
  312. /*      none                                                                 */
  313. /* Assumptions:                                                              */
  314. /*      none                                                                 */
  315. /*****************************************************************************/
  316. void Converttox(UCHAR *Input,UCHAR *x)
  317. {
  318.     UINT n;
  319.     UINT IpIndex;
  320.     UINT OpIndex;
  321.     UCHAR Temp;
  322.     OpIndex = 20;
  323.     IpIndex = 0;
  324.  
  325.     for( n=0 ; n < 10 ; n++)
  326.     {
  327.         Temp = Input[IpIndex++];
  328.         x[OpIndex--] = HexDig[Temp & 0xF];
  329.         Temp >>= 4;
  330.         x[OpIndex--] = HexDig[Temp & 0xF];
  331.         if (OpIndex == (UINT)4)
  332.           x[OpIndex--] = SPACE;
  333.     }
  334. }
  335.  
  336. /*****************************************************************************/
  337. /* FillIn()                                                                  */
  338. /*                                                                           */
  339. /* Description:                                                              */
  340. /*      Fills a string with given character.                                 */
  341. /* Parameters:                                                               */
  342. /*      Input  -> to input string.                                           */
  343. /*      x      character to copy.                                            */
  344. /* Return:                                                                   */
  345. /*      none                                                                 */
  346. /* Assumptions:                                                              */
  347. /*      none                                                                 */
  348. /*****************************************************************************/
  349. void FillIn(UCHAR *Input,UCHAR x)
  350. {
  351.     UINT n;
  352.     UINT OpIndex = 0;
  353.  
  354.     for( n=0 ; n < 20 ; n++)
  355.     {
  356.         Input[OpIndex++] = x;
  357.         if (OpIndex == (UINT)4)
  358.           Input[OpIndex++] = SPACE;
  359.     }
  360. }
  361. #ifdef MSH
  362. void showCoRegs(WINDOW *win)
  363. {
  364.  struct coregs  *p;
  365.  UCHAR  Attribute;
  366.  UINT   x,y;
  367.  USHORT TagValue;
  368.  UCHAR  Buffer[PRINTLEN+2];
  369.  long double Value387;
  370.  int    Len;
  371.  APIRET rc;
  372.  
  373.  int    i,j;
  374.  USHORT tag[8];
  375.  char   DosDebugRegValue[8][23];
  376.  char   PhysRegValueString[8][23];
  377.  char   PhysRegValue[8][10];
  378.  char   RelativeRegString[8][4];
  379.  USHORT PhysRegStackTop;
  380.  UCHAR  PhysRegIndex[8];
  381.  
  382.  char   **screen=(char **)win->user_data;
  383.  --screen;
  384.  /****************************************************************************/
  385.  /* - Get the coprocessor registers.                                         */
  386.  /****************************************************************************/
  387.  memset( &coproc_regs, 0, sizeof(COPROCESSORREGS) );
  388.  
  389.  rc = xGetCoRegs(&coproc_regs);
  390.  if( rc != 0 )
  391.  {
  392.   SayMsgBox2("CoProcessor Not Loaded", 800UL);
  393.   Reg_Display = 0;
  394.   return;
  395.  }
  396.  
  397.  /****************************************************************************/
  398.  /* - Define tag fields. See 80387 reference.                                */
  399.  /****************************************************************************/
  400.  tag[0] = (coproc_regs.TagWord & 0x0003 );
  401.  tag[1] = (coproc_regs.TagWord & 0x000C );
  402.  tag[2] = (coproc_regs.TagWord & 0x0030 );
  403.  tag[3] = (coproc_regs.TagWord & 0x00C0 );
  404.  tag[4] = (coproc_regs.TagWord & 0x0300 );
  405.  tag[5] = (coproc_regs.TagWord & 0x0C00 );
  406.  tag[6] = (coproc_regs.TagWord & 0x3000 );
  407.  tag[7] = (coproc_regs.TagWord & 0xC000 );
  408.  
  409.  /****************************************************************************/
  410.  /* - Convert the coprocessor register values to displayable hex strings.    */
  411.  /****************************************************************************/
  412.  memset( DosDebugRegValue, 0 , sizeof(DosDebugRegValue) );
  413.  Converttox( (UCHAR*)(&coproc_regs.Stack[0]), DosDebugRegValue[0]);
  414.  Converttox( (UCHAR*)(&coproc_regs.Stack[1]), DosDebugRegValue[1]);
  415.  Converttox( (UCHAR*)(&coproc_regs.Stack[2]), DosDebugRegValue[2]);
  416.  Converttox( (UCHAR*)(&coproc_regs.Stack[3]), DosDebugRegValue[3]);
  417.  Converttox( (UCHAR*)(&coproc_regs.Stack[4]), DosDebugRegValue[4]);
  418.  Converttox( (UCHAR*)(&coproc_regs.Stack[5]), DosDebugRegValue[5]);
  419.  Converttox( (UCHAR*)(&coproc_regs.Stack[6]), DosDebugRegValue[6]);
  420.  Converttox( (UCHAR*)(&coproc_regs.Stack[7]), DosDebugRegValue[7]);
  421.  
  422.  /****************************************************************************/
  423.  /* - Define the physical register that contains the top of the stack.       */
  424.  /****************************************************************************/
  425.  PhysRegStackTop =  (USHORT)((coproc_regs.StatusWord >> 11) & 0x7);
  426.  
  427.  /****************************************************************************/
  428.  /* - Now, associate the display hex strings with their physical registers.  */
  429.  /*   We wiil be displaying physical registers from 0-7.                     */
  430.  /* - Define the physical display hex value. This will be converted by       */
  431.  /*   sprintf to a displayable real value.                                   */
  432.  /* - Define the logical register index associated with a physical register. */
  433.  /****************************************************************************/
  434.  memset( PhysRegValueString, 0 , sizeof(PhysRegValueString) );
  435.  i = PhysRegStackTop;
  436.  for( j=0; j<8; j++ )
  437.  {
  438.   strcpy(PhysRegValueString[i], DosDebugRegValue[j]);
  439.   memcpy(PhysRegValue[i], &coproc_regs.Stack[j], sizeof(REG80BIT) );
  440.   sprintf(RelativeRegString[i], "ST%c", HexDig[j] );
  441.  
  442.   (i==7)?i=0:i++;
  443.  }
  444.  
  445. /*****************************************************************************/
  446. /* The following block of code will printf the coprocessor registers.        */
  447. /* Remove the ifdefs and build to get it to print.                           */
  448. /*---------------------------------------------------------------------------*/
  449. #if 0
  450.  printf("\n\n");
  451.  printf("\nControlWord %x ",coproc_regs.ControlWord);
  452.  printf("\nReserved1   %x ",coproc_regs.Reserved1  );
  453.  printf("\nStatusWord  %x ",coproc_regs.StatusWord );
  454.  printf("\nReserved2   %x ",coproc_regs.Reserved2  );
  455.  printf("\nTagWord     %x ",coproc_regs.TagWord    );
  456.  printf("\nReserved3   %x ",coproc_regs.Reserved3  );
  457.  printf("\nIpOffset    %x ",coproc_regs.IpOffset   );
  458.  printf("\nCsSelector  %x ",coproc_regs.CsSelector );
  459.  printf("\nReserved4   %x ",coproc_regs.Reserved4  );
  460.  printf("\nOpOffset    %x ",coproc_regs.OpOffset   );
  461.  printf("\nOpSelector  %x ",coproc_regs.OpSelector );
  462.  printf("\nReserved5   %x ",coproc_regs.Reserved5  );
  463.  
  464.  printf("\n\nPhysical Register Stack Top = %d", PhysRegStackTop );
  465.  printf("\n\nLogical Registers");
  466.  for( i=0; i<8; i++ )
  467.  {
  468.   printf("\n%d, %s, ", i, DosDebugRegValue[i] );
  469.  }
  470.  
  471.  printf("\n\nPhysical Registers");
  472.  for( i=0; i<8; i++ )
  473.  {
  474.   int    bitval1;
  475.   int    bitval2;
  476.  
  477.   bitval1 =  (tag[i] >> (i*2)  )&0x0001 ;
  478.   bitval2 =  (tag[i] >> (i*2+1))&0x0001;
  479.  
  480.   printf("\n%d, %s, %1d%1d ", i, PhysRegValueString[i], bitval2, bitval1 );
  481.  }
  482.  fflush(0);
  483. #endif
  484. /*--end of print coprocessor registers--------------------------------------*/
  485.  
  486.  /****************************************************************************/
  487.  /* - Release the screen bounds.                                             */
  488.  /* - Display the register box + headers/footers.                            */
  489.  /****************************************************************************/
  490.  Blank[0]=Attrib(vaRegWind);
  491.  memset(Blank+1, SPACE, sizeof(Blank)-2);
  492.  memset(Buffer, 0, sizeof(Buffer) );
  493.  memset(BoundPtr+VioStartOffSet,VideoCols,VideoRows-VioStartOffSet);
  494.  VideoAtr  = vaRegWind;
  495. #if 0
  496.  if (TestBit(Reg_Display,REPAINT))
  497.  {
  498.   Vfmtbox( "",VioStartOffSet,
  499.            VideoCols - COREGSWINWIDTH,COREGSWINLENGTH,COREGSWINWIDTH );
  500.  
  501.   ResetBit(Reg_Display,REPAINT);
  502.   Status[0]   = Attrib(vaRegWind);
  503.   Status1[0]  = Attrib(vaRegWind);
  504.   Status2[0]  = Attrib(vaRegWind);
  505.   Control[0]  = Attrib(vaRegWind);
  506.   Control1[0] = Attrib(vaRegWind);
  507.  }
  508. #endif
  509.  
  510.  /****************************************************************************/
  511.  /* Find the Toggle attribute of the existing color attribute for register   */
  512.  /* window and put it in vaRegTogg position of videomap.                     */
  513.  /****************************************************************************/
  514.  Attribute            = VideoMap[vaRegWind];
  515.  Attribute           ^= HIGHLIGHT;
  516.  VideoMap[vaRegTogg]  = Attribute;
  517.  
  518.  /****************************************************************************/
  519.  /* - Now, display the registers.                                            */
  520.  /****************************************************************************/
  521.  for( p=regs, i=0; i < 8 ; p++, i++)
  522.  {
  523.   TagValue  = tag[i] >> (i*2) ;
  524.   TagValue &= 0x3;
  525.   switch(TagValue)
  526.   {
  527.    case TAG_VALID:
  528.    case TAG_INFIN:
  529.     strcpy( RegValue + 1, PhysRegValueString[i] );
  530.     break;
  531.  
  532.    case TAG_ZERO:
  533.     FillIn(RegValue + 1,ZERO);
  534.     break;
  535.  
  536.    case TAG_EMPTY:
  537.     FillIn(RegValue + 1,EMPTY);
  538.     break;
  539.   }
  540.  
  541.   /***************************************************************************/
  542.   /* - highlight the top-of-stack                                            */
  543.   /***************************************************************************/
  544.   if(PhysRegStackTop == i )
  545.   {
  546.     Buffer[0]   = Attrib(vaRegTogg);
  547.     RegValue[0] = Attrib(vaRegTogg);
  548.   }
  549.   else
  550.   {
  551.     Buffer[0]   = Attrib(vaRegWind);
  552.     RegValue[0] = Attrib(vaRegWind);
  553.   }
  554.  
  555.   memset(PhysRegIndex, 0, sizeof(PhysRegIndex) );
  556.   PhysRegIndex[0] = Attrib(vaRegWind);
  557.   PhysRegIndex[1] = HexDig[i];
  558.  
  559.   strcpy( screen[p->row], PhysRegIndex );
  560.   strcat( screen[p->row], " " );
  561.   strcat( screen[p->row], RelativeRegString[i] );
  562.   strcat( screen[p->row], " " );
  563.   strcat( screen[p->row], RegValue );
  564.  
  565.   /***************************************************************************/
  566.   /* - display a blank or the floating register value in real format.        */
  567.   /***************************************************************************/
  568.   if (TagValue == TAG_EMPTY)
  569.   {
  570.    strcpy( screen[p->row+1], "  " );
  571.    strcpy( screen[p->row+1]+2, Blank );
  572.   }
  573.   else
  574.   {
  575.    /************************************************************************/
  576.    /* - Store the value of long double from co proceesor into a local var  */
  577.    /* - Call sprintf.                                                      */
  578.    /* - stuff in the spaces at the end of the buffer.                      */
  579.    /************************************************************************/
  580.    Value387 = *(long double*)&PhysRegValue[i];
  581.    Len = sprintf(Buffer+1,"  %+1.18LE",Value387);
  582.    while (Len < PRINTLEN)
  583.      Buffer[Len++ + 1] = SPACE;
  584.    strcpy( screen[p->row+1], Buffer);
  585.  
  586.   }
  587.  }
  588.  
  589.  /****************************************************************************/
  590.  /* Move the statuswords bit pattern into a temp array and display it        */
  591.  /****************************************************************************/
  592.  for (x = 0,y = 16; x < 16; x++, y--)
  593.     BitString[y] = (UCHAR)'0' + (UCHAR)((coproc_regs.StatusWord>>x) & 1);
  594.    memset( screen[StatusRow], ' ', 80);
  595.    strncpy( screen[StatusRow]+11, BitString,strlen(BitString));
  596.  
  597.  /****************************************************************************/
  598.  /* Move the Controlwords bit pattern into a temp array and display it       */
  599.  /****************************************************************************/
  600.  for (x = 0,y = 16; x < 16; x++, y--)
  601.     BitString[y] = (UCHAR)'0' + (UCHAR)((coproc_regs.ControlWord>>x) & 1);
  602.    memset( screen[ControlRow], ' ', 80);
  603.    strncpy( screen[ControlRow]+11, BitString,strlen(BitString));
  604.  
  605.  /****************************************************************************/
  606.  /****************************************************************************/
  607.   strncpy(screen[StatusRow   ], Status ,strlen(Status));
  608.   strncpy(screen[ControlRow  ], Control , strlen(Control));
  609.  
  610.   memset( screen[StatusRow-1], ' ', 80);
  611.   strncpy(screen[StatusRow-1 ]+10, Status2 , strlen(Status2));
  612.  
  613.   memset( screen[StatusRow-2], ' ', 80);
  614.   strncpy(screen[StatusRow-2 ]+10, Status1 , strlen(Status1));
  615.  
  616.   memset( screen[ControlRow-1], ' ', 80);
  617.   strncpy(screen[ControlRow-1]+10, Control1 ,strlen(Control1));
  618.   for(i=79;i>=0;--i)
  619.       if(screen[ControlRow-1][i]==' ')screen[ControlRow-1][i]='\0';else break;
  620.   for(i=79;i>=0;--i)
  621.       if(screen[ControlRow][i]==' ')screen[ControlRow][i]='\0';else break;
  622.   for(i=79;i>=0;--i)
  623.       if(screen[StatusRow][i]==' ')screen[StatusRow][i]='\0';else break;
  624.   for(i=79;i>=0;--i)
  625.       if(screen[StatusRow-1][i]==' ')screen[StatusRow-1][i]='\0';else break;
  626.   for(i=79;i>=0;--i)
  627.       if(screen[StatusRow-2][i]==' ')screen[StatusRow-2][i]='\0';else break;
  628. }
  629. #endif
  630.