Skip to content

Commit

Permalink
Merge pull request #1398 from o1-labs/feature/add-zkvm-instruction
Browse files Browse the repository at this point in the history
Implement `add` and `addu` instructions
  • Loading branch information
dannywillems authored Dec 5, 2023
2 parents d2b87eb + debadb5 commit 6bf6ee4
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions optimism/src/mips/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,22 @@ pub fn interpret_rtype<Env: InterpreterEnv>(env: &mut Env, instr: RTypeInstructi
RTypeInstruction::MultiplyUnsigned => (),
RTypeInstruction::Div => (),
RTypeInstruction::DivUnsigned => (),
RTypeInstruction::Add => (),
RTypeInstruction::AddUnsigned => (),
RTypeInstruction::Add => {
let rs = env.read_register(&rs);
let rt = env.read_register(&rt);
env.write_register(&rd, rs + rt);
env.set_instruction_pointer(next_instruction_pointer.clone());
env.set_next_instruction_pointer(next_instruction_pointer + Env::constant(4u32));
return;
}
RTypeInstruction::AddUnsigned => {
let rs = env.read_register(&rs);
let rt = env.read_register(&rt);
env.write_register(&rd, rs + rt);
env.set_instruction_pointer(next_instruction_pointer.clone());
env.set_next_instruction_pointer(next_instruction_pointer + Env::constant(4u32));
return;
}
RTypeInstruction::Sub => (),
RTypeInstruction::SubUnsigned => (),
RTypeInstruction::And => (),
Expand Down

0 comments on commit 6bf6ee4

Please sign in to comment.