void ParseCommandLine()
{
TRY_CATCH

	int nArgc = 0;
	// Extract arguments from command line
	PTCHAR* pArgs = CHelper::CommandLineToArgv(
			GetCommandLine(),
			&nArgc
		);

	if (!pArgs)
		return;

	// Create shared pointer for auto destroy pArgs handle
	boost::shared_ptr< boost::remove_pointer<HGLOBAL>::type > spArgs((HGLOBAL)pArgs, GlobalFree);

	tstring param(_T(""));
	while(*(++pArgs))
	{
		param.assign(*pArgs);
		tstring paramName = param.substr(0, 3);
		paramName = UpperCase(paramName);
		param.erase(0, 3);
		if(!paramName.compare(_T("-P=")))
		{
			SETTINGS_INSTANCE.SetLocalPort(atoi(param.c_str()));
		}
		else
		{
			if(!paramName.compare(_T("-GT")))
			{
				SETTINGS_INSTANCE.SetUseGarbageThread(true);
			}
			else
			{
				if(!paramName.compare(_T("-T=")))
				{
					SETTINGS_INSTANCE.SetTestTime(atoi(param.c_str()));
				}
				else
				{
					if(!paramName.compare(_T("-SG")))
					{
						SETTINGS_INSTANCE.SetSendGarbage(true);
					}
				}
			}
		}
	}

	return;

CATCH_THROW()
}
void ParseCommandLine()
{
    TRY_CATCH

    int nArgc = 0;
    // Extract arguments from command line
    PTCHAR* pArgs = CHelper::CommandLineToArgv(
                        GetCommandLine(),
                        &nArgc
                    );

    if (!pArgs)
        return;

    // Create shared pointer for auto destroy pArgs handle
    boost::shared_ptr< boost::remove_pointer<HGLOBAL>::type > spArgs((HGLOBAL)pArgs, GlobalFree);

    tstring param(_T(""));
    while(*(++pArgs))
    {
        param.assign(*pArgs);
        tstring paramName = param.substr(0, 3);
        paramName = UpperCase(paramName);
        param.erase(0, 3);

        if( !paramName.compare(_T("-A=")) )
            SETTINGS_INSTANCE.SetRemoteAddr(param);

        else if( !paramName.compare(_T("-P=")) )
            SETTINGS_INSTANCE.SetRemotePort(atoi(param.c_str()));

        else if( !paramName.compare(_T("-F=")) )
            SETTINGS_INSTANCE.SetFramesFileName(param);

        else if( !paramName.compare(_T("-AS")) )
            SETTINGS_INSTANCE.SetClientAutoStart(true);

        else if( !paramName.compare(_T("-R=")) )
            SETTINGS_INSTANCE.SetResultsFileName(param);

        else if( !paramName.compare(_T("-AE")) )
            SETTINGS_INSTANCE.SetAnalyzeEmptySpace(true);

        else if( !paramName.compare(_T("-M=")) )
            SETTINGS_INSTANCE.SetDisplayMode(atoi(param.c_str()));

        else if ( !paramName.compare(_T("-MS")) )
            SETTINGS_INSTANCE.SetMultiplexMode(true);
    }

    return;

    CATCH_THROW()
}
Beispiel #3
0
void AssemFunc::finalise() {
	// Add the necessary commands to the top and bottom of the function, 
	// depending on if the function is the main entry point, and whether the
	// local stack pointer needs to be moved or not

	// NB: Front intrsuctions are done in reverse

	if (_name == "main") {
		vector<string> args;
		args.push_back("r0");
		args.push_back("#0");
		addBack("mov", args);
	}

	if (_stackPointer > 0) {
		// Only do this if we actually need to move the pointer, avoid 
		// sub sp sp #0 and the like.
		vector<string> spArgs(2, "sp");
		spArgs.push_back("#" + boost::lexical_cast<string>(_stackPointer));
		addFront("sub", spArgs);

		vector<string> fpArgs;
		fpArgs.push_back("fp");
		fpArgs.push_back("sp");
		fpArgs.push_back("#4");
		addFront("add", fpArgs);

		fpArgs.clear();
		fpArgs.push_back("sp");
		fpArgs.push_back("fp");
		fpArgs.push_back("#4");
		addBack("sub", fpArgs);
	} else if (_pointerByReg != "") {

		if (_pointerByReg[0] == '.') {
			// size is in a label
			string tempReg = _freeRegs.front();

			vector<string> spArgs(2, "sp");
			spArgs.push_back(tempReg);
			addFront("sub", spArgs);

			spArgs.clear();
			spArgs.push_back(tempReg);
			spArgs.push_back(_pointerByReg);
			addFront("ldr", spArgs);
		} else {
			vector<string> spArgs(2, "sp");
			spArgs.push_back(_pointerByReg);
			addFront("sub", spArgs);
		}

		vector<string> fpArgs;
		fpArgs.push_back("fp");
		fpArgs.push_back("sp");
		fpArgs.push_back("#4");
		addFront("add", fpArgs);

		fpArgs.clear();
		fpArgs.push_back("sp");
		fpArgs.push_back("fp");
		fpArgs.push_back("#4");
		addBack("sub", fpArgs);
	}

	if (_name == "main") {
		vector<string> args;
		args.push_back("sp!");
		args.push_back("{fp, lr}");
		addFront("stmfd", args);

		args.clear();
		args.push_back("sp!");
		args.push_back("{fp, pc}");
		addBack("ldmfd", args);

		addFront("main:", vector<string>());

		vector<string> globArgs(1, _name);
		addFront(".global", globArgs);
	} else {
		vector<string> args;
		args.push_back("sp!");
		args.push_back("{r4-r10, fp, lr}");
		addFront("stmfd", args);

		args.clear();
		args.push_back("sp!");
		args.push_back("{r4-r10, fp, pc}");
		addBack("ldmfd", args);

		addFront(_name + ":", vector<string>());
	}

	vector<string> alignArgs(1, "2");
	addFront(".align", alignArgs);

}