mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-20 19:44:57 +00:00
Improved Assemble instruction workflow.
- Assemble instruction filed with the right disassembly instead of .li and the hex since the hex edition is available in "replace instruction" - Can now assemble branches with absolute addresses computing automatically the offset. For example assembling b ->0x80359370 at the address 0x8035936c will result in the right relative jump. Add -> before any address you want to use as absolute
This commit is contained in:
parent
e16918cfbe
commit
086c323561
3 changed files with 45 additions and 6 deletions
|
@ -10,6 +10,7 @@
|
|||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "Core/Core.h"
|
||||
#include "Common/Assembler/GekkoAssembler.h"
|
||||
#include "Common/StringUtil.h"
|
||||
|
||||
|
@ -38,8 +39,8 @@ QString HtmlFormatErrorLine(const Common::GekkoAssembler::AssemblerError& err)
|
|||
}
|
||||
} // namespace
|
||||
|
||||
AssembleInstructionDialog::AssembleInstructionDialog(QWidget* parent, u32 address, u32 value)
|
||||
: QDialog(parent), m_code(value), m_address(address)
|
||||
AssembleInstructionDialog::AssembleInstructionDialog(QWidget* parent, u32 address, u32 value, QString disasm )
|
||||
: QDialog(parent), m_code(value), m_address(address), m_disassembly(disasm)
|
||||
{
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
setWindowModality(Qt::WindowModal);
|
||||
|
@ -66,7 +67,9 @@ void AssembleInstructionDialog::CreateWidgets()
|
|||
layout->addWidget(m_error_line_label);
|
||||
layout->addWidget(m_msg_label);
|
||||
layout->addWidget(m_button_box);
|
||||
m_input_edit->setText(QStringLiteral(".4byte 0x%1").arg(m_code, 8, 16, QLatin1Char('0')));
|
||||
|
||||
// m_input_edit->setText(QStringLiteral(".4byte 0x%1").arg(m_code, 8, 16, QLatin1Char('0')));
|
||||
m_input_edit->setText( m_disassembly );
|
||||
|
||||
setLayout(layout);
|
||||
OnEditChanged();
|
||||
|
@ -86,6 +89,34 @@ void AssembleInstructionDialog::OnEditChanged()
|
|||
std::string line = m_input_edit->text().toStdString();
|
||||
Common::ToLower(&line);
|
||||
|
||||
size_t posArrow = line.find("->");
|
||||
if (posArrow != std::string::npos)
|
||||
{
|
||||
std::string start = line.substr(0, posArrow);
|
||||
std::string dest = line.substr(posArrow + 2);
|
||||
u32 destAddress = 0;
|
||||
size_t posHex = dest.find("0x");
|
||||
try
|
||||
{
|
||||
if (posHex == std::string::npos)
|
||||
{
|
||||
destAddress = (u32)std::stoi(dest);
|
||||
}
|
||||
else
|
||||
{
|
||||
destAddress = (u32)std::stoul(dest.substr(posHex + 2), NULL, 16);
|
||||
}
|
||||
} catch (...) {}
|
||||
if (destAddress < m_address)
|
||||
{
|
||||
line = start + " -" + std::to_string(m_address - destAddress);
|
||||
}
|
||||
else
|
||||
{
|
||||
line = start + " " + std::to_string(destAddress - m_address);
|
||||
}
|
||||
}
|
||||
|
||||
FailureOr<std::vector<CodeBlock>> asm_result = Assemble(line, m_address);
|
||||
|
||||
if (IsFailure(asm_result))
|
||||
|
|
|
@ -15,7 +15,7 @@ class AssembleInstructionDialog : public QDialog
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AssembleInstructionDialog(QWidget* parent, u32 address, u32 value);
|
||||
explicit AssembleInstructionDialog(QWidget* parent, u32 address, u32 value, QString disasm );
|
||||
|
||||
u32 GetCode() const;
|
||||
|
||||
|
@ -27,7 +27,7 @@ private:
|
|||
|
||||
u32 m_code;
|
||||
u32 m_address;
|
||||
|
||||
QString m_disassembly;
|
||||
QLineEdit* m_input_edit;
|
||||
QLabel* m_error_loc_label;
|
||||
QLabel* m_error_line_label;
|
||||
|
|
|
@ -1060,7 +1060,15 @@ void CodeViewWidget::DoPatchInstruction(bool assemble)
|
|||
|
||||
if (assemble)
|
||||
{
|
||||
AssembleInstructionDialog dialog(this, addr, debug_interface.ReadInstruction(guard, addr));
|
||||
std::string code_line = [this, addr] {
|
||||
Core::CPUThreadGuard guard(m_system);
|
||||
return m_system.GetPowerPC().GetDebugInterface().Disassemble(&guard, addr);
|
||||
}();
|
||||
|
||||
std::ranges::replace(code_line, '\t', ' ' );
|
||||
|
||||
AssembleInstructionDialog dialog(this, addr, debug_interface.ReadInstruction(guard, addr),
|
||||
QString::fromStdString(code_line));
|
||||
SetQWidgetWindowDecorations(&dialog);
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue