summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/instructions.rs1
-rw-r--r--src/instructions/rvm.rs7
2 files changed, 8 insertions, 0 deletions
diff --git a/src/instructions.rs b/src/instructions.rs
index d8e3ce2..90f2e28 100644
--- a/src/instructions.rs
+++ b/src/instructions.rs
@@ -40,6 +40,7 @@ pub(crate) fn find_and_exec(instr: Instruction, core: &mut Core) -> Result<(), E
(0b101, 0b0100000) => rvi::sra(core, instr),
(0b111, 0b0000000) => rvi::and(core, instr),
(0b100, 0b0000000) => rvi::xor(core, instr),
+ (0b100, 0b0000001) => rvm::div(core, instr),
(0b110, 0b0000000) => rvi::or(core, instr),
_ => illegal(instr),
},
diff --git a/src/instructions/rvm.rs b/src/instructions/rvm.rs
index 475fc58..bd0c100 100644
--- a/src/instructions/rvm.rs
+++ b/src/instructions/rvm.rs
@@ -6,4 +6,11 @@
//
use crate::{core::Core, decode::Instruction, exceptions::Exception};
+// multiplication
instr_op_r!(mul, u64::wrapping_mul);
+
+// division
+instr_op_r!(div, |a, b| match b {
+ 0 => -1,
+ _ => i64::wrapping_div(a as i64, b as i64),
+} as u64);