Implement SLTI and SLTIU instructions
This commit is contained in:
parent
6ce3366009
commit
b856f2c808
1 changed files with 7 additions and 0 deletions
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue