Exemplo n.º 1
0
/* ==================================================================================
	Function name:	ParseAddress
 	Arguments:			unsigned int * address
 	 	 	 	 		unsigned int * index
 	 	 	 	 		unsigned int * tag
	Returns:			void
	Description:		Address processing function (bit shifting utility function)
   ================================================================================== */
void ParseAddress(unsigned int * address, unsigned int * index, unsigned int * tag)
{
	unsigned int numOffsetBits = ConvertToBase(cacheStatistics.lineSize);
	unsigned int numIndexBits = ConvertToBase(cacheStatistics.numSets);
	unsigned int addressSize = ADDR_SIZE;
	unsigned int numTagBits = addressSize - (numOffsetBits + numIndexBits);
	//printf("\n%d, %d, %d, %d",addressSize, numOffsetBits, numIndexBits, numTagBits);
	*index = ((*address) << numTagBits) >> (numOffsetBits + numTagBits);
	*tag = (*address) >> (numOffsetBits + numIndexBits);
}
Exemplo n.º 2
0
/* ==================================================================================
	Function name: GetLineAddress
 	Arguments:        unsigned int address for trace file address
	Returns:             unsigned int for beginning of the cache line address
	Description:        Gets the beginning of the cache line address, from the trace file address
   ================================================================================== */
unsigned int GetLineAddress(unsigned int address)
{
	unsigned int numOffsetBits, mask, i;

	mask = 0;
	numOffsetBits = ConvertToBase(cacheStatistics.lineSize);
	mask = ~mask;

	for(i = 0; i < numOffsetBits; ++i)
	{
		mask &= ~(1 << i);
	}

#ifdef DEBUG
	printf("Original address(byte address) = %#x\n", address);
#endif

	address &= mask;

#ifdef DEBUG
	printf("Address of the beginning of the line = %#x\n", address);
#endif

	return address;
}
Exemplo n.º 3
0
int main(int argc, char *argv[]){
	int num = atoi(argv[1]);
	int num2 = atoi(argv[2]);
	printf("The argument in int is %d\n",num );
	printf("The base in int is %d\n",num2 );
	//ConvertBinary(num);
	printf("test\n");

	ConvertToBase(num, num2);
	return 0;
}
Exemplo n.º 4
0
void
CMVarNode::VarTreeNodeX()
{
	itsValueCommand		= NULL;
	itsIsPointerFlag	= kJFalse;
	itsValidFlag		= !itsValue.IsEmpty();
	itsNewValueFlag		= kJFalse;
	itsContentCommand	= NULL;

	itsShouldUpdateFlag = kJFalse;	// window is always initially hidden
	itsNeedsUpdateFlag  = kJFalse;

	itsBase               = 0;
	itsCanConvertBaseFlag = kJFalse;
	itsOrigValue          = NULL;
	ConvertToBase();
}
Exemplo n.º 5
0
void
CMVarNode::SetValue
	(
	const JString& value
	)
{
	itsNewValueFlag = JI2B(!itsValue.IsEmpty() && value != itsValue);
	itsValue        = value;	// set *after* checking value

	itsValue.TrimWhitespace();
	if (itsOrigValue != NULL)
		{
		itsOrigValue->Clear();
		}
	ConvertToBase();

	JTree* tree;
	if (!itsCanConvertBaseFlag && GetTree(&tree))
		{
		tree->BroadcastChange(this);
		}
}
int main(int argc, char *argv[])
{
	if(argc!=4){
		printf("Wrong number of arguments\n");
		return 0;
	}
	char *s;
	int q,base1,base2;
	
	
	base1 = atoi(argv[1]);
	base2 = atoi(argv[2]);
	s = argv[3];	
		
	char temp;
	if (checkbase(s,base1))
	{
		q=base10(s,base1);
		ConvertToBase(q,base2);
	}
	else
	printf("Output: 0\n");	
	return 0;
}