Skip to content

Commit

Permalink
Merge pull request #2841 from o1-labs/sai/shift_right_arithmetic_imme…
Browse files Browse the repository at this point in the history
…diate

implementation for shift right arithmetic immediate for riscv32im
  • Loading branch information
dannywillems authored Dec 16, 2024
2 parents 08cfecf + becb4ee commit 767ea96
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion o1vm/src/interpreters/riscv32im/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1847,7 +1847,16 @@ pub fn interpret_itype<Env: InterpreterEnv>(env: &mut Env, instr: IInstruction)
env.set_next_instruction_pointer(next_instruction_pointer + Env::constant(4u32));
}
IInstruction::ShiftRightArithmeticImmediate => {
unimplemented!("ShiftRightArithmeticImmediate")
// srai: x[rd] = x[rs1] >> shamt
let local_rs1 = env.read_register(&rs1);

let local_rd = {
let pos = env.alloc_scratch();
unsafe { env.shift_right_arithmetic(&local_rs1, &shamt, pos) }
};
env.write_register(&rd, local_rd);
env.set_instruction_pointer(next_instruction_pointer.clone());
env.set_next_instruction_pointer(next_instruction_pointer + Env::constant(4u32));
}
IInstruction::SetLessThanImmediate => {
unimplemented!("SetLessThanImmediate")
Expand Down

0 comments on commit 767ea96

Please sign in to comment.