Implement SLTI and SLTIU instructions

This commit is contained in:
Konstantin Nazarov 2024-12-15 00:36:09 +00:00
parent 6ce3366009
commit b856f2c808
Signed by: knazarov
GPG key ID: 4CFE0A42FA409C22

View file

@ -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<int32_t>(registers[rs1]) <
static_cast<int32_t>(imm))
? 0
: 1);
} else if (funct3 == 0x03) { // SLTIU
setreg(rd, (registers[rs1] < static_cast<uint32_t>(imm)) ? 1 : 0);
} else {
throw std::runtime_error("Unknown I-type instruction");
}