Example #1
0
cs_err M680X_instprinter_init(cs_struct *ud)
{
#ifndef CAPSTONE_DIET

	if (M680X_REG_ENDING != ARR_SIZE(s_reg_names)) {
		fprintf(stderr, "Internal error: Size mismatch in enum "
			"m680x_reg and s_reg_names\n");

		return CS_ERR_MODE;
	}

	if (M680X_INS_ENDING != ARR_SIZE(s_instruction_names)) {
		fprintf(stderr, "Internal error: Size mismatch in enum "
			"m680x_insn and s_instruction_names\n");

		return CS_ERR_MODE;
	}

	if (M680X_GRP_ENDING != ARR_SIZE(s_group_names)) {
		fprintf(stderr, "Internal error: Size mismatch in enum "
			"m680x_group_type and s_group_names\n");

		return CS_ERR_MODE;
	}

#endif

	return CS_ERR_OK;
}
Example #2
0
// given internal insn id, return public instruction info
void Sparc_get_insn_id(cs_struct *h, cs_insn *insn, unsigned int id)
{
	unsigned short i;

	i = insn_find(insns, ARR_SIZE(insns), id, &h->insn_cache);
	if (i != 0) {
		insn->id = insns[i].mapid;

		if (h->detail) {
#ifndef CAPSTONE_DIET
			memcpy(insn->detail->regs_read, insns[i].regs_use, sizeof(insns[i].regs_use));
			insn->detail->regs_read_count = (uint8_t)count_positive(insns[i].regs_use);

			memcpy(insn->detail->regs_write, insns[i].regs_mod, sizeof(insns[i].regs_mod));
			insn->detail->regs_write_count = (uint8_t)count_positive(insns[i].regs_mod);

			memcpy(insn->detail->groups, insns[i].groups, sizeof(insns[i].groups));
			insn->detail->groups_count = (uint8_t)count_positive8(insns[i].groups);

			if (insns[i].branch || insns[i].indirect_branch) {
				// this insn also belongs to JUMP group. add JUMP group
				insn->detail->groups[insn->detail->groups_count] = SPARC_GRP_JUMP;
				insn->detail->groups_count++;
			}
#endif
			// hint code
			for (i = 0; i < ARR_SIZE(insn_hints); i++) {
				if (id == insn_hints[i].id) {
					insn->detail->sparc.hint = insn_hints[i].hints;
					break;
				}
			}
		}
	}
}
Example #3
0
// given internal insn id, return public instruction info
void Mips_get_insn_id(cs_struct *h, cs_insn *insn, unsigned int id)
{
	unsigned int i;

	// consider alias insn first
	for (i = 0; i < ARR_SIZE(alias_insns); i++) {
		if (alias_insns[i].id == id) {
			insn->id = alias_insns[i].mapid;

			if (h->detail) {
#ifndef CAPSTONE_DIET
				memcpy(insn->detail->regs_read, alias_insns[i].regs_use, sizeof(alias_insns[i].regs_use));
				insn->detail->regs_read_count = (uint8_t)count_positive(alias_insns[i].regs_use);

				memcpy(insn->detail->regs_write, alias_insns[i].regs_mod, sizeof(alias_insns[i].regs_mod));
				insn->detail->regs_write_count = (uint8_t)count_positive(alias_insns[i].regs_mod);

				memcpy(insn->detail->groups, alias_insns[i].groups, sizeof(alias_insns[i].groups));
				insn->detail->groups_count = (uint8_t)count_positive8(alias_insns[i].groups);

				if (alias_insns[i].branch || alias_insns[i].indirect_branch) {
					// this insn also belongs to JUMP group. add JUMP group
					insn->detail->groups[insn->detail->groups_count] = MIPS_GRP_JUMP;
					insn->detail->groups_count++;
				}

#endif
			}
			return;
		}
	}

	i = insn_find(insns, ARR_SIZE(insns), id, &h->insn_cache);
	if (i != 0) {
		insn->id = insns[i].mapid;

		if (h->detail) {
#ifndef CAPSTONE_DIET
			memcpy(insn->detail->regs_read, insns[i].regs_use, sizeof(insns[i].regs_use));
			insn->detail->regs_read_count = (uint8_t)count_positive(insns[i].regs_use);

			memcpy(insn->detail->regs_write, insns[i].regs_mod, sizeof(insns[i].regs_mod));
			insn->detail->regs_write_count = (uint8_t)count_positive(insns[i].regs_mod);

			memcpy(insn->detail->groups, insns[i].groups, sizeof(insns[i].groups));
			insn->detail->groups_count = (uint8_t)count_positive8(insns[i].groups);

			if (insns[i].branch || insns[i].indirect_branch) {
				// this insn also belongs to JUMP group. add JUMP group
				insn->detail->groups[insn->detail->groups_count] = MIPS_GRP_JUMP;
				insn->detail->groups_count++;
			}
#endif
		}
	}
}
Example #4
0
/*
 * FormCmsTopn copies current count-min sketch and new top-n array into a new
 * CmsTopn. This function is called only when there is an update in top-n and it
 * only copies ArrayType part if allocated memory is enough for new ArrayType.
 * Otherwise, it allocates new memory and copies all CmsTopn.
 */
static CmsTopn *
FormCmsTopn(CmsTopn *cmsTopn, ArrayType *newTopnArray)
{
	Size staticSize = sizeof(CmsTopn);
	Size sketchSize = cmsTopn->sketchDepth * cmsTopn->sketchWidth * sizeof(Frequency);
	Size sizeWithoutTopnArray = staticSize + sketchSize;
	Size topnArrayReservedSize = VARSIZE(cmsTopn) - sizeWithoutTopnArray;
	Size newTopnArraySize = ARR_SIZE(newTopnArray);
	Size newCmsTopnSize = 0;
	char *newCmsTopn = NULL;
	char *topnArrayOffset = NULL;

	/*
	 * Check whether we have enough memory for new top-n array. If not, we need
	 * to allocate more memory and copy CmsTopn and new top-n array.
	 */
	if (newTopnArraySize > topnArrayReservedSize)
	{
		Size newItemsReservedSize = 0;
		Size newTopnArrayReservedSize = 0;
		uint32 topnItemCount = cmsTopn->topnItemCount;

		/*
		 * Calculate average top-n item size in the new top-n array and use
		 * two times of it for each top-n item while allocating new memory.
		 */
		Size averageTopnItemSize = (Size) (newTopnArraySize / topnItemCount);
		Size topnItemSize = averageTopnItemSize * 2;
		cmsTopn->topnItemSize = topnItemSize;

		newItemsReservedSize = topnItemCount * topnItemSize;
		newTopnArrayReservedSize = TOPN_ARRAY_OVERHEAD + newItemsReservedSize;
		newCmsTopnSize = sizeWithoutTopnArray + newTopnArrayReservedSize;
		newCmsTopn = palloc0(newCmsTopnSize);

		/* first copy until to top-n array */
		memcpy(newCmsTopn, (char *)cmsTopn, sizeWithoutTopnArray);

		/* set size of new CmsTopn */
		SET_VARSIZE(newCmsTopn, newCmsTopnSize);
	}
	else
	{
		newCmsTopn = (char *)cmsTopn;
	}

	/* finally copy new top-n array */
	topnArrayOffset = ((char *) newCmsTopn) + sizeWithoutTopnArray;
	memcpy(topnArrayOffset, newTopnArray, ARR_SIZE(newTopnArray));

	return (CmsTopn *) newCmsTopn;
}
Example #5
0
int main(void)
{
	int	array[] = {4,2,56,32,7,2,6,8,6,3,5,7};
	int j, k, incr, n, tmp;

	n = ARR_SIZE(array);
	incr =  n / 2;

	PRINT_OUT(array, k, n)

	while( incr > 0 ) {
		//printf("-\n");
		for(j=incr; j<n; j++) {
			k = j - incr;
			//printf("+ k = %d k + incr = %d\n", k, k + incr);
			while( k>=0 ) {
				if ( array[k] > array[k + incr]) {
					SWAP(array[k], array[k + incr], tmp)
					k = k - incr;
					//`printf("=\n");
				} else {
					k = -1;
				}
			}
		} // for(i=incr+1; i<n; i++)
		incr = incr / 2;
	} // while( incr > 0 )

	PRINT_OUT(array, k, n)

	return 0;
}
Example #6
0
static void update_strategy(){
  if (!showing_time){
    Layer *root_window = window_get_root_layer(window_strategy);
    srand(time(0));
    char* text = strategies[rand() % ARR_SIZE(strategies)];
    GRect bounds = layer_get_bounds(root_window);
    text_layer = text_layer_create((GRect) { .origin = { 0, 0}, .size = { bounds.size.w, bounds.size.h } });
bool HTTPSourceMMIExtensionEventHandler::HTTPMMIEventQManager<T>::Peek
(
 T& eventToRead
)
{
  bool bOk = false;

  //Check if the queue is already empty, if not get the event from
  //the queue
  if (IsQEmpty())
  {
    QTV_MSG_PRIO( QTVDIAG_STREAMING, QTVDIAG_PRIO_MEDIUM,
                  "MMIEventQManager - MMI event queue empty" );
  }
  else
  {
    (void)MM_CriticalSection_Enter(m_hEventQLock);
    if (m_nEventReadIndex < ARR_SIZE(m_eventQ))
    {
      bOk = true;
      eventToRead = m_eventQ[m_nEventReadIndex];

      QTV_MSG_PRIO2( QTVDIAG_STREAMING, QTVDIAG_PRIO_MEDIUM,
                     "MMIEventQManager - Peeked event from index %u, "
                     "%u events remain", m_nEventReadIndex, m_nOutstandingEvents );
    }
    (void)MM_CriticalSection_Leave(m_hEventQLock);
  }

  return bOk;
}
LRESULT CViewHexEdit::OnWmCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{ 
    uMsg, wParam, lParam, bHandled; 
	HRESULT hr = E_FAIL;

    CREATESTRUCT * pCreateStruct = reinterpret_cast<CREATESTRUCT *>(lParam); 

    LRESULT lRet = S_OK; 
    lRet = DefWindowProc(uMsg, wParam, lParam); 

    { 
        CComPtr<IUnknown> punkCtrl; 
        CComVariant v; 

        OLECHAR szGUID[MAX_PATH] = { 0 }; 
        StringFromGUID2(__uuidof(HexEditor::HexEdit), szGUID, ARR_SIZE(szGUID)); 

        // Create the AX host window. And Create the HexEdit control using its GUID. 
        HWND hHost = m_wndAxHost.Create ( m_hWnd, rcDefault, szGUID, WS_CHILD | WS_VISIBLE , 
            0, ID_DISPATCH_HEXEDIT ); 

		hr = m_wndAxHost.QueryControl(&m_spHexEdit);
		ATLASSERT( SUCCEEDED(hr) );

        // Begin sinking events 
        AtlAdviseSinkMap ( this, true ); 
    } 

    bHandled = FALSE; 

    return lRet; 
} 
Example #9
0
void lcd_Redraw()
{
	uint_t i, nBus;
	__packed uint32_t *pData, *pEnd;
	uint32_t nData;
	p_dev_spi p;

	p = spi_Get(GUI_LCD_COMID, OS_TMO_FOREVER);
	spi_Config(p, SPI_SCKIDLE_LOW, SPI_LATCH_1EDGE, 0);
#if SPI_SEL_ENABLE
	spi_CsSel(p, GUI_LCD_CSID);
#endif
	spi_Start(p);
	sys_GpioSet(tbl_bspLcdCtrl[0] + 2, 0);
	for (i = 0; i < ARR_SIZE(uc1698_tblParam); i++)
		spi_SendChar(p, uc1698_tblParam[i]);
	spi_SendChar(p, UC1698_SetBR | UC1698_Bias_10);
	spi_SendChar(p, UC1698_SetPM);
	spi_SendChar(p, 192);
	
	sys_GpioSet(tbl_bspLcdCtrl[0] + 2, 1);
	pData = (__packed uint32_t *)&gui_aBuf[0][0];
	pEnd = (__packed uint32_t *)ARR_ENDADR(gui_aBuf);
	for (; pData < pEnd; pData = (__packed uint32_t *)((uint8_t *)pData + 3)) {
		nData = *pData;
		for (i = 0; i < 24; i += 3, nData >>= 3) {
			nBus = uc1698_tbl_map[nData & 0x07];
			spi_SendChar(p, nBus >> 8);
			spi_SendChar(p, nBus);
		}
	}
	spi_End(p);
	spi_Release(p);
}
Example #10
0
GCD_CIB *
gcd_new_cib( u_i2 count )
{
    GCD_CIB	*cib = NULL;
    u_i2	len = sizeof( GCD_CIB ) + (sizeof(CONN_PARM) * (count - 1));

    if ( count < ARR_SIZE( GCD_global.cib_free ) )
	if (! (cib = (GCD_CIB *)QUremove(GCD_global.cib_free[count].q_next)))
	    if ( (cib = (GCD_CIB *)MEreqmem( 0, len, FALSE, NULL )) )
		cib->id = GCD_global.cib_total++;

    if ( ! cib )
	gcu_erlog(0, GCD_global.language, E_GC4808_NO_MEMORY, NULL, 0, NULL);
    else  
    {
	u_i4	id = cib->id;
	char	buff[16];

	MEfill( len, 0, (PTR)cib );
	cib->id = id;
	cib->parm_max = count;
	QUinit( &cib->caps );

	MOulongout( 0, (u_i8)cib->id, sizeof( buff ), buff );
	MOattach( MO_INSTANCE_VAR, GCD_MIB_DBMS, buff, (PTR)cib );

	GCD_global.cib_active++;

	if ( GCD_global.gcd_trace_level >= 6 )
	    TRdisplay( "%4d    GCD new CIB (%d)\n", -1, cib->id );
    }

    return( cib );
}
Example #11
0
void ARM_get_insn_id(cs_struct *h, cs_insn *insn, unsigned int id)
{
	int i = insn_find(insns, ARR_SIZE(insns), id, &h->insn_cache);
	//printf(">> id = %u\n", id);
	if (i != 0) {
		insn->id = insns[i].mapid;

		if (h->detail) {
#ifndef CAPSTONE_DIET
			cs_struct handle;
			handle.detail = h->detail;

			memcpy(insn->detail->regs_read, insns[i].regs_use, sizeof(insns[i].regs_use));
			insn->detail->regs_read_count = (uint8_t)count_positive(insns[i].regs_use);

			memcpy(insn->detail->regs_write, insns[i].regs_mod, sizeof(insns[i].regs_mod));
			insn->detail->regs_write_count = (uint8_t)count_positive(insns[i].regs_mod);

			memcpy(insn->detail->groups, insns[i].groups, sizeof(insns[i].groups));
			insn->detail->groups_count = (uint8_t)count_positive8(insns[i].groups);

			insn->detail->arm.update_flags = cs_reg_write((csh)&handle, insn, ARM_REG_CPSR);

			if (insns[i].branch || insns[i].indirect_branch) {
				// this insn also belongs to JUMP group. add JUMP group
				insn->detail->groups[insn->detail->groups_count] = ARM_GRP_JUMP;
				insn->detail->groups_count++;
			}
#endif
		}
	}
}
Example #12
0
// Hacky: enable all features for disassembler
static uint64_t Mips_getFeatureBits(int mode)
{
	int i;
	uint64_t Bits = 0;
	for (i = 0; i < ARR_SIZE(MipsFeatureKV); i++) {
		Bits |= MipsFeatureKV[i].Value;
	}

	// ref: MipsGenDisassemblerTables.inc::checkDecoderPredicate()
	if (mode & CS_MODE_16) {
		Bits -= Mips_FeatureMips32r2;
		Bits -= Mips_FeatureMips32;
		Bits -= Mips_FeatureFPIdx;
		Bits -= Mips_FeatureBitCount;
		Bits -= Mips_FeatureSwap;
		Bits -= Mips_FeatureSEInReg;
		Bits -= Mips_FeatureMips64r2;
		// Bits -= Mips_FeatureFP64Bit;	// FIXME???
	} else if (mode & CS_MODE_32) {
		Bits -= Mips_FeatureMips16;
		Bits -= Mips_FeatureMicroMips;
		Bits -= Mips_FeatureFP64Bit;
	} else if (mode & CS_MODE_64) {
		Bits -= Mips_FeatureMips16;
		Bits -= Mips_FeatureMicroMips;
	}

	return Bits;
}
Example #13
0
// map internal raw register to 'public' register
sparc_reg Sparc_map_register(unsigned int r)
{
	static const unsigned int map[] = { 0,
		SPARC_REG_ICC, SPARC_REG_Y, SPARC_REG_F0, SPARC_REG_F2, SPARC_REG_F4,
		SPARC_REG_F6, SPARC_REG_F8, SPARC_REG_F10, SPARC_REG_F12, SPARC_REG_F14,
		SPARC_REG_F16, SPARC_REG_F18, SPARC_REG_F20, SPARC_REG_F22, SPARC_REG_F24,
		SPARC_REG_F26, SPARC_REG_F28, SPARC_REG_F30, SPARC_REG_F32, SPARC_REG_F34,
		SPARC_REG_F36, SPARC_REG_F38, SPARC_REG_F40, SPARC_REG_F42, SPARC_REG_F44,
		SPARC_REG_F46, SPARC_REG_F48, SPARC_REG_F50, SPARC_REG_F52, SPARC_REG_F54,
		SPARC_REG_F56, SPARC_REG_F58, SPARC_REG_F60, SPARC_REG_F62, SPARC_REG_F0,
		SPARC_REG_F1, SPARC_REG_F2, SPARC_REG_F3, SPARC_REG_F4, SPARC_REG_F5,
		SPARC_REG_F6, SPARC_REG_F7, SPARC_REG_F8, SPARC_REG_F9, SPARC_REG_F10,
		SPARC_REG_F11, SPARC_REG_F12, SPARC_REG_F13, SPARC_REG_F14, SPARC_REG_F15,
		SPARC_REG_F16, SPARC_REG_F17, SPARC_REG_F18, SPARC_REG_F19, SPARC_REG_F20,
		SPARC_REG_F21, SPARC_REG_F22, SPARC_REG_F23, SPARC_REG_F24, SPARC_REG_F25,
		SPARC_REG_F26, SPARC_REG_F27, SPARC_REG_F28, SPARC_REG_F29, SPARC_REG_F30,
		SPARC_REG_F31, SPARC_REG_FCC0, SPARC_REG_FCC1, SPARC_REG_FCC2, SPARC_REG_FCC3,
		SPARC_REG_G0, SPARC_REG_G1, SPARC_REG_G2, SPARC_REG_G3, SPARC_REG_G4,
		SPARC_REG_G5, SPARC_REG_G6, SPARC_REG_G7, SPARC_REG_I0, SPARC_REG_I1,
		SPARC_REG_I2, SPARC_REG_I3, SPARC_REG_I4, SPARC_REG_I5, SPARC_REG_FP,
		SPARC_REG_I7, SPARC_REG_L0, SPARC_REG_L1, SPARC_REG_L2, SPARC_REG_L3,
		SPARC_REG_L4, SPARC_REG_L5, SPARC_REG_L6, SPARC_REG_L7, SPARC_REG_O0,
		SPARC_REG_O1, SPARC_REG_O2, SPARC_REG_O3, SPARC_REG_O4, SPARC_REG_O5,
		SPARC_REG_SP, SPARC_REG_O7, SPARC_REG_F0, SPARC_REG_F4, SPARC_REG_F8,
		SPARC_REG_F12, SPARC_REG_F16, SPARC_REG_F20, SPARC_REG_F24, SPARC_REG_F28,
		SPARC_REG_F32, SPARC_REG_F36, SPARC_REG_F40, SPARC_REG_F44, SPARC_REG_F48,
		SPARC_REG_F52, SPARC_REG_F56, SPARC_REG_F60,
	};

	if (r < ARR_SIZE(map))
		return map[r];

	// cannot find this register
	return 0;
}
Example #14
0
const char *M680X_group_name(csh handle, unsigned int id)
{
#ifndef CAPSTONE_DIET
	return id2name(s_group_names, ARR_SIZE(s_group_names), id);
#else
	return NULL;
#endif
}
Example #15
0
sparc_cc Sparc_map_FCC(const char *name)
{
	unsigned int i;

	i = name2id(alias_fcc_maps, ARR_SIZE(alias_fcc_maps), name);

	return (i != -1)? i : SPARC_CC_INVALID;
}
Example #16
0
const char *BPF_group_name(csh handle, unsigned int id)
{
#ifndef CAPSTONE_DIET
	return id2name(group_name_maps, ARR_SIZE(group_name_maps), id);
#else
	return NULL;
#endif
}
Example #17
0
void servo_setup()
{
	unsigned int idx;
	for (idx = 0; idx < ARR_SIZE(servoPins); idx++) {
		pinMode(servoPins[idx], OUTPUT);
		pulseWidth[idx] = minPulse;
	}
}
Example #18
0
// map instruction name to instruction ID (public)
sparc_reg Sparc_map_insn(const char *name)
{
	unsigned int i;

	// NOTE: skip first NULL name in insn_name_maps
	i = name2id(&insn_name_maps[1], ARR_SIZE(insn_name_maps) - 1, name);

	return (i != -1)? i : SPARC_REG_INVALID;
}
Example #19
0
// given internal insn id, return operand access info
uint8_t *ARM_get_op_access(cs_struct *h, unsigned int id)
{
	int i = insn_find(insns, ARR_SIZE(insns), id, &h->insn_cache);
	if (i != 0) {
		return insn_ops[i].access;
	}

	return NULL;
}
Example #20
0
static void lcd_SetPara()
{
	uint_t i;

	for (i = 0; i < ARR_SIZE(uc1698_tblParam); i++)
		lcd_WriteCmd(uc1698_tblParam[i]);
	lcd_SetBR(0x80);
	lcd_SetPM(0);
}
/*
 * get_flat_size method for expanded arrays
 */
static Size
EA_get_flat_size(ExpandedObjectHeader *eohptr)
{
	ExpandedArrayHeader *eah = (ExpandedArrayHeader *) eohptr;
	int			nelems;
	int			ndims;
	Datum	   *dvalues;
	bool	   *dnulls;
	Size		nbytes;
	int			i;

	Assert(eah->ea_magic == EA_MAGIC);

	/* Easy if we have a valid flattened value */
	if (eah->fvalue)
		return ARR_SIZE(eah->fvalue);

	/* If we have a cached size value, believe that */
	if (eah->flat_size)
		return eah->flat_size;

	/*
	 * Compute space needed by examining dvalues/dnulls.  Note that the result
	 * array will have a nulls bitmap if dnulls isn't NULL, even if the array
	 * doesn't actually contain any nulls now.
	 */
	nelems = eah->nelems;
	ndims = eah->ndims;
	Assert(nelems == ArrayGetNItems(ndims, eah->dims));
	dvalues = eah->dvalues;
	dnulls = eah->dnulls;
	nbytes = 0;
	for (i = 0; i < nelems; i++)
	{
		if (dnulls && dnulls[i])
			continue;
		nbytes = att_addlength_datum(nbytes, eah->typlen, dvalues[i]);
		nbytes = att_align_nominal(nbytes, eah->typalign);
		/* check for overflow of total request */
		if (!AllocSizeIsValid(nbytes))
			ereport(ERROR,
					(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
					 errmsg("array size exceeds the maximum allowed (%d)",
							(int) MaxAllocSize)));
	}

	if (dnulls)
		nbytes += ARR_OVERHEAD_WITHNULLS(ndims, nelems);
	else
		nbytes += ARR_OVERHEAD_NONULLS(ndims);

	/* cache for next time */
	eah->flat_size = nbytes;

	return nbytes;
}
Example #22
0
bool BufDemuxer::Demux(MpegPlayer& plyr)
{
    io::stream& strm = *plyr.inpStrm;
    int cnt = strm.raw_read(rawBuf, ARR_SIZE(rawBuf));
    // пока поток (файл) не закончился
    bool res = strm;
    if( res )
        res = Demux((uint8_t*)rawBuf, (uint8_t*)rawBuf+cnt, plyr) ? false : true ;
    return res;
}
Example #23
0
// map instruction name to public instruction ID
mips_reg Mips_map_insn(const char *name)
{
	// handle special alias first
	unsigned int i;

	// NOTE: skip first NULL name in insn_name_maps
	i = name2id(&insn_name_maps[1], ARR_SIZE(insn_name_maps) - 1, name);

	return (i != -1)? i : MIPS_REG_INVALID;
}
Example #24
0
File: vm.c Project: q6r/risc
INST_NAME get_inst_name(const u8 opcode)
{
    size_t i;
    for (i = 0; i < ARR_SIZE(inst_table); i++) {
        if (inst_table[i].opcode == opcode) {
            return inst_table[i].name;
        }
    }
    return INVALID_OPCODE;
}
Example #25
0
File: vm.c Project: q6r/risc
inst get_instruction(const u8 opcode)
{
    size_t i;
    for (i = 0; i < ARR_SIZE(inst_table); i++) {
        if (inst_table[i].opcode == opcode)
            return inst_table[i];
    }
    return (inst) {
        INVALID_OPCODE, "InvalidOp", opcode, NULL};	// TODO INVALID INSTRUCTION
}
Example #26
0
// exposes an assert failure when encoding unsigned 64 bit integers (#VDB-539), case 2
FIXTURE_TEST_CASE(IRZIP_u64_assert2, EncoderFixture)
{
    uint64_t y[]={
        UINT64_C(353878216), 
        UINT64_C(353878152), 
        UINT64_C(        0), 
        UINT64_C(        0), 
        UINT64_C(        0), 
        UINT64_C(        0), 
        UINT64_C(        0), 
        UINT64_C(        0), 
        UINT64_C(        0), 
        UINT64_C(        0)
    };
    uint64_t decoded[ARR_SIZE(y)];
    REQUIRE_RC(doEncode_u64(dst, dSize, &used, min, slope, &series_count, &planes, y, ARR_SIZE(y)));
    REQUIRE_RC(doDecode_u64(decoded, ARR_SIZE(y), min, slope, series_count, planes, dst, used));
    REQUIRE_EQ_ARR(y, decoded, ARR_SIZE(y));
}
Example #27
0
// exposes an assert failure when encoding unsigned 64 bit integers (#VDB-539), case 1
FIXTURE_TEST_CASE(IRZIP_u64_assert1, EncoderFixture)
{
    uint64_t y[]={
        UINT64_C(353878216), 
        UINT64_C(353878152), 
        UINT64_C(353877873), 
        UINT64_C(353877162), 
        UINT64_C(353876785), 
        UINT64_C(353875727), 
        UINT64_C(353874605), 
        UINT64_C(353873979), 
        UINT64_C(353873604), 
        UINT64_C(353872503)
    };
    uint64_t decoded[ARR_SIZE(y)];
    REQUIRE_RC(doEncode_u64(dst, dSize, &used, min, slope, &series_count, &planes, y, ARR_SIZE(y)));
    REQUIRE_RC(doDecode_u64(decoded, ARR_SIZE(y), min, slope, series_count, planes, dst, used));
    REQUIRE_EQ_ARR(y, decoded, ARR_SIZE(y));
}
Example #28
0
// encoding/decoding of signed 32 bit integers
FIXTURE_TEST_CASE(IRZIP_i32_assert1, EncoderFixture)
{
    int32_t y[]={
        78216, 
        78152, 
        -77873, 
        -77162, 
        -76785, 
        75727, 
        74605, 
        -73979, 
        -73604, 
        72503
    };
    int32_t decoded[ARR_SIZE(y)];
    REQUIRE_RC(doEncode_i32(dst, dSize, &used, min, slope, &series_count, &planes, y, ARR_SIZE(y)));
    REQUIRE_RC(doDecode_i32(decoded, ARR_SIZE(y), min, slope, series_count, planes, dst, used));
    REQUIRE_EQ_ARR(y, decoded, ARR_SIZE(y));
}
Example #29
0
// exposes an assert failure when encoding unsigned 64 bit integers, case 3
FIXTURE_TEST_CASE(IRZIP_u64_assert3, EncoderFixture)
{
    uint64_t y[]={
        UINT64_C( 388750),
        UINT64_C( 490295),
        UINT64_C( 813277),
        UINT64_C( 725540),
        UINT64_C(  85294),
        UINT64_C( 178363),
        UINT64_C(1607062),
        UINT64_C( 825545),
        UINT64_C( 474451),
        UINT64_C( 745337),
    };
    uint64_t decoded[ARR_SIZE(y)];
    REQUIRE_RC(doEncode_u64(dst, dSize, &used, min, slope, &series_count, &planes, y, ARR_SIZE(y)));
    REQUIRE_RC(doDecode_u64(decoded, ARR_SIZE(y), min, slope, series_count, planes, dst, used));
    REQUIRE_EQ_ARR(y, decoded, ARR_SIZE(y));
}
Example #30
0
// tries to expose the same assert failure as above (#VDB-539), using 32 bit integers (#VDB-539), case 2
FIXTURE_TEST_CASE(IRZIP_u32_assert2, EncoderFixture)
{
    uint32_t y[]={
        78216, 
        78152, 
        0, 
        0, 
        0, 
        0, 
        0, 
        0, 
        0, 
        0
    };
    uint32_t decoded[ARR_SIZE(y)];
    REQUIRE_RC(doEncode_u32(dst, dSize, &used, min, slope, &series_count, &planes, y, ARR_SIZE(y)));
    REQUIRE_RC(doDecode_u32(decoded, ARR_SIZE(y), min, slope, series_count, planes, dst, used));
    REQUIRE_EQ_ARR(y, decoded, ARR_SIZE(y));
}