Skip to content

Commit

Permalink
Merge pull request #2850 from o1-labs/sai/store-half-riscv32im
Browse files Browse the repository at this point in the history
implementation for store half instruction in riscv32im
  • Loading branch information
dannywillems authored Dec 19, 2024
2 parents 161540c + b0b8760 commit a50442b
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion o1vm/src/interpreters/riscv32im/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2064,7 +2064,26 @@ pub fn interpret_stype<Env: InterpreterEnv>(env: &mut Env, instr: SInstruction)
env.set_next_instruction_pointer(next_instruction_pointer + Env::constant(4u32));
}
SInstruction::StoreHalf => {
unimplemented!("StoreHalf")
// sh: M[x[rs1] + sext(offset)] = x[rs2][15:0]
let [v0, v1] = [
{
let value_scratch = env.alloc_scratch();
unsafe { env.bitmask(&local_rs2, 8, 0, value_scratch) }
},
{
let value_scratch = env.alloc_scratch();
unsafe { env.bitmask(&local_rs2, 16, 8, value_scratch) }
},
];

env.lookup_8bits(&v0);
env.lookup_8bits(&v1);

env.write_memory(&address, v0);
env.write_memory(&(address.clone() + Env::constant(1u32)), v1);

env.set_instruction_pointer(next_instruction_pointer.clone());
env.set_next_instruction_pointer(next_instruction_pointer + Env::constant(4u32));
}
SInstruction::StoreWord => {
unimplemented!("StoreWord")
Expand Down

0 comments on commit a50442b

Please sign in to comment.