Skip to content

Commit

Permalink
Merge pull request #1421 from o1-labs/feature/mips/bltz
Browse files Browse the repository at this point in the history
Implement `bltz`
  • Loading branch information
dannywillems authored Dec 6, 2023
2 parents d4895dd + b39a95e commit c0b61fa
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion optimism/src/mips/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,25 @@ pub fn interpret_itype<Env: InterpreterEnv>(env: &mut Env, instr: ITypeInstructi
}
ITypeInstruction::BranchLeqZero => (),
ITypeInstruction::BranchGtZero => (),
ITypeInstruction::BranchLtZero => (),
ITypeInstruction::BranchLtZero => {
let offset = env.sign_extend(&(immediate * Env::constant(1 << 2)), 18);
let rs = env.read_register(&rs);
let less_than = {
// FIXME: Requires constraints
let pos = env.alloc_scratch();
unsafe { env.test_less_than_signed(&rs, &Env::constant(0), pos) }
};
let offset =
(Env::constant(1) - less_than.clone()) * Env::constant(4) + less_than * offset;
let addr = {
let pos = env.alloc_scratch();
env.copy(&(next_instruction_pointer.clone() + offset), pos)
};
env.set_instruction_pointer(next_instruction_pointer);
env.set_next_instruction_pointer(addr);
// REMOVEME: when all itype instructions are implemented.
return;
}
ITypeInstruction::BranchGeqZero => (),
ITypeInstruction::AddImmediate => {
let register_rs = env.read_register(&rs);
Expand Down

0 comments on commit c0b61fa

Please sign in to comment.