示例#1
0
bool DirectiveInclude(ArgumentList& List, int flags)
{
	std::wstring fileName = getFullPathName(List[0].text);

	TextFile::Encoding encoding = TextFile::GUESS;
	if (List.size() == 2)
		encoding = getEncodingFromString(List[1].text);

	int FileNum = Global.FileInfo.FileNum;
	int LineNum = Global.FileInfo.LineNumber;
	if (fileExists(fileName) == false)
	{
		Logger::printError(Logger::Error,L"Included file \"%s\" does not exist",fileName.c_str());
		return false;
	}
	LoadAssemblyFile(fileName,encoding);
	Global.FileInfo.FileNum = FileNum;
	Global.FileInfo.LineNumber = LineNum;
	return true;
}
示例#2
0
文件: main.cpp 项目: Blade2187/armips
int wmain(int argc, wchar_t* argv[])
{
	Global.Radix = 10;
	Global.Revalidate = true;
	Global.Section = 0;
	Global.nocash = false;
	Global.IncludeNestingLevel = 0;
	Global.FileInfo.FileCount = 0;
	Global.FileInfo.TotalLineCount = 0;
	Global.DebugMessages = 0;
	Global.relativeInclude = false;
	Global.warningAsError = false;
	Global.validationPasses = 0;
	Arch = &InvalidArchitecture;

	Logger::printLine("ARMIPS Assembler v0.7d ("__DATE__" "__TIME__") by Kingcom");
	StringList arguments = getStringListFromArray(argv,argc);

	if (arguments.size() < 2)
	{
		Logger::printLine("Usage: armips.exe file.asm [-temp temp.txt] [-sym symfile.sym]");
		return 1;
	}

	if (fileExists(arguments[1]) == false)
	{
		Logger::printLine("File %S not found\n",arguments[1].c_str());
		return 1;
	}

	int argpos = 2;
	while (argpos < (int)arguments.size())
	{
		if (arguments[argpos] == L"-temp")
		{
			Global.tempData.setFileName(arguments[argpos+1]);
			argpos += 2;
		} else if (arguments[argpos] == L"-sym")
		{
			Global.symData.setNocashSymFileName(arguments[argpos+1]);
			argpos += 2;
		} else if (arguments[argpos] == L"-exsym")
		{
			Global.symData.setExSymFileName(arguments[argpos+1]);
			argpos += 2;
		} else if (arguments[argpos] == L"-erroronwarning")
		{
			Global.warningAsError = true;
			argpos += 1;
		} else {
			Logger::printLine("Invalid parameter %S\n",arguments[argpos].c_str());
			return 1;
		}
	}

	LoadAssemblyFile(arguments[1]);
	if (Logger::hasError())
	{
		Logger::printLine("Aborting.");
		return 1;
	}

	if (EncodeAssembly() == true)
	{
		Logger::printLine("Done.");
	} else {
		Logger::printLine("Aborting.");
		return 1;
	}
	return 0;
}
示例#3
0
bool runAssembler(AssemblerArguments& arguments)
{
	// initialize and reset global data
	Global.Radix = 10;
	Global.Revalidate = true;
	Global.Section = 0;
	Global.nocash = false;
	Global.IncludeNestingLevel = 0;
	Global.MacroNestingLevel = 0;
	Global.FileInfo.FileCount = 0;
	Global.FileInfo.TotalLineCount = 0;
	Global.DebugMessages = 0;
	Global.relativeInclude = false;
	Global.validationPasses = 0;
	Arch = &InvalidArchitecture;

	Logger::clear();
	Global.symData.clear();
	Global.Table.clear();
	Global.symbolTable.clear();
	Global.tempData.clear();
	Global.conditionData.clear();
	Global.areaData.clear();
	Global.Commands.clear();
	Global.Macros.clear();

	Global.FileInfo.FileList.Clear();
	Global.FileInfo.FileCount = 0;
	Global.FileInfo.TotalLineCount = 0;
	Global.FileInfo.LineNumber = 0;
	Global.FileInfo.FileNum = 0;

	Arm.clear();

	// process arguments
	Logger::setSilent(arguments.silent);
	Logger::setErrorOnWarning(arguments.errorOnWarning);

	if (!arguments.symFileName.empty())
		Global.symData.setNocashSymFileName(arguments.symFileName,arguments.symFileVersion);

	if (!arguments.exSymFileName.empty())
		Global.symData.setExSymFileName(arguments.exSymFileName);

	if (!arguments.tempFileName.empty())
		Global.tempData.setFileName(arguments.tempFileName);

	for (size_t i = 0; i < arguments.equList.size(); i++)
	{
		std::wstring equline = arguments.equList.at(i);
		CheckEquLabel(equline);
	}

	// run assembler
	LoadAssemblyFile(arguments.inputFileName);
	bool result = !Logger::hasError();
	if (result == true)
		result = EncodeAssembly();

	// return errors
	if (arguments.errorsResult != NULL)
	{
		StringList errors = Logger::getErrors();
		for (size_t i = 0; i < errors.size(); i++)
			arguments.errorsResult->push_back(errors[i]);
	}

	// cleanup
	for (size_t i = 0; i < Global.Commands.size(); i++)
		delete Global.Commands[i];	

	for (size_t i = 0; i < Global.Macros.size(); i++)
		delete Global.Macros[i];

	Global.Commands.clear();
	Global.Macros.clear();

	return result;
}