mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Change register value by "assembling" "reg=value"
This commit is contained in:
parent
2ec48b0154
commit
7ba00fa65f
1 changed files with 45 additions and 0 deletions
|
@ -452,6 +452,24 @@ void CtrlDisAsmView::parseDisasm(const char* disasm, char* opcode, char* argumen
|
|||
*arguments = 0;
|
||||
}
|
||||
|
||||
std::string trimString(std::string input)
|
||||
{
|
||||
int pos = input.find_first_not_of(" \t");
|
||||
if (pos != 0 && pos != std::string::npos)
|
||||
{
|
||||
input = input.erase(0,pos);
|
||||
}
|
||||
|
||||
pos = input.find_last_not_of(" \t");
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
int size = input.length()-pos-1;
|
||||
input = input.erase(pos+1,size);
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
void CtrlDisAsmView::assembleOpcode(u32 address, std::string defaultText)
|
||||
{
|
||||
u32 encoded;
|
||||
|
@ -465,6 +483,33 @@ void CtrlDisAsmView::assembleOpcode(u32 address, std::string defaultText)
|
|||
if (!result)
|
||||
return;
|
||||
|
||||
// check if it changes registers first
|
||||
auto seperator = op.find('=');
|
||||
if (seperator != std::string::npos)
|
||||
{
|
||||
std::string registerName = trimString(op.substr(0,seperator));
|
||||
std::string expression = trimString(op.substr(seperator+1));
|
||||
|
||||
u32 value;
|
||||
if (parseExpression(expression.c_str(),debugger,value) == true)
|
||||
{
|
||||
for (int cat = 0; cat < debugger->GetNumCategories(); cat++)
|
||||
{
|
||||
for (int reg = 0; reg < debugger->GetNumRegsInCategory(cat); reg++)
|
||||
{
|
||||
if (strcasecmp(debugger->GetRegName(cat,reg),registerName.c_str()) == 0)
|
||||
{
|
||||
debugger->SetRegValue(cat,reg,value);
|
||||
SendMessage(GetParent(wnd),WM_DEB_UPDATE,0,0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// try to assemble the input if it failed
|
||||
}
|
||||
|
||||
result = MIPSAsm::MipsAssembleOpcode(op.c_str(),debugger,address,encoded);
|
||||
if (result == true)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue