From 4c5bff90bafd0f2fc984d01cb0a3d90a32fa904a Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Wed, 20 Nov 2024 17:04:21 +0100 Subject: [PATCH] o1vm/riscv32: implement M type instruction Remu --- o1vm/src/interpreters/riscv32im/interpreter.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/o1vm/src/interpreters/riscv32im/interpreter.rs b/o1vm/src/interpreters/riscv32im/interpreter.rs index d0e6630e07..1797dde93e 100644 --- a/o1vm/src/interpreters/riscv32im/interpreter.rs +++ b/o1vm/src/interpreters/riscv32im/interpreter.rs @@ -2299,7 +2299,17 @@ pub fn interpret_mtype(env: &mut Env, instr: MInstruction) env.set_next_instruction_pointer(next_instruction_pointer + Env::constant(4u32)); } MInstruction::Remu => { - unimplemented!("Remu") + let rs1 = env.read_register(&rs1); + let rs2 = env.read_register(&rs2); + // FIXME: constrain + let res = { + let pos = env.alloc_scratch(); + unsafe { env.mod_unsigned(&rs1, &rs2, pos) } + }; + env.write_register(&rd, res); + + env.set_instruction_pointer(next_instruction_pointer.clone()); + env.set_next_instruction_pointer(next_instruction_pointer + Env::constant(4u32)); } } }