Skip to content

Commit

Permalink
Merge pull request #2810 from o1-labs/dw/riscv32-impl-mulhsu
Browse files Browse the repository at this point in the history
o1vm/riscv32: implement M type instruction Mulhsu
  • Loading branch information
dannywillems authored Dec 4, 2024
2 parents 71d6a09 + 277cec8 commit d0f9cb3
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion o1vm/src/interpreters/riscv32im/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2258,7 +2258,17 @@ pub fn interpret_mtype<Env: InterpreterEnv>(env: &mut Env, instr: MInstruction)
env.set_next_instruction_pointer(next_instruction_pointer + Env::constant(4u32));
}
MInstruction::Mulhsu => {
unimplemented!("Mulhsu")
let rs1 = env.read_register(&rs1);
let rs2 = env.read_register(&rs2);
// FIXME: constrain
let res = {
let pos = env.alloc_scratch();
unsafe { env.mul_hi_signed_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));
}
MInstruction::Mulhu => {
let rs1 = env.read_register(&rs1);
Expand Down

0 comments on commit d0f9cb3

Please sign in to comment.