Example #1
0
File: emu.cpp Project: nealey/vera
//----------------------------------------------------------------------
int emu(void)
{
  uint32 Feature = cmd.get_canon_feature();
  flow = ((Feature & CF_STOP) == 0);

  if ( Feature & CF_USE1 ) TouchArg(cmd.Op1,1);
  if ( Feature & CF_USE2 ) TouchArg(cmd.Op2,1);
  if ( Feature & CF_JUMP ) QueueMark(Q_jumps,cmd.ea);

  if ( Feature & CF_CHG1 ) TouchArg(cmd.Op1,0);
  if ( Feature & CF_CHG2 ) TouchArg(cmd.Op2,0);

  if ( flow && canFlow() ) ua_add_cref(0,cmd.ea+cmd.size,fl_F);

  switch ( cmd.itype )
  {
    case TMS_ldp:                       // change DP register
    case TMS2_ldp:                      // change DP register
    case TMS2_ldpk:                     // change DP register
      {
        uint v = (cmd.Op1.type == o_imm) ? uint(cmd.Op1.value) : -1u;
        splitSRarea1(get_item_end(cmd.ea),rDP,v,SR_auto);
      }
      break;
  }

  return 1;
}
Example #2
0
int read_test2(TEST_DATA *data, IO_BUFFER *iobuf)
{
   IO_ITEM_HEADER item_header;
   int i;
   
   item_header.type = 99;             /* test data */
   if ( get_item_begin(iobuf,&item_header) < 0 )
   {
      Warning("Missing or invalid test data block.");
      return -4;
   }

   get_vector_of_long(data->lvar,2,iobuf);
   data->ilvar[0] = get_long(iobuf);
   data->ilvar[1] = get_long(iobuf);
   get_vector_of_int(data->isvar,2,iobuf);
   get_vector_of_short(data->svar,3,iobuf);
   get_vector_of_real(data->fvar,2,iobuf);
   get_vector_of_double(data->dvar,2,iobuf);
   data->hvar[0] = get_sfloat(iobuf);
   data->hvar[1] = get_sfloat(iobuf);
   get_vector_of_byte((uint8_t *)data->i8var,2,iobuf);
   get_vector_of_byte(data->u8var,2,iobuf);
   get_vector_of_short(data->i16var,2,iobuf);
   get_vector_of_short((int16_t *)data->u16var,2,iobuf);
   get_vector_of_int32(data->i32var,2,iobuf);
   get_vector_of_uint32(data->u32var,2,iobuf);
#ifdef HAVE_64BIT_INT
   get_vector_of_int64(data->i64var,2,iobuf);
   get_vector_of_uint64(data->u64var,2,iobuf);
#endif
   data->nbvar = get_count(iobuf);
   get_vector_of_byte(data->bvar,2,iobuf);
   for (i=0; i<4; i++)
      data->cnt16var[i] = get_count(iobuf);
   for (i=0; i<6; i++)
      data->cnt32var[i] = get_count(iobuf);
   for (i=0; i<6; i++)
      data->cntzvar[i] = get_count(iobuf);
   for (i=0; i<8; i++)
      data->cntvar[i] = get_count(iobuf);
   for (i=0; i<10; i++)
      data->scnt16var[i] = get_scount16(iobuf);
   for (i=0; i<12; i++)
      data->scnt32var[i] = get_scount32(iobuf);
   for (i=0; i<12; i++)
      data->scntzvar[i] = get_scount(iobuf);
   for (i=0; i<14; i++)
      data->scntvar[i] = get_scount(iobuf);
   get_string(data->str16var,sizeof(data->str16var),iobuf);
   get_long_string(data->str32var,sizeof(data->str32var),iobuf);
   get_var_string(data->strvvar,sizeof(data->strvvar),iobuf);

   return(get_item_end(iobuf,&item_header));
}
Example #3
0
ea_t x86_get_fake_jump(ea_t ea)
{
	unsigned char byte;
	unsigned long l;

	byte = get_byte(ea);
	if (byte == 0xE9)
	{
		l = get_long(ea+1);
		if (l == 0)
			return get_item_end(ea);
	}
	else if (byte == 0xeb)
	{
		byte = get_byte(ea+1);
		if (byte == 0)
			return get_item_end(ea);
	}

	return BADADDR;
}
Example #4
0
ea_t
get_next_code(ea_t start)
{
  segment_t *cs = getseg(start);
  if ( NULL == cs )
   return NULL;

  for ( ; start < cs->endEA; start = get_item_end(start) )
   if ( isCode(start) )
    return start;
  return cs->endEA;
}
Example #5
0
File: emu.cpp Project: nealey/vera
//----------------------------------------------------------------------
int emu(void)
{
  uint32 feature = cmd.get_canon_feature();
  flow = (feature & CF_STOP) == 0;

  if ( feature & CF_USE1 ) process_operand(cmd.Op1, 1);
  if ( feature & CF_USE2 ) process_operand(cmd.Op2, 1);
  if ( feature & CF_USE3 ) process_operand(cmd.Op3, 1);

  if ( feature & CF_CHG1 ) process_operand(cmd.Op1, 0);
  if ( feature & CF_CHG2 ) process_operand(cmd.Op2, 0);
  if ( feature & CF_CHG3 ) process_operand(cmd.Op3, 0);

  // check for CPL changes
  if ((cmd.itype == TMS320C54_rsbx1 || cmd.itype == TMS320C54_ssbx1)
    && cmd.Op1.type == o_reg && cmd.Op1.reg == CPL)
      splitSRarea1(get_item_end(cmd.ea), CPL, cmd.itype == TMS320C54_rsbx1 ? 0 : 1, SR_auto);

  // check for DP changes
  if (cmd.itype == TMS320C54_ld2 && cmd.Op1.type == o_imm && cmd.Op1.dtyp == dt_byte
    && cmd.Op2.type == o_reg && cmd.Op2.reg == DP)
      splitSRarea1(get_item_end(cmd.ea), DP, cmd.Op1.value & 0x1FF, SR_auto);

  // determine if the next instruction should be executed
  if ( segtype(cmd.ea) == SEG_XTRN ) flow = 0;
  if ( flow && delayed_stop() ) flow = 0;
  if ( flow ) ua_add_cref(0,cmd.ea+cmd.size,fl_F);

  if ( may_trace_sp() )
  {
    if ( !flow )
      recalc_spd(cmd.ea);     // recalculate SP register for the next insn
    else
      trace_sp();
  }

  return 1;
}
Example #6
0
File: emu.cpp Project: nealey/vera
//----------------------------------------------------------------------
int emu(void)
{
  uint32 feature = cmd.get_canon_feature();
  flow = (feature & CF_STOP) == 0;

  if ((cmd.auxpref & DBrFlag) == 0)   // У отложенных переходов не надо обрабатывать операнды, т.к.
                                      // регистры и так не обрабатываются, а адр. перехода будет обработан через 3 команды
  {
        if ( feature & CF_USE1 ) process_operand(cmd.Op1, 1);
        if ( feature & CF_USE2 ) process_operand(cmd.Op2, 1);
        if ( feature & CF_USE3 ) process_operand(cmd.Op3, 1);

        if ( feature & CF_CHG1 ) process_operand(cmd.Op1, 0);
        if ( feature & CF_CHG2 ) process_operand(cmd.Op2, 0);
        if ( feature & CF_CHG3 ) process_operand(cmd.Op3, 0);
  }


  if  (GetDelayedBranchAdr() != BADADDR)  // добавить ссылку по отложенному переходу
        ua_add_cref(0, toEA(cmd.cs, GetDelayedBranchAdr()), fl_JN);

  if  (cmd.itype == TMS320C3X_RETScond)  // добавить ссылку по условному выходу
        ua_add_cref(0, cmd.ea, fl_JN);

  // check for DP changes
  if ( ((cmd.itype == TMS320C3X_LDIcond) || (cmd.itype == TMS320C3X_LDI)) && (cmd.Op1.type == o_imm)
    && (cmd.Op2.type == o_reg) && (cmd.Op2.reg == dp))
      splitSRarea1(get_item_end(cmd.ea), dp, cmd.Op1.value & 0xFF, SR_auto);

  // determine if the next instruction should be executed
  if ( segtype(cmd.ea) == SEG_XTRN ) flow = 0;
  if ( flow && delayed_stop() ) flow = 0;
  if ( flow ) ua_add_cref(0,cmd.ea+cmd.size,fl_F);

  if ( may_trace_sp() )
  {
    if ( !flow )
      recalc_spd(cmd.ea);     // recalculate SP register for the next insn
    else
      trace_sp();
  }

  return 1;
}
Example #7
0
File: emu.cpp Project: nealey/vera
//----------------------------------------------------------------------
// change value of virtual register "BANK" and switch to another bank
static void split(int reg, sel_t v)
{
    if ( reg == -1 )
    {
        flow = 0;
        if ( v != BADSEL )
        {
            sel_t pclath = getSR(cmd.ea, PCLATH) & 0x1F;
            ea_t ea = calc_code_mem(uchar(v) | (pclath<<8));
            ua_add_cref(0, ea, fl_JN);
        }
    }
    else
    {
        if ( v == BADSEL ) v = 0;     // assume bank0 if bank is unknown
        if ( reg == BANK )
        {
            if ( ptype != PIC16 ) v &= 3;
            else v &= 0xF;
        }
        splitSRarea1(get_item_end(cmd.ea), reg, v, SR_auto);
    }
}
Example #8
0
int print_histograms (IO_BUFFER *iobuf)
{
   int mhisto, ihisto, rc, ncounts;
   char title[256];
   char type, cdummy;
   long ident;
   unsigned long entries=0, tentries=0;
   int nbins=0, nbins_2d=0, ibin;
   double content=0., content_inside=0.;
   int ls;
   IO_ITEM_HEADER item_header;
   
   if ( iobuf == (IO_BUFFER *) NULL )
      return -1;

   item_header.type = 100;
   if ( (rc = get_item_begin(iobuf,&item_header)) != 0 )
      return rc;
   printf("Histogram block, version %d, size %ld:\n", 
      item_header.version, iobuf->item_length[iobuf->item_level-1]);

   if ( item_header.version < 1 || item_header.version > 2 )
   {
      Warning("Wrong version no. of histogram data to be read");
      return -1;
   }

   mhisto = get_short(iobuf);

   for (ihisto=0; ihisto<mhisto; ihisto++)
   {
      type = (char) get_byte(iobuf);
      if ( (ls = get_string(title,sizeof(title)-1,iobuf)) % 2 == 0 )
         cdummy = get_byte(iobuf); // Compiler may warn about it but this is OK.
      if ( ls < 0 )
         ls = 0;
      else if ( (size_t) ls >= sizeof(title) )
         ls = sizeof(title)-1;
      title[ls] = '\0'; /* Make sure title is properly truncated */
      ident = get_long(iobuf);
      nbins = (int) get_short(iobuf);
      nbins_2d = (int) get_short(iobuf);
      entries = (uint32_t) get_long(iobuf); /* 32 bit number */
      tentries = (uint32_t) get_long(iobuf);
      (void) get_long(iobuf);
      (void) get_long(iobuf);

      // printf("   Histogram %ld of type %c with %dx%d bins and %lu/%lu entries: %s\n",
      //   ident, type,  nbins, nbins_2d, tentries, entries, title);

      if ( type == 'R' || type == 'r' || type == 'F' || type == 'D' )
      {
         (void) get_real(iobuf);
         (void) get_real(iobuf);
         (void) get_real(iobuf);
         (void) get_real(iobuf);
      }
      else if ( type == 'I' || type == 'i' )
      {
         (void) get_long(iobuf);
         (void) get_long(iobuf);
         (void) get_long(iobuf);
         (void) get_long(iobuf);
      }
      else
      {
         printf("   Histogram %ld of type %c with %dx%d bins and %ld/%ld entries: %s\n",
            ident, type,  nbins, nbins_2d, tentries, entries, title);
         Warning("Invalid histogram type");
         return -1;
      }
      if ( nbins_2d > 0 )
      {
         (void) get_long(iobuf);
         (void) get_long(iobuf);
         if ( type == 'R' || type == 'r' || type == 'F' || type == 'D' )
         {
            (void) get_real(iobuf);
            (void) get_real(iobuf);
            (void) get_real(iobuf);
            (void) get_real(iobuf);
         }
         else
         {
            (void) get_long(iobuf);
            (void) get_long(iobuf);
            (void) get_long(iobuf);
            (void) get_long(iobuf);
         }
         ncounts = nbins * nbins_2d;
      }
      else
         ncounts = nbins;

      /* Don't attempt to allocate histograms without data. */
      if ( ncounts <= 0 )
      {
         printf("   Histogram %ld of type %c with %dx%d bins and %lu/%lu entries: %s\n      HAS NO CONTENTS!\n",
            ident, type,  nbins, nbins_2d, tentries, entries, title);
         continue;
      }

      if ( type == 'F' || type == 'D' )
      {
         content = get_real(iobuf);
         content_inside = get_real(iobuf);
         for (ibin=0; ibin<8; ibin++ )
            (void) get_real(iobuf); /* content_outside... in histogram extension */
      }
      if ( tentries > 0 )
         for (ibin=0; ibin<ncounts; ibin++)
            (void) get_long(iobuf); /* long and real is the same length */

      if ( type == 'F' || type == 'D' )
         printf("   Histogram %ld of type %c with %dx%d bins and %lu/%lu entries (contents: %g/%g): %s\n",
            ident, type,  nbins, nbins_2d, tentries, entries, content_inside, content, title);
      else
         printf("   Histogram %ld of type %c with %dx%d bins and %lu/%lu entries: %s\n",
            ident, type,  nbins, nbins_2d, tentries, entries, title);
   }

   if ( (rc = get_item_end(iobuf,&item_header)) != 0 )
      return rc;

   return(mhisto);
}
Example #9
0
int read_histograms_x (HISTOGRAM **phisto, int nhisto, const long *xcld_ids, int nxcld, IO_BUFFER *iobuf)
{
   int mhisto, ihisto, rc, ncounts;
   char title[256];
   char type, cdummy;
   long ident;
   double rlower[2] = {0., 0.}, rupper[2] = {0., 0.}, 
          rsum[2] = {0., 0.}, rtsum[2] = {0., 0.};
   long ilower[2] = {0,0}, iupper[2] = {0,0}, isum[2] = {0,0}, itsum[2] = {0,0};
   long entries=0, tentries=0, underflow[2] = {0,0}, overflow[2] = {0,0};
   int nbins=0, nbins_2d=0, ibin, mbins[2] = {0,0};
   HISTOGRAM *thisto=NULL, *ohisto=NULL;
   IO_ITEM_HEADER item_header;
   int adding = 0;
   
   if  ( nhisto < 0 )
   {
      adding = 1;
      nhisto = -nhisto;
   }

   if ( iobuf == (IO_BUFFER *) NULL )
      return -1;

   item_header.type = 100;
   if ( (rc = get_item_begin(iobuf,&item_header)) != 0 )
      return rc;

   if ( item_header.version < 1 || item_header.version > 2 )
   {
      Warning("Wrong version no. of histogram data to be read");
      return -1;
   }
// fprintf(stderr,"Read histograms called, with %d histograms excluded\n",nxcld);
   mhisto = get_short(iobuf);

   for (ihisto=0; ihisto<mhisto; ihisto++)
   {
      int add_this = 0, exclude_this = 0;
      type = (char) get_byte(iobuf);
      if ( get_string(title,sizeof(title)-1,iobuf) % 2 == 0 )
         cdummy = get_byte(iobuf); // Compiler may warn about it but this is OK.
      ident = get_long(iobuf);
      nbins = (int) get_short(iobuf);
      nbins_2d = (int) get_short(iobuf);
      entries = (uint32_t) get_long(iobuf);
      tentries = (uint32_t) get_long(iobuf);
      underflow[0] = (uint32_t) get_long(iobuf);
      overflow[0] = (uint32_t) get_long(iobuf);
      if ( type == 'R' || type == 'r' || type == 'F' || type == 'D' )
      {
         rlower[0] = get_real(iobuf);
         rupper[0] = get_real(iobuf);
         rsum[0] = get_real(iobuf);
         rtsum[0] = get_real(iobuf);
      }
      else
      {
         ilower[0] = get_long(iobuf);
         iupper[0] = get_long(iobuf);
         isum[0] = get_long(iobuf);
         itsum[0] = get_long(iobuf);
      }
      if ( nbins_2d > 0 )
      {
         underflow[1] = (uint32_t) get_long(iobuf);
         overflow[1] = (uint32_t) get_long(iobuf);
         if ( type == 'R' || type == 'r' || type == 'F' || type == 'D' )
         {
            rlower[1] = get_real(iobuf);
            rupper[1] = get_real(iobuf);
            rsum[1] = get_real(iobuf);
            rtsum[1] = get_real(iobuf);
         }
         else
         {
            ilower[1] = get_long(iobuf);
            iupper[1] = get_long(iobuf);
            isum[1] = get_long(iobuf);
            itsum[1] = get_long(iobuf);
         }
         ncounts = nbins * nbins_2d;
      }
      else
         ncounts = nbins;

      /* Don't attempt to allocate histograms without data. */
      if ( ncounts <= 0 )
         continue;

      if ( xcld_ids != (const long *) NULL && nxcld > 0 )
      {
         int ixcld;
         for ( ixcld=0; ixcld<nxcld && xcld_ids[ixcld] > 0; ixcld++ )
         {
            if ( xcld_ids[ixcld] == ident )
            {
               exclude_this = 1;
               break;
            }
         }
      }

      /* If the histogram has a numerical identifier delete a */
      /* previously existing histogram with the same identifier. */
      ohisto = NULL;
      if ( ident != 0 )
      {
         if ( (ohisto=get_histogram_by_ident(ident)) !=
               (HISTOGRAM *)NULL )
         {
            if ( adding && ! exclude_this )
               add_this = 1;
            else
               free_histogram(ohisto);
         }
      }

      /* (Re-) Allocate the new histogram according to its type. */
      thisto = NULL;
      // if ( ! exclude_this ) /* Would really exclude all histograms of this ID but we just don't want to add it up */
      {
         if ( nbins_2d > 0 )
         {
            if ( type == 'R' || type == 'r' )
               thisto = alloc_2d_real_histogram(rlower[0],rupper[0],nbins,
                   rlower[1],rupper[1],nbins_2d);
            else if ( type == 'F' || type == 'D' )
            {
               mbins[0] = nbins;
               mbins[1] = nbins_2d;
               thisto = allocate_histogram(&type,2,rlower,rupper,mbins);
            }
            else
               thisto = alloc_2d_int_histogram(ilower[0],iupper[0],nbins,
                   ilower[1],iupper[1],nbins_2d);
         }
         else
         {
            if ( type == 'R' || type == 'r' )
               thisto = alloc_real_histogram(rlower[0],rupper[0],nbins);
            else if ( type == 'F' || type == 'D' )
               thisto = allocate_histogram(&type,1,rlower,rupper,&nbins);
            else
               thisto = alloc_int_histogram(ilower[0],iupper[0],nbins);
         }
      }
      
      /* If the allocation failed or the histogram should be excluded, skip the histogram contents. */
      /* This should guarantee that reading the input doesn't get */
      /* confused when there is not enough memory available to allocate */
      /* a histogram. The drawback is that, so far, there is no failure */
      /* indicator for the caller. */
      if ( thisto == (HISTOGRAM *) NULL )
      {
         if ( type == 'F' || type == 'D' )
            for (ibin=0; ibin<10; ibin++ )
               (void) get_real(iobuf); /* contents... in histogram extension */
         if ( tentries > 0 )
            for (ibin=0; ibin<ncounts; ibin++)
               (void) get_long(iobuf); /* long and real is the same length */
         continue;
      }
      else
         thisto->type = type;

      /* Give the histogram its title and identifier. */
      if ( *title )
         describe_histogram(thisto,title,add_this?0:ident);

#ifdef _REENTRANT
      histogram_lock(thisto);
#endif

      /* Set the values for histogram statistics. */
      thisto->entries = entries;
      thisto->tentries = tentries;
      thisto->underflow = underflow[0];
      thisto->overflow = overflow[0];
      if ( type == 'R' || type == 'r' || type == 'F' || type == 'D' )
      {
         thisto->specific.real.sum = rsum[0];
         thisto->specific.real.tsum = rtsum[0];
      }
      else
      {
         thisto->specific.integer.sum = isum[0];
         thisto->specific.integer.tsum = itsum[0];
      }
      if ( nbins_2d > 0 )
      {
         thisto->underflow_2d = underflow[1];
         thisto->overflow_2d = overflow[1];
         if ( type == 'R' || type == 'r' || type == 'F' || type == 'D' )
         {
            thisto->specific_2d.real.sum = rsum[1];
            thisto->specific_2d.real.tsum = rtsum[1];
         }
         else
         {
            thisto->specific_2d.integer.sum = isum[1];
            thisto->specific_2d.integer.tsum = itsum[1];
         }
      }

      /* If wanted and possible, return the pointer to caller. */
      if ( phisto != (HISTOGRAM **) NULL && ihisto < nhisto )
         phisto[ihisto] = (add_this ? ohisto : thisto);

      /* Finally, read the histogram contents. */
      if ( type == 'F' || type == 'D' )
      {
         struct Histogram_Extension *he = thisto->extension;
         he->content_all = get_real(iobuf);
         he->content_inside = get_real(iobuf);
         get_vector_of_real(he->content_outside,8,iobuf);
         if ( type == 'F' )
         {
            if ( thisto->tentries > 0 )
               for ( ibin=0; ibin<ncounts; ibin++ )
                  he->fdata[ibin] = (float) get_real(iobuf);
            else
               for ( ibin=0; ibin<ncounts; ibin++ )
                  he->fdata[ibin] = (float) 0.;
         }
         else
         {
            if ( thisto->tentries > 0 )
               get_vector_of_real(he->ddata,ncounts,iobuf);
            else
               for ( ibin=0; ibin<ncounts; ibin++ )
                  he->ddata[ibin] = 0.;
         }
      }
      else
      {
         if ( thisto->tentries > 0 )
            get_vector_of_long((long *)thisto->counts,ncounts,iobuf);
         else
            for ( ibin=0; ibin<nbins; ibin++ )
               thisto->counts[ibin] = 0;
      }
#ifdef _REENTRANT
      histogram_unlock(thisto);
#endif

      if ( add_this )
      {
// fprintf(stderr,"Adding histogram ID %ld\n", ident);
         add_histogram(ohisto,thisto);
         free_histogram(thisto);
      }

   }

   if ( (rc = get_item_end(iobuf,&item_header)) != 0 )
      return rc;

   return(mhisto);
}
Example #10
0
int read_test3(TEST_DATA *data, IO_BUFFER *iobuf)
{
   IO_ITEM_HEADER item_header1, item_header2;
   int i;
   
   item_header1.type = 990;             /* test data */
   if ( get_item_begin(iobuf,&item_header1) < 0 )
   {
      Warning("Missing or invalid test data block.");
      return -4;
   }

   item_header2.type = 991;             /* test data */
   if ( get_item_begin(iobuf,&item_header2) < 0 )
   {
      Warning("Missing or invalid test data sub-block 1.");
      return -4;
   }

   get_vector_of_long(data->lvar,2,iobuf);
   data->ilvar[0] = get_long(iobuf);
   data->ilvar[1] = get_long(iobuf);
   get_vector_of_int(data->isvar,2,iobuf);
   get_vector_of_short(data->svar,3,iobuf);
   
   get_item_end(iobuf,&item_header2);

   if ( next_subitem_type(iobuf) != 992 )
   {
      Warning("Failed to look ahead for next sub-item type.");
      return -4;
   }

   item_header2.type = 992;             /* test data */
   if ( get_item_begin(iobuf,&item_header2) < 0 )
   {
      Warning("Missing or invalid test data sub-block 2.");
      return -4;
   }

   get_vector_of_real(data->fvar,2,iobuf);
   get_vector_of_double(data->dvar,2,iobuf);
   data->hvar[0] = get_sfloat(iobuf);
   data->hvar[1] = get_sfloat(iobuf);
   get_vector_of_byte((uint8_t *)data->i8var,2,iobuf);
   get_vector_of_byte(data->u8var,2,iobuf);
   get_vector_of_short(data->i16var,2,iobuf);
   get_vector_of_short((int16_t *)data->u16var,2,iobuf);
   get_vector_of_int32(data->i32var,2,iobuf);
   get_vector_of_uint32(data->u32var,2,iobuf);
#ifdef HAVE_64BIT_INT
   get_vector_of_int64(data->i64var,2,iobuf);
   get_vector_of_uint64(data->u64var,2,iobuf);
#endif

   get_item_end(iobuf,&item_header2);
   
   /* Check that non-sequential access to sub-items also works */

   rewind_item(iobuf,&item_header1);

   item_header2.type = 994;             /* test data */
   if ( search_sub_item(iobuf,&item_header1,&item_header2) < 0 )
   {
      Warning("Cannot find test data sub-block 4.");
      return -4;
   }
   if ( get_item_begin(iobuf,&item_header2) < 0 )
   {
      Warning("Missing or invalid test data sub-block 4.");
      return -4;
   }

   get_string(data->str16var,sizeof(data->str16var),iobuf);
   get_long_string(data->str32var,sizeof(data->str32var),iobuf);
   get_var_string(data->strvvar,sizeof(data->strvvar),iobuf);

   get_item_end(iobuf,&item_header2);

   rewind_item(iobuf,&item_header1);

   item_header2.type = 993;             /* test data */
   if ( search_sub_item(iobuf,&item_header1,&item_header2) < 0 )
   {
      Warning("Cannot find test data sub-block 3.");
      return -4;
   }
   if ( get_item_begin(iobuf,&item_header2) < 0 )
   {
      Warning("Missing or invalid test data sub-block 3.");
      return -4;
   }

   data->nbvar = get_count(iobuf);
   get_vector_of_byte(data->bvar,2,iobuf);
   for (i=0; i<4; i++)
      data->cnt16var[i] = get_count(iobuf);
   for (i=0; i<6; i++)
      data->cnt32var[i] = get_count(iobuf);
   for (i=0; i<6; i++)
      data->cntzvar[i] = get_count(iobuf);
   for (i=0; i<8; i++)
      data->cntvar[i] = get_count(iobuf);
   for (i=0; i<10; i++)
      data->scnt16var[i] = get_scount16(iobuf);
   for (i=0; i<12; i++)
      data->scnt32var[i] = get_scount32(iobuf);
   for (i=0; i<12; i++)
      data->scntzvar[i] = get_scount(iobuf);
   for (i=0; i<14; i++)
      data->scntvar[i] = get_scount(iobuf);

   get_item_end(iobuf,&item_header2);

   return(get_item_end(iobuf,&item_header1));
}
Example #11
0
File: emu.cpp Project: nealey/vera
//----------------------------------------------------------------------
int emu(void)
{
  if ( segtype(cmd.ea) == SEG_XTRN ) return 1;

  //uint32 Feature = cmd.get_canon_feature();
  int flag1 = is_forced_operand(cmd.ea, 0);
  int flag2 = is_forced_operand(cmd.ea, 1);
  int flag3 = is_forced_operand(cmd.ea, 2);

//      Determine if the next instruction should be executed
  flow = (InstrIsSet(cmd.itype, CF_STOP) != true);



  if ( InstrIsSet(cmd.itype,CF_USE1) ) process_operand(cmd.Op1, flag1, 1);
  if ( InstrIsSet(cmd.itype,CF_USE2) ) process_operand(cmd.Op2, flag2, 1);
  if ( InstrIsSet(cmd.itype,CF_USE3) ) process_operand(cmd.Op3, flag3, 1);

  if ( InstrIsSet(cmd.itype,CF_CHG1) ) process_operand(cmd.Op1, flag1, 0);
  if ( InstrIsSet(cmd.itype,CF_CHG2) ) process_operand(cmd.Op2, flag2, 0);
  if ( InstrIsSet(cmd.itype,CF_CHG3) ) process_operand(cmd.Op3, flag3, 0);


  // check for DP changes
  if ( cmd.itype == OAK_Dsp_lpg )
                splitSRarea1(get_item_end(cmd.ea), PAGE, cmd.Op1.value & 0xFF, SR_auto);
  if ( ( cmd.itype == OAK_Dsp_mov ) && (cmd.Op1.type == o_imm) && (cmd.Op2.type == o_reg) && (cmd.Op2.reg == ST1) )
                splitSRarea1(get_item_end(cmd.ea), PAGE, cmd.Op1.value & 0xFF, SR_auto);


  //Delayed Return

  insn_t saved = cmd;
  cycles = cmd.cmd_cycles;
  delayed = false;

  if ( decode_prev_insn(cmd.ea) != BADADDR )
  {
          if  ( (cmd.itype == OAK_Dsp_retd) || (cmd.itype == OAK_Dsp_retid) )
                  delayed = true;
          else
                  cycles += cmd.cmd_cycles;

          if (!delayed)
                if ( decode_prev_insn(cmd.ea) != BADADDR )
                        if ( (cmd.itype == OAK_Dsp_retd) || (cmd.itype == OAK_Dsp_retid) )
                                delayed = true;
  }

  if (delayed && (cycles > 1) )
          flow = 0;

  cmd = saved;

  //mov #imm, pc

  if ( ( cmd.itype == OAK_Dsp_mov ) && (cmd.Op2.type == o_reg) && (cmd.Op2.reg == PC) )
     flow = 0;

  if ( flow ) ua_add_cref(0,cmd.ea+cmd.size,fl_F);

  if ( may_trace_sp() )
  {
    if ( !flow )
      recalc_spd(cmd.ea);     // recalculate SP register for the next insn
    else
      trace_sp();
  }

  return 1;
}