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

  1. /*****************************************************************************/
  2. /* File:                                              IBM INTERNAL USE ONLY  */
  3. /*      showvreg.c                                                           */
  4. /*                                                                           */
  5. /* Description:                                                              */
  6. /*      Vertical Display and Edit Registers' and Flags' contents.            */
  7. /*                                                                           */
  8. /* History:                                                                  */
  9. /*                                                                           */
  10. /*...Release 1.00 (Pre-release 107 11/13/91)                                 */
  11. /*...                                                                        */
  12. /*... 11/13/91  400   Srinivas  Vertical Register Display.                   */
  13. /*...                                                                        */
  14. /*...Release 1.00 (Pre-release 108 12/05/91)                                 */
  15. /*...                                                                        */
  16. /*... 01/28/92  508   Srinivas  Added Set Execution Line function.           */
  17. /*... 02/11/92  518   Srinivas  Remove limitation on max no of screen rows.  */
  18. /*... 02/12/92  521   Srinivas  Port to C-Set/2.                             */
  19. /*...                                                                        */
  20. /*...Release 1.00 (03/03/92)                                                 */
  21. /*...                                                                        */
  22. /*... 03/20/92  607   Srinivas  CRMA fixes.                                  */
  23. /*...                                                                        */
  24. /*...Release 1.01 (04/03/92)                                                 */
  25. /*...                                                                        */
  26. /*... 05/08/92  701   Srinivas  Cua Interface.                               */
  27. /*... 09/16/93  901   Joe       Add code to handle resource interlock error. */
  28. /***Includes******************************************************************/
  29.  
  30. #include "all.h"
  31.  
  32. /***External declarations*****************************************************/
  33.  
  34. extern uint          VideoCols;         /*                                   */
  35. extern uint          VideoRows;         /* # of rows per screen           518*/
  36. extern uchar         *VideoMap;         /*                                   */
  37. extern uchar         VideoAtr;          /*                                   */
  38. extern uchar         AppRegsZapped;     /* Flag to say 'Regs Edited'         */
  39. extern PtraceBuffer  AppPTB;            /* Appln Process Trace Buffer        */
  40. extern uchar        *BoundPtr;          /* -> to screen bounds            518*/
  41. extern uchar         Reg_Display;       /*                                   */
  42. extern AFILE        *fp_focus;          /*                                521*/
  43. extern uint          VioStartOffSet;    /* flag to tell were to start screen */
  44.                                         /* display.                       701*/
  45. static UINT          RegChgMask;        /*                                   */
  46.  
  47. static struct rfsv32 {                  /* 32-bit regs                       */
  48.   uchar rn32[4];                        /* register name                     */
  49.   uchar row;                            /* screen row                        */
  50.   uchar ndx;                            /* index into userregs               */
  51. } rfsv32[] = {                          /* the array of regs.                */
  52.   { {'E','A','X',' '},1, 0},            /* Reg. EAX, row, its index          */
  53.   { {'E','B','X',' '},2, 3},            /* Reg. EBX, row, its index          */
  54.   { {'E','C','X',' '},3, 1},            /* Reg. ECX, row, its index          */
  55.   { {'E','D','X',' '},4, 2},            /* Reg. EDX, row, its index          */
  56.   { {'E','S','I',' '},5, 6},            /* Reg. ESI, row, its index          */
  57.   { {'E','D','I',' '},6, 7},            /* Reg. EDI, row, its index          */
  58.   { {'E','S','P',' '},7, 4},            /* Reg. ESP, row, its index          */
  59.   { {'E','B','P',' '},8, 5},            /* Reg. EBP, row, its index          */
  60.   { {'E','I','P',' '},9, 9},            /* Reg. EIP, row, its index          */
  61.   { { 0 , 0 , 0 , 0 },0, 0}             /*                                   */
  62. };                                      /*                                   */
  63.                                         /*                                   */
  64. static struct rfsv16 {                  /* 16-bit regs                       */
  65.   uchar rn16[2];                        /* register name                     */
  66.   uchar row;                            /* screen row                        */
  67.   uchar ndx;                            /* index into userregs               */
  68. } rfsv16[] = {                          /* the array of regs.                */
  69.   { {'D','S'},10,06},                   /* Reg. DS, row, its index           */
  70.   { {'E','S'},11,12},                   /* Reg. ES, row, its index           */
  71.   { {'C','S'},12,00},                   /* Reg. CS, row, its index           */
  72.   { {'S','S'},13,30},                   /* Reg. SS, row, its index           */
  73.   { {'F','S'},14,18},                   /* Reg. FS, row, its index           */
  74.   { {'G','S'},15,24},                   /* Reg. GS, row, its index           */
  75.   { { 0 , 0 },00,00}                    /*                                   */
  76. };                                      /*                                   */
  77.                                         /*                                   */
  78. static uchar regname[5];                /* register name                     */
  79. static uchar x4[6] =                    /* parm for fn to convert 16bit to   */
  80.   { Attrib(vaRegWind)  };               /* hex                               */
  81.                                         /*                                   */
  82. static uchar x8[10] =                   /* parm for fn to convert 32bit to   */
  83.   { Attrib(vaRegWind) };                /* hex                               */
  84.                                         /*                                   */
  85. static struct ffs {                     /*                                   */
  86.   uchar fn[2];                          /* flag name                         */
  87.   uchar row;                            /* screen row                        */
  88.   uchar col;                            /* screen col                        */
  89.   uchar Nsh;                            /* shift count                       */
  90. } ffs[] = {                             /* the array of flags                */
  91.   { {'C','='}, 16,FC1, 0},              /* CARRY flag, pos, shift count      */
  92.   { {'P','='}, 17,FC2, 2},              /* PARITY flg, pos, shift count      */
  93.   { {'A','='}, 18,FC0, 4},              /* ACARRY flg, pos, shift count      */
  94.   { {'Z','='}, 16,FC0, 6},              /* ZERO  flag, pos, shift count      */
  95.   { {'S','='}, 16,FC2, 7},              /* SIGN  flag, pos, shift count      */
  96.   { {'D','='}, 17,FC1,10},              /* DIRECTION flg, pos, shift count   */
  97.   { {'O','='}, 17,FC0,11},              /* OVERFLOW flg, pos, shift count    */
  98.   { { 0 , 0 }, 0, 0 ,  0}               /*                                   */
  99. };                                      /*                                   */
  100.                                         /*                                   */
  101. static uchar flagvalue[3] =             /* flag value to display             */
  102.   { Attrib(vaRegWind) };                /*                                   */
  103.                                         /*                                   */
  104. static uint FlagMask[] = {              /*                                   */
  105.   ZERO_FLAG, CARRY_FLAG, SIGN_FLAG,     /* array of masks for all the flags  */
  106.    OVERFLOW_FLAG, DIRECTION_FLAG,       /*                                   */
  107.    PARITY_FLAG, ACARRY_FLAG, 0 };       /*                                   */
  108.                                         /*                                   */
  109. static uchar r16lolite[] =              /* param for PUTRC to display 16bit  */
  110.   { RepCnt(4), Attrib(vaRegWind), 0 };  /* reg value with no highlighting    */
  111.                                         /*                                   */
  112. static uchar r16hilite[] =              /* param for PUTRC to display 16bit  */
  113.   { RepCnt(4), Attrib(vaStgPro), 0 };   /* reg value highlighted             */
  114.                                         /*                                   */
  115. static uchar r32lolite[] =              /* param for PUTRC to display 32bit  */
  116.   { RepCnt(8), Attrib(vaRegWind), 0 };  /* reg value with no highlighting    */
  117.                                         /*                                   */
  118. static uchar r32hilite[] =              /* param for PUTRC to display 32bit  */
  119.   { RepCnt(8), Attrib(vaStgPro), 0 };   /* reg value highlighted             */
  120.                                         /*                                   */
  121. static uchar flolite[] =                /* param for PUTRC to display flag   */
  122.   { RepCnt(1), Attrib(vaRegWind), 0 };  /* value with no highlighting        */
  123.                                         /*                                   */
  124. static uchar fhilite[] =                /* param for PUTRC to display flag   */
  125.   { RepCnt(1), Attrib(vaStgPro), 0 };   /* value highlighted                 */
  126.  
  127. static PtraceBuffer  OldPTB;            /* Old Appln Process Trace Buffer    */
  128. /*****************************************************************************/
  129. /* ShowvRegs()                                                               */
  130. /*                                                                           */
  131. /* Description:                                                              */
  132. /*      Vertical Display the registers' and flags' contents.                 */
  133. /* Parameters:                                                               */
  134. /*      none                                                                 */
  135. /* Return:                                                                   */
  136. /*                                                                           */
  137. /* Assumptions:                                                              */
  138. /*      none                                                                 */
  139. /*****************************************************************************/
  140. void ShowvRegs()
  141. {
  142.  uint  *userregs;                       /* user regs in the PTBuffer         */
  143.  uint   Start_Col;                      /* column where to start display     */
  144.  struct rfsv32 *p;                      /* -> to 32bit registers             */
  145.  struct rfsv16 *q;                      /* -> to 16bit segment registers     */
  146.  struct ffs *r;                         /* -> to flags                       */
  147.  ushort flags;                          /* Holds the flags from AppPTB       */
  148.  uchar  Attribute;                      /* attribute to hold reg win highlit */
  149.  uint   Mask;                           /* mask position to check bits in    */
  150.                                         /* RegChgMask                        */
  151.  /****************************************************************************/
  152.  /* Release the screen bounds.                                               */
  153.  /* If it is the 1st invocation paint the whole register window Box.         */
  154.  /****************************************************************************/
  155.  memset(BoundPtr+VioStartOffSet,VideoCols,VideoRows-VioStartOffSet);
  156.  Start_Col = VideoCols - REGSWINWIDTH + 2;
  157.  Mask = 0;
  158.  VideoAtr  = vaRegWind;
  159.  if (TestBit(Reg_Display,REPAINT))
  160.  {
  161.    Vfmtbox( "",VioStartOffSet,                                          /*701*/
  162.             VideoCols - REGSWINWIDTH,REGSWINLENGTH,REGSWINWIDTH );
  163.    ResetBit(Reg_Display,REPAINT);
  164.  }
  165.  
  166. #if 0
  167.  MouseRect.row  = VioStartOffSet;                                       /*701*/
  168.  MouseRect.col  = VideoCols - REGSWINWIDTH;                             /*701*/
  169.  MouseRect.cRow = MouseRect.row + REGSWINLENGTH - 1;                    /*701*/
  170.  MouseRect.cCol = MouseRect.col + REGSWINWIDTH - 1;                     /*701*/
  171.  SetCollisionArea( &MouseRect );                                        /*701*/
  172. #endif
  173.  
  174.  /****************************************************************************/
  175.  /* Find the Toggle attribute of the existing color attribute for register   */
  176.  /* window and put it in vaRegTogg position of videomap.                     */
  177.  /****************************************************************************/
  178.  Attribute = VideoMap[vaRegWind];
  179.  Attribute ^= HIGHLIGHT;
  180.  VideoMap[vaRegTogg] = Attribute;
  181.  
  182.  /****************************************************************************/
  183.  /*  Get pointer to the register in AppPTB, loop for all 32bit registers.    */
  184.  /*  Check the register change mask to determine if the attribute has to be  */
  185.  /*  changed for the value being displayed.                                  */
  186.  /****************************************************************************/
  187.  userregs = (uint *)&(AppPTB.EAX);
  188.  p = rfsv32;
  189.  *(fourc *)regname = *(fourc *) p->rn32;
  190.  for(; *(fourc *)regname ; ++p, Mask++, *(fourc *)regname = *(fourc *) p->rn32)
  191.  {
  192.     utox8( *(userregs + p->ndx ), x8 + 1 );
  193.     putrc( p->row + VioStartOffSet, Start_Col, regname );               /*701*/
  194.     if (TestBit(RegChgMask,Mask))
  195.       x8[0] = Attrib(vaRegTogg);
  196.     else
  197.       x8[0] = Attrib(vaRegWind);
  198.     putrc( p->row + VioStartOffSet, Start_Col + 4, x8 );                /*701*/
  199.  }
  200.  
  201.  /****************************************************************************/
  202.  /*  Get pointer to the segment registers in AppPTB, loop for all seg regs.  */
  203.  /*  Check the register change mask to determine if the attribute has to be  */
  204.  /*  changed for the value being displayed.                                  */
  205.  /****************************************************************************/
  206.  userregs = (uint *)&(AppPTB.CS);
  207.  q = rfsv16;
  208.  *(twoc *)regname = *(twoc *) q->rn16;
  209.  for( ; *(twoc *)regname ; ++q, Mask++,*(twoc *)regname = *(twoc *) q->rn16 )
  210.  {
  211.     utox4( *((ushort *)userregs + q->ndx ), x4 + 1 );
  212.     putrc( q->row + VioStartOffSet, Start_Col, regname );               /*701*/
  213.     if (TestBit(RegChgMask,Mask))
  214.       x4[0] = Attrib(vaRegTogg);
  215.     else
  216.       x4[0] = Attrib(vaRegWind);
  217.     putrc( q->row + VioStartOffSet, Start_Col + 4, x4 );                /*701*/
  218.  }
  219.  
  220.  /****************************************************************************/
  221.  /* Get the flags from the AppPTB, Shift out each one by one from the flags. */
  222.  /* The shift is indicated by the shift count for each of the flags in the   */
  223.  /* flag structure.                                                          */
  224.  /* Check the register change mask to determine if the attribute has to be   */
  225.  /* changed for the value being displayed.                                   */
  226.  /****************************************************************************/
  227.  flags = ( ushort )AppPTB.EFlags;
  228.  r = ffs;
  229.  *(twoc *)regname = *(twoc *) r->fn;
  230.  for( ; *(twoc *)regname ; ++r, Mask++,*(twoc *)regname = *(twoc *) r->fn )
  231.  {
  232.     flagvalue[1] = (uchar)'0' + (uchar)((flags>>r->Nsh) & 1);
  233.     putrc( r->row + VioStartOffSet, Start_Col + r->col , regname );     /*701*/
  234.     if (TestBit(RegChgMask,Mask))
  235.       flagvalue[0] = Attrib(vaRegTogg);
  236.     else
  237.       flagvalue[0] = Attrib(vaRegWind);
  238.     putrc( r->row + VioStartOffSet, Start_Col + r->col + 2,flagvalue);  /*701*/
  239.  }
  240.  
  241.  /****************************************************************************/
  242.  /* Set the screen bounds.                                                   */
  243.  /****************************************************************************/
  244.  memset(BoundPtr+VioStartOffSet,VideoCols-REGSWINWIDTH,REGSWINLENGTH);  /*518*/
  245.                                                                         /*701*/
  246. }
  247.  
  248. /*****************************************************************************/
  249. /* GetScrAccess()                                                            */
  250. /*                                                                           */
  251. /* Description:                                                              */
  252. /*      Gets the access to write to screen.                                  */
  253. /* Parameters:                                                               */
  254. /*      none                                                                 */
  255. /* Return:                                                                   */
  256. /*                                                                           */
  257. /* Assumptions:                                                              */
  258. /*      none                                                                 */
  259. /*****************************************************************************/
  260. void GetScrAccess()
  261. {
  262.   if ( (TestBit(Reg_Display,REGS386BIT)) ||
  263.        (TestBit(Reg_Display,REGS387BIT)) )
  264.   {
  265.     memset(BoundPtr+VioStartOffSet,VideoCols,VideoRows-VioStartOffSet); /*701*/
  266.   }
  267. }
  268.  
  269. /*****************************************************************************/
  270. /* SetScrAccess()                                                            */
  271. /*                                                                           */
  272. /* Description:                                                              */
  273. /*      Sets the bounds to prevent writing to screen.                        */
  274. /* Parameters:                                                               */
  275. /*      none                                                                 */
  276. /* Return:                                                                   */
  277. /*                                                                           */
  278. /* Assumptions:                                                              */
  279. /*      none                                                                 */
  280. /*****************************************************************************/
  281. void SetScrAccess()
  282. {
  283.   if (TestBit(Reg_Display,REGS386BIT))
  284.   {
  285.     memset(BoundPtr+VioStartOffSet,
  286.            VideoCols-REGSWINWIDTH,REGSWINLENGTH);                /*518*//*701*/
  287.   }
  288.   if (TestBit(Reg_Display,REGS387BIT))
  289.   {
  290.     memset(BoundPtr+VioStartOffSet,
  291.            VideoCols-COREGSWINWIDTH,COREGSWINLENGTH);            /*518*//*701*/
  292.   }
  293. }
  294.  
  295. /*****************************************************************************/
  296. /* KeyvRegs()                                                                */
  297. /*                                                                           */
  298. /* Description:                                                              */
  299. /*      Display the registers' and flags' contents.                          */
  300. /* Parameters:                                                               */
  301. /*      none                                                                 */
  302. /* Return:                                                                   */
  303. /*                                                                           */
  304. /* Assumptions:                                                              */
  305. /*      none                                                                 */
  306. /*****************************************************************************/
  307.  
  308. AFILE *KeyvRegs(uint *key)
  309. {
  310.  uint   n;
  311.  uint   OldSS, OldSP, OldBP;
  312.  uchar  flagvals[16][2], *mbuf;
  313.  char  *Ivtable[7];
  314.  ULONG  execaddr = 0;
  315.  AFILE *execfp;
  316.  
  317.  /****************************************************************************/
  318.  /* save curretn stack frame registers SS , ESP and EBP                      */
  319.  /****************************************************************************/
  320.  OldSS = AppPTB.SS;
  321.  OldSP = AppPTB.ESP;
  322.  OldBP = AppPTB.EBP;
  323.  
  324.  /****************************************************************************/
  325.  /* Get the current values of flags into an array to be used for the help    */
  326.  /* window for flags.                                                        */
  327.  /****************************************************************************/
  328.  memset(flagvals,0,sizeof(flagvals));
  329.  for( n=0 ; FlagMask[n] ; ++n )
  330.      flagvals[n][0] = (uchar)((AppPTB.EFlags & FlagMask[n]) ? '1' : '0');
  331.  
  332.  /****************************************************************************/
  333.  /* Fill the buffer to be used for displaying help info for flags            */
  334.  /****************************************************************************/
  335.  
  336.  for(n=0;n<7;n++)
  337.   Ivtable[n] = &flagvals[n][0];
  338.  mbuf = GetHelpMsg(HELP_REGS_FLAGS, Ivtable,7);
  339.  
  340.  /****************************************************************************/
  341.  /* Display the help info for flags and let use edit registers and flags     */
  342.  /* Set flag to indicate that registers are editied.                         */
  343.  /****************************************************************************/
  344.  VideoAtr = vaRegWind;
  345.  *key = ShowHelpBox(mbuf,(UINTFUNC)ZapvRegs,NULL,NULL);
  346.  Tfree( (void*)mbuf);                                                    /*521*/
  347.  AppRegsZapped = TRUE;
  348.  
  349.  /****************************************************************************/
  350.  /* - write the registers to esp.                                            */
  351.  /****************************************************************************/
  352.  xWriteRegs( &execaddr,&AppPTB);
  353.  if( execaddr != GetExecAddr() )
  354.  {
  355.   SetExecAddr(execaddr);
  356.   SetExecValues( GetExecTid(), FALSE );
  357.  }
  358.  
  359.  /****************************************************************************/
  360.  /* If any of the stack registers or CS IP have changed, establish the       */
  361.  /* necessary arrays for the current state of users stack.                   */
  362.  /****************************************************************************/
  363.  if ( OldSS != AppPTB.SS || OldSP != AppPTB.ESP|| OldBP != AppPTB.EBP )
  364.     SetActFrames();
  365.  
  366.  /****************************************************************************/
  367.  /* Following the changes set the flag to show the current executing line    */
  368.  /****************************************************************************/
  369.  execfp = SetExecfp();
  370.  if ( execfp != NULL )
  371.  {
  372.   execfp->flags |= AF_ZOOM;
  373.   return( execfp );
  374.  }
  375.  
  376.  return(fp_focus);                      /* return the current fp which    521*/
  377. }
  378.  
  379. /*****************************************************************************/
  380. /* ZapvRegs()                                                                */
  381. /*                                                                           */
  382. /* Description:                                                              */
  383. /*      Let the user edit the registers and flags.                           */
  384. /* Parameters:                                                               */
  385. /*      none                                                                 */
  386. /* Return:                                                                   */
  387. /*      key code of the last key.                                            */
  388. /* Assumptions:                                                              */
  389. /*      none                                                                 */
  390. /*****************************************************************************/
  391. uint ZapvRegs()
  392. {
  393.  uchar   regval16[5];                  /* field for reg16 edited values     */
  394.  uchar   regval32[9];                  /* field for reg32 edited values     */
  395.  uchar   flagval[2];                   /* field for flags edited values     */
  396.  uint    mode;                         /* what type of field we are in      */
  397.  struct  rfsv16 *p16;                  /* -> array of 16-bit reg struct     */
  398.  struct  rfsv32 *p32;                  /* -> array of 32-bit reg struct     */
  399.  struct  ffs *q;                       /* -> array of flag struct           */
  400.  uint    fldlen;                       /* length of field being edited      */
  401.  uint    flagmask;                     /* mask for updating flag in AppPTB  */
  402.  uint    bitpos;                       /* bit position of edited flag       */
  403.  int     csrrow;                       /* cursor row position               */
  404.  int     csrcol;                       /* cursor col position               */
  405.  uint    Start_Col;                    /* column where to start display     */
  406.  uint   *userregs32;                   /* -> to 32bit regs in AppPTB        */
  407.  ushort *userregs16;                   /* -> to 16bit seg regs in AppPTB    */
  408.  uint   *flags;                        /* -> to flags of AppPTB structure   */
  409.  uint    n, key, csroff;               /*                                   */
  410.  
  411.  /***************************************************************************/
  412.  /* Initialise the pointers to the AppPTB structure.                        */
  413.  /***************************************************************************/
  414.  userregs32 = (uint *)&(AppPTB.EAX);   /* cast it to uint *              521*/
  415.  userregs16 = (ushort *)&(AppPTB.CS);
  416.  flags      = (uint *)&(AppPTB.EFlags);/* cast it to uint *              521*/
  417.  
  418.  /***************************************************************************/
  419.  /* Initialise the variables.                                               */
  420.  /***************************************************************************/
  421.  csrcol    = 0;
  422.  csrrow    = 1 + VioStartOffSet;                                       /*701*/
  423.  Start_Col = VideoCols - REGSWINWIDTH + 2;
  424.  
  425.  for(;;)
  426.  {
  427.    /**************************************************************************/
  428.    /* Depending on the cursor row set the mode which indicates what we are   */
  429.    /* editing.                                                               */
  430.    /**************************************************************************/
  431.    if ((csrrow >= (1 + VioStartOffSet)) &&                              /*701*/
  432.        (csrrow <= (9 + VioStartOffSet)))                                /*701*/
  433.       mode = REG32MODE;
  434.    else
  435.    {
  436.       if ((csrrow >= (10 + VioStartOffSet)) &&                          /*701*/
  437.           (csrrow <= (15 + VioStartOffSet)))                            /*701*/
  438.          mode = REG16MODE;
  439.       else
  440.          mode = FLAGSMODE;
  441.    }
  442.    csroff = 0;
  443.  
  444.    /**************************************************************************/
  445.    /* Release the screen bounds. Clear the csrcol field, if we are not in    */
  446.    /* flags mode as it does not make any sense when we are in registers mode */
  447.    /**************************************************************************/
  448.    memset(BoundPtr + VioStartOffSet,VideoCols,VideoRows-VioStartOffSet);/*701*/
  449.    if (mode != FLAGSMODE)
  450.       csrcol = 0;
  451.  
  452.    /**************************************************************************/
  453.    /* If a flag is to be edited, hilite it and init required fields.         */
  454.    /*  - find the flag to be edited                                          */
  455.    /*  - hilite the flag field                                               */
  456.    /*  - set up the field length, shift count and mask for updating flags    */
  457.    /*  - get the key from the KEYSTR function and value into flagval         */
  458.    /*  - if the key is not ESC key and if it is not a blank field update     */
  459.    /*    the flags value                                                     */
  460.    /*  - remove the hilite from the flag field                               */
  461.    /**************************************************************************/
  462.    if (mode == FLAGSMODE)
  463.    {
  464.      for( q = ffs, n = 0; n++ < NOFREGS; ++q )
  465.        if ((csrrow == (q->row + VioStartOffSet)) && (csrcol == q->col))/*701*/
  466.           break;
  467.  
  468.      putrc(csrrow, Start_Col+q->col + 2, fhilite);
  469.  
  470.      fldlen   = 1;
  471.      bitpos   = q->Nsh;
  472.      flagmask = 1;
  473.  
  474.      key = GetString( csrrow, Start_Col + q->col + 2, fldlen, fldlen,
  475.                       &csroff, flagval, BINKEYFLD,NULL );
  476.  
  477.      if ((key != ESC) && (strlen(flagval) != 0))
  478.      {
  479.        if (atou(flagval) == 0)
  480.          *flags  = (*flags) & ~(flagmask << bitpos);
  481.        else
  482.          *flags |= (flagmask << bitpos);
  483.      }
  484.  
  485.      putrc(csrrow,Start_Col+q->col+2, flolite);
  486.    }
  487.  
  488.    /**************************************************************************/
  489.    /* If a 32bit register is to be edited, hilite it and init req fields.    */
  490.    /*  - find the 32bit register to be edited                                */
  491.    /*  - hilite the register field                                           */
  492.    /*  - set up the field length                                             */
  493.    /*  - get the key from the KEYSTR function and value into regval32        */
  494.    /*  - if the key is not ESC key and if it is not a blank field update     */
  495.    /*    the register value                                                  */
  496.    /*  - remove the hilite from the 32bit register field                     */
  497.    /**************************************************************************/
  498.    if ( mode == REG32MODE )
  499.    {
  500.       for( p32 = rfsv32, n = 0; n++ < NO32REGS; ++p32 )
  501.         if (csrrow == (p32->row + VioStartOffSet))                      /*701*/
  502.            break;
  503.  
  504.       putrc(csrrow, Start_Col+4, r32hilite);
  505.       fldlen = 8;
  506.  
  507.       key = GetString( csrrow, Start_Col + 4, fldlen, fldlen,
  508.                        &csroff, regval32, HEXKEYFLD,NULL);
  509.  
  510.       if ((key != ESC) && (strlen(regval32) != 0))
  511.         x8tou( regval32, userregs32 + p32->ndx );
  512.  
  513.       putrc(csrrow, Start_Col+4, r32lolite);
  514.    }
  515.  
  516.    /**************************************************************************/
  517.    /* If a 16bit register is to be edited, hilite it and init req fields.    */
  518.    /*  - find the 16bit register to be edited                                */
  519.    /*  - hilite the register field                                           */
  520.    /*  - set up the field length                                             */
  521.    /*  - get the key from the KEYSTR function and value into regval16        */
  522.    /*  - if the key is not ESC key and if it is not a blank field update     */
  523.    /*    the register value                                                  */
  524.    /*  - remove the hilite from the 16bit register field                     */
  525.    /**************************************************************************/
  526.    if ( mode == REG16MODE )
  527.    {
  528.       for( p16 = rfsv16, n = 0; n++ < NO16REGS; ++p16 )
  529.          if (csrrow == (p16->row + VioStartOffSet))                     /*701*/
  530.             break;
  531.  
  532.       putrc(csrrow, Start_Col+4, r16hilite);
  533.       fldlen = 4;
  534.  
  535.       key = GetString( csrrow, Start_Col + 4, fldlen, fldlen,
  536.                        &csroff, regval16, HEXKEYFLD,NULL );
  537.  
  538.       if ((key != ESC) && (strlen(regval16) != 0))
  539.         x4tou( regval16,userregs16 + p16->ndx);
  540.  
  541.       putrc(csrrow, Start_Col+4, r16lolite);
  542.    }
  543.  
  544.    switch (key)
  545.    {
  546.      case TAB:
  547.      case RIGHT:
  548.      case DATAKEY:
  549.        if (mode == FLAGSMODE)           /* If in FLAGSMODE incr column       */
  550.           csrcol += FCincr;             /*                                   */
  551.        if (csrrow == (REGSWINLENGTH - 2 + VioStartOffSet))              /*701*/
  552.                                         /* If on last row incr column such   */
  553.           csrcol = 12;                  /* that we go back to top.           */
  554.        if ((mode != FLAGSMODE)          /* If we are in register mode or     */
  555.            || (csrcol > 8))             /* colunm is greater than 8 , treat  */
  556.        {                                /* the keys as down key.             */
  557.          if (csrcol > 8)                /* If column is > 8 wrap around to   */
  558.             csrcol = 0;                 /* 1st column.                       */
  559.          goto casedown;
  560. casedown:
  561.      case DOWN:                         /*                                   */
  562.          if (csrrow == (REGSWINLENGTH - 2 + VioStartOffSet))            /*701*/
  563.                                         /* Is it last row                    */
  564.             csrrow = 1 + VioStartOffSet;/*  - yes go back to top          701*/
  565.          else                           /*                                   */
  566.             csrrow += 1;                /*  - no bump to next row            */
  567.        }                                /*                                   */
  568.        break;
  569.  
  570.      case LEFT:
  571.      case S_TAB:
  572.        if (mode == FLAGSMODE)           /* If in FLAGSMODE decr column       */
  573.           csrcol -= FCincr;             /*                                   */
  574.        if ((mode != FLAGSMODE)          /* If we are in register mode or     */
  575.            || (csrcol < 0))             /* colunm is smaller than 0 , treat  */
  576.        {                                /* the keys as up key.               */
  577.          if (csrcol < 0)                /* If column is < 0 wrap around to   */
  578.             csrcol = 8;                 /* last column.                      */
  579.          goto caseup;
  580. caseup:
  581.      case UP:                           /*                                   */
  582.          if (csrrow == (1 + VioStartOffSet))/* Is it first row            701*/
  583.              csrrow = REGSWINLENGTH - 2 + VioStartOffSet;               /*701*/
  584.                                         /*  - yes go back to last            */
  585.          else                           /*                                   */
  586.              csrrow -= 1;               /*  - no bump to previous row        */
  587.        }                                /*                                   */
  588.        break;
  589.  
  590.      case ENTER:
  591.      case ESC:
  592.      case PADPLUS:
  593.        ShowvRegs();
  594.        return(key);
  595.  
  596.      case F1:
  597.        Help(HELP_DLG_EDITREGS);  break;
  598.  
  599.      default:
  600.        beep();
  601.    }                                    /* end switch                        */
  602.    ShowvRegs();                         /* display the regsisters            */
  603.  }                                      /* end of forever loop               */
  604. }                                       /* end ZapRegs                       */
  605.  
  606. /*****************************************************************************/
  607. /* SetRegChgMask()                                                           */
  608. /*                                                                           */
  609. /* Description:                                                              */
  610. /*      Sets the bits in the mask to indicate the register changed after     */
  611. /*      any go.                                                              */
  612. /* Parameters:                                                               */
  613. /*      none                                                                 */
  614. /* Return:                                                                   */
  615. /*                                                                           */
  616. /* Assumptions:                                                              */
  617. /*      none                                                                 */
  618. /*****************************************************************************/
  619. void SetRegChgMask()
  620. {
  621.  ulong *userregs;                       /* user regs in the PTBuffer      521*/
  622.  ulong *Oldregs;                        /* Old regs in the PTBuffer       521*/
  623.  struct rfsv32 *p;                      /* -> to 32bit registers             */
  624.  struct rfsv16 *q;                      /* -> to 16bit segment registers     */
  625.  struct ffs *r;                         /* -> to flags                       */
  626.  ushort Newflags;                       /* Holds the flags from AppPTB       */
  627.  ushort Oldflags;                       /* Holds the flags from OldPTB       */
  628.  uchar  NewflagValue;                   /* Holds the new flag value          */
  629.  uchar  OldflagValue;                   /* Holds the Old flag value          */
  630.  uint   Mask;                           /* mask to set the bits in RegChgmsk */
  631.  
  632.  RegChgMask = 0;
  633.  Mask       = 0x1;
  634.  /****************************************************************************/
  635.  /*  Get pointer to the register in PTB, loop for all 32bit registers.       */
  636.  /*  Set the bit in the mask if the value changes.                           */
  637.  /****************************************************************************/
  638.  userregs = &(AppPTB.EAX);
  639.  Oldregs  = &(OldPTB.EAX);
  640.  for( p = rfsv32; *(fourc *) p->rn32; ++p , Mask <<= 1)
  641.  {
  642.     if ( *(userregs + p->ndx) != *(Oldregs + p->ndx) )
  643.        RegChgMask |= Mask;
  644.  }
  645.  
  646.  /****************************************************************************/
  647.  /*  Get pointer to the segment registers in PTB, loop for all seg regs.     */
  648.  /*  Set the bit in the mask if the value changes.                           */
  649.  /****************************************************************************/
  650.  userregs = (ulong *)&(AppPTB.CS);      /* cast to ulong *                521*/
  651.  Oldregs  = (ulong *)&(OldPTB.CS);      /* cast to ulong *                521*/
  652.  for( q = rfsv16; *(twoc *)q->rn16; ++q,Mask <<= 1)
  653.  {
  654.     if ( *(userregs + p->ndx) != *(Oldregs + p->ndx) )
  655.        RegChgMask |= Mask;
  656.  }
  657.  
  658.  /****************************************************************************/
  659.  /* Get the flags from the PTB, Shift out each one by one from the flags.    */
  660.  /* The shift is indicated by the shift count for each of the flags in the   */
  661.  /* flag structure.                                                          */
  662.  /* Set the bit in the mask if the value changes.                            */
  663.  /****************************************************************************/
  664.  Newflags = ( ushort )AppPTB.EFlags;
  665.  Oldflags = ( ushort )OldPTB.EFlags;
  666.  for( r = ffs; *(twoc *)r->fn; ++r,Mask <<= 1)
  667.  {
  668.     NewflagValue = (uchar)'0' + (uchar)((Newflags>>r->Nsh) & 1);
  669.     OldflagValue = (uchar)'0' + (uchar)((Oldflags>>r->Nsh) & 1);
  670.     if ( NewflagValue != OldflagValue )
  671.        RegChgMask |= Mask;
  672.  }
  673.  
  674.  /****************************************************************************/
  675.  /* Update the old set of register values with the new set of values         */
  676.  /****************************************************************************/
  677.  OldPTB = AppPTB;
  678. }
  679.  
  680. /*****************************************************************************/
  681. /* SetExecLine()                                                          508*/
  682. /*                                                                           */
  683. /* Description:                                                              */
  684. /*                                                                           */
  685. /*   Updates the CS:IP and all related global variables.                     */
  686. /*                                                                           */
  687. /* Parameters:                                                               */
  688. /*                                                                           */
  689. /*   NewIp   -> New Instruction Pointer.                                     */
  690. /*                                                                           */
  691. /* Return:                                                                   */
  692. /*                                                                           */
  693. /*   TRUE    success                                                         */
  694. /*   FALSE   failure                                                         */
  695. /*                                                                           */
  696. /* Assumptions:                                                              */
  697. /*                                                                           */
  698. /*      none                                                                 */
  699. /*                                                                           */
  700. /*****************************************************************************/
  701. uint SetExecLine(uint NewIp)
  702. {
  703.  APIRET  rc;
  704.  
  705.  /****************************************************************************/
  706.  /* - if the address didn't change don't do anything.                        */
  707.  /****************************************************************************/
  708.  if(NewIp == GetExecAddr() )
  709.   return( TRUE );
  710.  
  711.  if( xSetExecAddr( NewIp ) )
  712.   return(FALSE);
  713.  
  714.  /************************************************************************/
  715.  /* - update the exec values after forcing an update of the AppPTB       */
  716.  /*   buffer.                                                            */
  717.  /************************************************************************/
  718.  SetExecValues( GetExecTid(), TRUE );
  719.  
  720.  if(SetExecfp())
  721.     rc = TRUE;
  722.  else
  723.     rc = FALSE;
  724.  
  725.  return(rc);
  726. }
  727. #ifdef MSH
  728. void showvRegs(WINDOW *win)
  729. {
  730.  uint  *userregs;                       /* user regs in the PTBuffer         */
  731.  struct rfsv32 *p;                      /* -> to 32bit registers             */
  732.  struct rfsv16 *q;                      /* -> to 16bit segment registers     */
  733.  struct ffs *r;                         /* -> to flags                       */
  734.  ushort flags;                          /* Holds the flags from AppPTB       */
  735.  uchar  Attribute;                      /* attribute to hold reg win highlit */
  736.  uint   Mask;                           /* mask position to check bits in    */
  737.                                         /* RegChgMask                        */
  738.  char   **screen=(char **)win->user_data;
  739.  --screen;
  740.  /****************************************************************************/
  741.  /* Release the screen bounds.                                               */
  742.  /* If it is the 1st invocation paint the whole register window Box.         */
  743.  /****************************************************************************/
  744.  Mask = 0;
  745.  VideoAtr  = vaRegWind;
  746.  
  747.  /****************************************************************************/
  748.  /* Find the Toggle attribute of the existing color attribute for register   */
  749.  /* window and put it in vaRegTogg position of videomap.                     */
  750.  /****************************************************************************/
  751.  Attribute = VideoMap[vaRegWind];
  752.  Attribute ^= HIGHLIGHT;
  753.  VideoMap[vaRegTogg] = Attribute;
  754.  
  755.  /****************************************************************************/
  756.  /*  Get pointer to the register in AppPTB, loop for all 32bit registers.    */
  757.  /*  Check the register change mask to determine if the attribute has to be  */
  758.  /*  changed for the value being displayed.                                  */
  759.  /****************************************************************************/
  760.  userregs = (uint *)&(AppPTB.EAX);
  761.  p = rfsv32;
  762.  *(fourc *)regname = *(fourc *) p->rn32;
  763.  for(; *(fourc *)regname ; ++p, Mask++, *(fourc *)regname = *(fourc *) p->rn32)
  764.  {
  765.     utox8( *(userregs + p->ndx ), x8 + 1 );
  766.     memset(screen[p->row],' ',80);
  767.     screen[p->row][0]=Attrib(vaRegWind);
  768.     strcpy(screen[p->row]+1, regname );
  769.     if (TestBit(RegChgMask,Mask))
  770.       x8[0] = Attrib(vaRegTogg);
  771.     else
  772.       x8[0] = Attrib(vaRegWind);
  773.     strcpy(screen[p->row]+5, x8 );                /*701*/
  774.  }
  775.  
  776.  /****************************************************************************/
  777.  /*  Get pointer to the segment registers in AppPTB, loop for all seg regs.  */
  778.  /*  Check the register change mask to determine if the attribute has to be  */
  779.  /*  changed for the value being displayed.                                  */
  780.  /****************************************************************************/
  781.  userregs = (uint *)&(AppPTB.CS);
  782.  q = rfsv16;
  783.  *(twoc *)regname = *(twoc *) q->rn16;
  784.  for( ; *(twoc *)regname ; ++q, Mask++,*(twoc *)regname = *(twoc *) q->rn16 )
  785.  {
  786.     utox4( *((ushort *)userregs + q->ndx ), x4 + 1 );
  787.     memset(screen[q->row],' ',80);
  788.     screen[q->row][0]=Attrib(vaRegWind);
  789.     strncpy(screen[q->row]+1, regname , 2);                         /*701*/
  790.     if (TestBit(RegChgMask,Mask))
  791.       x4[0] = Attrib(vaRegTogg);
  792.     else
  793.       x4[0] = Attrib(vaRegWind);
  794.     strcpy(screen[q->row] + 5, x4 );                /*701*/
  795.  }
  796.  
  797.  /****************************************************************************/
  798.  /* Get the flags from the AppPTB, Shift out each one by one from the flags. */
  799.  /* The shift is indicated by the shift count for each of the flags in the   */
  800.  /* flag structure.                                                          */
  801.  /* Check the register change mask to determine if the attribute has to be   */
  802.  /* changed for the value being displayed.                                   */
  803.  /****************************************************************************/
  804.  flags = ( ushort )AppPTB.EFlags;
  805.  r = ffs;
  806.  *(twoc *)regname = *(twoc *) r->fn;
  807.  for( ; *(twoc *)regname ; ++r,*(twoc *)regname = *(twoc *) r->fn )
  808.  {
  809.     memset(screen[r->row],' ',80);
  810.     screen[r->row][0]=Attrib(vaRegWind);
  811.  }
  812.  
  813.  r = ffs;
  814.  *(twoc *)regname = *(twoc *) r->fn;
  815.  for( ; *(twoc *)regname ; ++r, Mask++,*(twoc *)regname = *(twoc *) r->fn )
  816.  {
  817.     flagvalue[1] = (uchar)'0' + (uchar)((flags>>r->Nsh) & 1);
  818.     strncpy(screen[r->row] + (5*r->col/4) + 1, regname, strlen(regname) );     /*701*/
  819.     if (TestBit(RegChgMask,Mask))
  820.       flagvalue[0] = Attrib(vaRegTogg);
  821.     else
  822.       flagvalue[0] = Attrib(vaRegWind);
  823.     strncpy( screen[r->row]+(5*r->col/4)+3,flagvalue,strlen(flagvalue));  /*701*/
  824.  }
  825.  r = ffs;
  826.  *(twoc *)regname = *(twoc *) r->fn;
  827.  for( ; *(twoc *)regname ; ++r,*(twoc *)regname = *(twoc *) r->fn )
  828.  {
  829.   int i;
  830.   for(i=79;i>=0;--i)
  831.       if(screen[r->row][i]==' ')screen[r->row][i]='\0';else break;
  832.  }
  833.  PaintWindow(win);
  834. }
  835. #endif
  836.