Skip to content

Commit

Permalink
Merge pull request #1397 from o1-labs/feature/store32
Browse files Browse the repository at this point in the history
Add `sw` instruction
  • Loading branch information
dannywillems authored Dec 5, 2023
2 parents ee2b52a + 7ef1031 commit d2b87eb
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion optimism/src/mips/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,43 @@ pub fn interpret_itype<Env: InterpreterEnv>(env: &mut Env, instr: ITypeInstructi
ITypeInstruction::LoadWordRight => (),
ITypeInstruction::Store8 => (),
ITypeInstruction::Store16 => (),
ITypeInstruction::Store32 => (),
ITypeInstruction::Store32 => {
let base = env.read_register(&rs);
let offset = env.sign_extend(&immediate, 16);
let addr = base.clone() + offset.clone();
let value = env.read_register(&rt);
let [v0, v1, v2, v3] = {
[
{
// FIXME: Requires a range check
let pos = env.alloc_scratch();
unsafe { env.bitmask(&value, 32, 24, pos) }
},
{
// FIXME: Requires a range check
let pos = env.alloc_scratch();
unsafe { env.bitmask(&value, 24, 16, pos) }
},
{
// FIXME: Requires a range check
let pos = env.alloc_scratch();
unsafe { env.bitmask(&value, 16, 8, pos) }
},
{
// FIXME: Requires a range check
let pos = env.alloc_scratch();
unsafe { env.bitmask(&value, 8, 0, pos) }
},
]
};
env.write_memory(&addr, v0);
env.write_memory(&(addr.clone() + Env::constant(1)), v1);
env.write_memory(&(addr.clone() + Env::constant(2)), v2);
env.write_memory(&(addr.clone() + Env::constant(3)), v3);
env.set_instruction_pointer(next_instruction_pointer.clone());
env.set_next_instruction_pointer(next_instruction_pointer + Env::constant(4u32));
return;
}
ITypeInstruction::StoreWordLeft => (),
ITypeInstruction::StoreWordRight => (),
};
Expand Down

0 comments on commit d2b87eb

Please sign in to comment.