Beispiel #1
0
DWORD _c_FasmAssemble(char * szSource, DWORD nMemorySize, DWORD nPassesLimit)
{
	DWORD dwFasmReturn;
	//_C_FASM_STATE *fasm_state;

	if (strlen(szSource) == 0)
		return NULL;

	if (nPassesLimit == 0)
		nPassesLimit = DEFAULT_PASS_LIMIT;

	if (nMemorySize == 0)
		nMemorySize = DEFAULT_MEMORY_SIZE;


	if (_c_fasm_memorybuf)
		delete[] _c_fasm_memorybuf;

	_c_fasm_memorybuf = new BYTE[nMemorySize];

	dwFasmReturn = fasm_Assemble(szSource, _c_fasm_memorybuf, nMemorySize, nPassesLimit);

	//fasm_state = reinterpret_cast<_C_FASM_STATE *>(_c_fasm_memorybuf);

	return dwFasmReturn;
}
Beispiel #2
0
void FasmCompile()
{
    int len = SendMessage(hWinInput, SCI_GETTEXTLENGTH, NULL, NULL);
    if (len > 0)
    {
        char* buff = new char[len + 1];
        SendMessage(hWinInput, SCI_GETTEXT, len + 1, (LPARAM)buff);

        fasm_Assemble(buff, memBuff, sizeof(memBuff), 100, 0);
        FASM_STATE* state = reinterpret_cast<FASM_STATE*>(memBuff);

        std::stringstream ss;

        if (state->condition == FasmCondition::OK)
        {
            PrintHex(state->output_data, state->output_length, ss);
        }
        else if (state->condition == FasmCondition::FERROR)
        {
            ss << "Error: " << FasmErrorToString(state->error_code) << " at line " << state->error_data->line_number;
        }
        else
        {
            ss << "Error: " << FasmConditionToString(state->condition);
        }

        std::string output = ss.str();
        SendMessage(hWinOutput, SCI_SETTEXT, output.length(), (LPARAM)output.c_str());

        delete buff;
    }
}