Display proper error messages when assembling failed

This commit is contained in:
Kingcom 2013-09-01 10:21:05 +02:00
parent 17086b65c3
commit 2a56694626
3 changed files with 27 additions and 8 deletions

View File

@ -6,6 +6,22 @@
namespace MIPSAsm
{
char errorMessage[512];
void SetAssembleError(char* format, ...)
{
va_list args;
va_start(args,format);
vsprintf(errorMessage,format,args);
va_end (args);
}
char* GetAssembleError()
{
return errorMessage;
}
void SplitLine(const char* Line, char* Name, char* Arguments)
{
while (*Line == ' ' || *Line == '\t') Line++;
@ -166,9 +182,9 @@ bool CMipsInstruction::Load(char* Name, char* Params, int RamPos)
{
if (paramfail == true)
{
// PrintError(ERROR_ERROR,"Parameter failure \"%s\"",Params);
SetAssembleError("Parameter failure \"%s\"",Params);
} else {
// PrintError(ERROR_ERROR,"Invalid opcode \"%s\"",Name);
SetAssembleError("Invalid opcode \"%s\"",Name);
}
}
return false;
@ -301,7 +317,7 @@ bool CMipsInstruction::Validate()
if (num > 0x20000 || num < (-0x20000))
{
//QueueError(ERROR_ERROR,"Branch target %08X out of range",Vars.Immediate);
SetAssembleError("Branch target %08X out of range",Vars.Immediate);
return false;
}
Vars.Immediate = num >> 2;
@ -312,7 +328,7 @@ bool CMipsInstruction::Validate()
case MIPS_IMMEDIATE5:
if (Vars.Immediate > 0x1F)
{
// QueueError(ERROR_ERROR,"Immediate value %02X out of range",Vars.OriginalImmediate);
SetAssembleError("Immediate value %02X out of range",Vars.OriginalImmediate);
return false;
}
break;
@ -321,7 +337,7 @@ bool CMipsInstruction::Validate()
case MIPS_IMMEDIATE16:
if (abs(Vars.Immediate) > 0x0000FFFF)
{
// QueueError(ERROR_ERROR,"Immediate value %04X out of range",Vars.OriginalImmediate);
SetAssembleError("Immediate value %04X out of range",Vars.OriginalImmediate);
return false;
}
Vars.Immediate &= 0x0000FFFF;
@ -329,7 +345,7 @@ bool CMipsInstruction::Validate()
case MIPS_IMMEDIATE20:
if (abs(Vars.Immediate) > 0x000FFFFF)
{
// QueueError(ERROR_ERROR,"Immediate value %08X out of range",Vars.OriginalImmediate);
SetAssembleError("Immediate value %08X out of range",Vars.OriginalImmediate);
return false;
}
Vars.Immediate &= 0x000FFFFF;
@ -337,7 +353,7 @@ bool CMipsInstruction::Validate()
case MIPS_IMMEDIATE26:
if (abs(Vars.Immediate) > 0x03FFFFFF)
{
// QueueError(ERROR_ERROR,"Immediate value %08X out of range",Vars.OriginalImmediate);
SetAssembleError("Immediate value %08X out of range",Vars.OriginalImmediate);
return false;
}
Vars.Immediate &= 0x03FFFFFF;

View File

@ -39,4 +39,6 @@ private:
u32 encoding;
};
char* GetAssembleError();
}

View File

@ -314,7 +314,8 @@ void CtrlDisAsmView::assembleOpcode(u32 address, std::string defaultText)
MIPSComp::jit->ClearCacheAt(address - 4, 8);
redraw();
} else {
MessageBox(wnd,L"Couldn't assemble.",L"Error",MB_OK);
std::wstring error = ConvertUTF8ToWString(MIPSAsm::GetAssembleError());
MessageBox(wnd,error.c_str(),L"Error",MB_OK);
}
}