Esempio n. 1
0
int wmain(int argc, wchar_t* argv[])
{
	ArmipsArguments parameters;

#ifdef ARMIPS_TESTS
	std::wstring name;

	if (argc < 2)
		return !runTests(L"Tests");
	else
		return !runTests(argv[1]);
#endif

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

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

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

	size_t argpos = 2;
	while (argpos < arguments.size())
	{
		if (arguments[argpos] == L"-temp")
		{
			parameters.tempFileName = arguments[argpos+1];
			argpos += 2;
		} else if (arguments[argpos] == L"-sym")
		{
			parameters.symFileName = arguments[argpos+1];
			parameters.symFileVersion = 1;
			argpos += 2;
		} else if (arguments[argpos] == L"-sym2")
		{
			parameters.symFileName = arguments[argpos+1];
			parameters.symFileVersion = 2;
			argpos += 2;
		} else if (arguments[argpos] == L"-erroronwarning")
		{
			parameters.errorOnWarning = true;
			argpos += 1;
		} else if (arguments[argpos] == L"-equ")
		{
			std::wstring name = arguments[argpos + 1];
			std::wstring replacement = arguments[argpos + 2];
			parameters.equList.push_back(name + L" equ " + replacement);
			argpos += 3;
		} else {
			Logger::printLine(L"Invalid parameter %S\n",arguments[argpos]);
			return 1;
		}
	}

	bool result = runArmips(parameters);
	if (result == false)
	{
		Logger::printLine(L"Aborting.");
		return 1;
	}
	
	Logger::printLine(L"Done.");
	return 0;
}
Esempio n. 2
0
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;
}