summaryrefslogtreecommitdiff
path: root/src/instructions/rvi.rs
diff options
context:
space:
mode:
authortaitep <taitep@taitep.se>2025-12-22 19:33:40 +0100
committertaitep <taitep@taitep.se>2025-12-22 19:33:40 +0100
commitcb100e92ac6ff10e5468678d734adb633b04c5c4 (patch)
tree95cc155ba212d362e09a64ecda02853fc8203f82 /src/instructions/rvi.rs
parentd0d3775b888b6cf1e7d240d3426db4175c200b48 (diff)
Implement SUB
Diffstat (limited to 'src/instructions/rvi.rs')
-rw-r--r--src/instructions/rvi.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/instructions/rvi.rs b/src/instructions/rvi.rs
index 69670d0..df3d9d5 100644
--- a/src/instructions/rvi.rs
+++ b/src/instructions/rvi.rs
@@ -21,6 +21,16 @@ pub fn add(core: &mut Core, instr: Instruction) -> InstructionResult {
InstructionResult::Normal
}
+pub fn sub(core: &mut Core, instr: Instruction) -> InstructionResult {
+ core.reg_write(
+ instr.rd(),
+ core.reg_read(instr.rs1())
+ .wrapping_sub(core.reg_read(instr.rs2())),
+ );
+ core.advance_pc();
+ InstructionResult::Normal
+}
+
pub fn addi(core: &mut Core, instr: Instruction) -> InstructionResult {
core.reg_write(
instr.rd(),