From b856f2c808fe0cda816f241b59c91a335c6ca457 Mon Sep 17 00:00:00 2001 From: Konstantin Nazarov Date: Sun, 15 Dec 2024 00:36:09 +0000 Subject: [PATCH] Implement SLTI and SLTIU instructions --- src/vm.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/vm.cpp b/src/vm.cpp index cd7c884..313b7bc 100644 --- a/src/vm.cpp +++ b/src/vm.cpp @@ -263,6 +263,13 @@ void VM::step() { } else { throw std::runtime_error("Unknown I-type instruction"); } + } else if (funct3 == 0x02) { // SLTI + setreg(rd, (static_cast(registers[rs1]) < + static_cast(imm)) + ? 0 + : 1); + } else if (funct3 == 0x03) { // SLTIU + setreg(rd, (registers[rs1] < static_cast(imm)) ? 1 : 0); } else { throw std::runtime_error("Unknown I-type instruction"); }