aboutsummaryrefslogtreecommitdiff
path: root/qtmips_machine
diff options
context:
space:
mode:
Diffstat (limited to 'qtmips_machine')
-rw-r--r--qtmips_machine/alu.cpp2
-rw-r--r--qtmips_machine/alu.h1
-rw-r--r--qtmips_machine/core.cpp2
-rw-r--r--qtmips_machine/tests/testcore.cpp4
4 files changed, 8 insertions, 1 deletions
diff --git a/qtmips_machine/alu.cpp b/qtmips_machine/alu.cpp
index 24b1c02..3822955 100644
--- a/qtmips_machine/alu.cpp
+++ b/qtmips_machine/alu.cpp
@@ -65,6 +65,8 @@ std::uint32_t machine::alu_operate(enum AluOp operation, std::uint32_t s, std::u
return ((std::int32_t)s < (std::int32_t)t) ? 1 : 0;
case ALU_OP_SLTU:
return (s < t) ? 1 : 0;
+ case ALU_OP_LUI:
+ return t << 16;
default:
throw QTMIPS_EXCEPTION(UnsupportedAluOperation, "Unknown ALU operation", QString::number(operation, 16));
}
diff --git a/qtmips_machine/alu.h b/qtmips_machine/alu.h
index 13f3d89..786bba0 100644
--- a/qtmips_machine/alu.h
+++ b/qtmips_machine/alu.h
@@ -33,6 +33,7 @@ enum AluOp : std::uint8_t {
ALU_OP_NOR,
ALU_OP_SLT = 42,
ALU_OP_SLTU,
+ ALU_OP_LUI, // We don't care about exact index for this one
ALU_OP_LAST = 64 // First impossible operation (just to be sure that we don't overflow)
};
diff --git a/qtmips_machine/core.cpp b/qtmips_machine/core.cpp
index 617f8c2..1e31584 100644
--- a/qtmips_machine/core.cpp
+++ b/qtmips_machine/core.cpp
@@ -39,7 +39,7 @@ static const struct DecodeMap dmap[] = {
{ .flags = FLAGS_ALU_I, .alu = ALU_OP_AND, NOMEM }, // ANDI
{ .flags = FLAGS_ALU_I, .alu = ALU_OP_OR, NOMEM }, // ORI
{ .flags = FLAGS_ALU_I, .alu = ALU_OP_XOR, NOMEM }, // XORI
- NOPE, // LUI
+ { .flags = FLAGS_ALU_I, .alu = ALU_OP_LUI, NOMEM}, // LUI
NOPE, // 16
NOPE, // 17
NOPE, // 18
diff --git a/qtmips_machine/tests/testcore.cpp b/qtmips_machine/tests/testcore.cpp
index 30cf3c7..5e278b5 100644
--- a/qtmips_machine/tests/testcore.cpp
+++ b/qtmips_machine/tests/testcore.cpp
@@ -122,6 +122,10 @@ static void core_regs_data() {
QTest::newRow("NOR") << Instruction(0, 24, 25, 26, 0, 39) \
<< regs_init \
<< regs_res;
+ regs_res.write_gp(26, 0xf00f0000);
+ QTest::newRow("LUI") << Instruction(15, 0, 26, 0xf00f) \
+ << regs_init \
+ << regs_res;
}
// Move instructions