예제 #1
0
void ChangeRegisterValue()
{
  cout << "\tEnter 'c' to skip this mode and continue \n";
  while ( true )
    {
      string t1="",t2="";
      cout << "Register (r0-r11) : ";
      cin >> t1;
      if (t1 == "c")
	break ;
      if (RG.Registers.find(t1) == RG.Registers.end())
	{
	  cout << "\tError in register value . Not changing value . ";
	}
      else
	{
	  cout << "New Contents (in Hex) : ";
	  cin >> t2;
	  if (CheckHex(t2) == false)
	    {
	      cout << "Error in value . Did not change .\n";
	    }
	  else
	    {
	      RG.value_of_register[RG.Registers[t1]] = HexToBin(t2);
	    }
	}
    }
}
예제 #2
0
uint32_t ParseFlags(std::string string)
{
    if(CheckHex(string))
    {
        return HexToInt(string);
    }
    else
    {
        uint32_t flags = 0;
        std::vector<std::string> v = Explode(string, "|");
        for(std::vector<std::string>::iterator it = v.begin(); it != v.end(); ++it)
        {
            std::string par = ToLower(Trim((*it)));
            if(!par.length()) continue;
            uint32_t flag = 0;
            bool erase = false;
            if(par[0] == '-')
            {
                erase = true;
                par.erase(0, 1);
            }

            if(par == "pvm")
                flag = SVF_PVM;
            else if(par == "muted")
                flag = SVF_MUTED;
            else if(par == "closed")
                flag = SVF_CLOSED;
            else if(par == "advanced_pvm")
                flag = SVF_ADVPVM;
			else if(par == "nohealing")
				flag = SVF_NOHEALING;
			else if(par == "noobsrv")
				flag = SVF_NOOBSRV;
			else if(par == "softcore")
				flag = SVF_SOFTCORE;
			else if(par == "nodrop")
				flag = SVF_NODROP;
			else if(par == "fnodrop")
				flag = SVF_FNODROP;

            if(!flag) continue;
            if(!erase) flags |= flag;
            else flags &= ~flag;
        }

        return flags;
    }
}
예제 #3
0
bool SetBreakPoints()
{
  string tmp ;
  int in,c=0;
  cout << "Enter -1 as address of break-point to quit from this mode\n";
  while ( true )
    {
      cout << "bp"<<c++<<" : ";
      cin >> tmp; // Hex Code 
      if (tmp == "-1")
	break;
      if (CheckHex(tmp) == false )
	{
	  cout << "Invalid Hex value . Quitting . \n";
	  return false ;
	}
      breaks.insert(Value(HexToBin(tmp).c_str()));
    }
  return true ;
}
예제 #4
0
bool Scan_input(MemoryIO & Mem , ALU & ALU1 , RegisterFile & RG)
{
	char codef[100];
	FILE * filepointer;
	bool flag = false;
	do
	{
		cout << "\n\tPlease enter the program file : ";
		cin >> codef;
		filepointer = fopen(codef,"r");
		if (errno)
		{
			perror("Invalid Entry : ");
		}
		else
			flag = true;
		errno = 0;
	}
	while (flag == false );
	fclose(filepointer);
	//	Creating the label table
	{
		ifstream fin(codef);
		string str1="" , str2="" , str3="";
		int line = 0  , l = 0;
		while (TRUE)
		{
			fin >> str1; // Always a new instruction
			if (fin.eof()) // Code end
			{
				break;
			}
			if (str1=="brk")
			{
				breaks.insert(line);
				continue;
			}
			l = str1.length();
			if (str1[l-1]==':')
			{
				//Label Handle
				if (labels.find(str1)!=labels.end())
				{
					cout << "Error : Redefinition of label  : " <<str1<<"\n";
					return false ;
				}
				if (CheckHex(str1) == true )
				{
					cout << "The labels cannot be valid Hexadecimal numbers. Please change the label " << str1<<"\n\n";
					return false ;
				}
				// check if label is an instruction
				if (ALU1.SelectBits.count(str1) != 0)
				{
					cout << "Error. Instruction defined as a label : "<<str1<<"\n";
					return false;
				}
				labels.insert(str1);
				label_lookup[str1] = line;
				continue ;
			}
			if (str1[0]=='r' ) // Return Statement
			{
				line++;
				continue;
			}
			if (inst_len[str1] == 4)
			{
				fin >> str2;// Register Value is scanned
				line++;
			}
			if (inst_len[str1] == 8 )
			{
				line++;
			}
			if (str1[0]=='j' || (str1[0]=='c' && (str1[1]=='d' || str1[1]=='r'))) // Jump or Call instruction
			{
				line++;
				if (str1[l-2]=='d' || str1[l-3]=='d')  // only if a direct inst.
				{
					line++;
					fin >> str2;
				}
			}