Set register names and tooltips
MODIFY
src/memorytab.cpp
src/memorytab.cpp
@@ -7,9 +7,80 @@ MemoryTab::MemoryTab(QWidget *parent)
: QWidget(parent), m_ui(new Ui::MemoryTab) {
m_ui->setupUi(this);
- // create some registers
+ // Initialize register ABInames
+ QStringList ABInames = QStringList() << "zero"
+ << "ra"
+ << "sp"
+ << "gp"
+ << "tp"
+ << "t0"
+ << "t1"
+ << "t2"
+ << "s0/fp"
+ << "s1"
+ << "a0"
+ << "a1"
+ << "a2"
+ << "a3"
+ << "a4"
+ << "a5"
+ << "a6"
+ << "a7"
+ << "s2"
+ << "s3"
+ << "s4"
+ << "s5"
+ << "s6"
+ << "s7"
+ << "s8"
+ << "s9"
+ << "s10"
+ << "s11"
+ << "t3"
+ << "t4"
+ << "t5"
+ << "t6";
+ QStringList descriptions =
+ QStringList() << "Hard-Wired zero"
+ << "Return Address \nSaver: Caller"
+ << "Stack pointer\nSaver: Callee"
+ << "Global pointer"
+ << "Thread pointer"
+ << "Temporary/alternate link register\nSaver: Caller"
+ << "Temporary\nSaver: Caller"
+ << "Temporary\nSaver: Caller"
+ << "Saved register/frame pointer\nSaver: Callee"
+ << "Saved register\nSaver: Callee"
+ << "Function argument/return value\nSaver: Caller"
+ << "Function argument/return value\nSaver: Caller"
+ << "Function argument\nSaver: Caller"
+ << "Function argument\nSaver: Caller"
+ << "Function argument\nSaver: Caller"
+ << "Function argument\nSaver: Caller"
+ << "Function argument\nSaver: Caller"
+ << "Function argument\nSaver: Caller"
+ << "Saved register\nSaver: Callee"
+ << "Saved register\nSaver: Callee"
+ << "Saved register\nSaver: Callee"
+ << "Saved register\nSaver: Callee"
+ << "Saved register\nSaver: Callee"
+ << "Saved register\nSaver: Callee"
+ << "Saved register\nSaver: Callee"
+ << "Saved register\nSaver: Callee"
+ << "Saved register\nSaver: Callee"
+ << "Saved register\nSaver: Callee"
+ << "Temporary register\nSaver: Caller"
+ << "Temporary register\nSaver: Caller"
+ << "Temporary register\nSaver: Caller"
+ << "Temporary register\nSaver: Caller";
+
+ // Initialize 32 register widgets
for (int i = 0; i < 32; i++) {
- m_ui->registerLayout->addWidget(new RegisterWidget(this));
+ auto reg = new RegisterWidget(this);
+ reg->setAlias(ABInames[i]);
+ reg->setNumber(i);
+ reg->setToolTip(descriptions[i]);
+ m_ui->registerLayout->addWidget(reg);
}
}

MODIFY
src/memorytab.ui
src/memorytab.ui
<rect>
<x>0</x>
<y>0</y>
- <width>281</width>
+ <width>179</width>
<height>342</height>
</rect>
</property>
<rect>
<x>0</x>
<y>0</y>
- <width>281</width>
+ <width>383</width>
<height>342</height>
</rect>
</property>
</widget>
</item>
<item>
- <spacer name="horizontalSpacer_3">
+ <spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</property>
</spacer>
</item>
+ <item>
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Go to</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="comboBox_3">
+ <item>
+ <property name="text">
+ <string>Text</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Data</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Heap</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Stack</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushButton">
+ <property name="text">
+ <string>Up</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushButton_2">
+ <property name="text">
+ <string>down</string>
+ </property>
+ </widget>
+ </item>
</layout>
</item>
</layout>

MODIFY
src/registerwidget.cpp
src/registerwidget.cpp
#include "registerwidget.h"
#include "ui_registerwidget.h"
-RegisterWidget::RegisterWidget(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::RegisterWidget)
-{
- ui->setupUi(this);
+RegisterWidget::RegisterWidget(QWidget *parent)
+ : QWidget(parent), m_ui(new Ui::RegisterWidget) {
+ m_ui->setupUi(this);
}
-RegisterWidget::~RegisterWidget()
-{
- delete ui;
+RegisterWidget::~RegisterWidget() { delete m_ui; }
+
+void RegisterWidget::setAlias(QString text) { m_ui->alias->setText(text); }
+
+void RegisterWidget::setNumber(int number) {
+ m_ui->number->setText(QString("x(%1)").arg(number));
}

MODIFY
src/registerwidget.h
src/registerwidget.h
@@ -7,16 +7,18 @@ namespace Ui {
class RegisterWidget;
}
-class RegisterWidget : public QWidget
-{
+class RegisterWidget : public QWidget {
Q_OBJECT
public:
explicit RegisterWidget(QWidget *parent = 0);
~RegisterWidget();
+ void setAlias(QString text);
+ void setNumber(int number);
+
private:
- Ui::RegisterWidget *ui;
+ Ui::RegisterWidget *m_ui;
};
#endif // REGISTERWIDGET_H

MODIFY
src/registerwidget.ui
src/registerwidget.ui
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
- <widget class="QLabel" name="label">
+ <widget class="QLabel" name="alias">
<property name="text">
<string>Alias</string>
</property>
</widget>
</item>
<item>
- <widget class="QLabel" name="label_2">
+ <widget class="QLabel" name="number">
<property name="text">
<string>(x#)</string>
</property>
</widget>
</item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Minimum</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
<item>
<widget class="QLineEdit" name="lineEdit">
<property name="text">

Set register names and tooltips