From 35759449502e6361357aa6bee724b50ed15d6bb3 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Tue, 23 Apr 2024 13:40:44 +0200 Subject: [PATCH] MIPS/Store16: add missing constraint --- optimism/src/mips/interpreter.rs | 5 +++++ optimism/src/mips/tests.rs | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/optimism/src/mips/interpreter.rs b/optimism/src/mips/interpreter.rs index 5c6db9ae03..654de975ba 100644 --- a/optimism/src/mips/interpreter.rs +++ b/optimism/src/mips/interpreter.rs @@ -2237,6 +2237,11 @@ pub fn interpret_itype(env: &mut Env, instr: ITypeInstructi }, ] }; + // Checking that v is the correct decomposition. + { + let res = value - v0.clone() * Env::constant(1 << 8) - v1.clone(); + env.is_zero(&res) + }; env.write_memory(&addr, v0); env.write_memory(&(addr.clone() + Env::constant(1)), v1); env.set_instruction_pointer(next_instruction_pointer.clone()); diff --git a/optimism/src/mips/tests.rs b/optimism/src/mips/tests.rs index 0ff276df9b..b5aa2ed0ee 100644 --- a/optimism/src/mips/tests.rs +++ b/optimism/src/mips/tests.rs @@ -78,10 +78,10 @@ fn test_mips_number_constraints() { JumpAndLink => assert_num_constraints(&instr, 3), }, IType(itype) => match itype { - BranchLeqZero | BranchGtZero | BranchLtZero | BranchGeqZero | Store8 | Store16 => { + BranchLeqZero | BranchGtZero | BranchLtZero | BranchGeqZero | Store8 => { assert_num_constraints(&instr, 0) } - BranchEq | BranchNeq | Store32 => assert_num_constraints(&instr, 2), + BranchEq | BranchNeq | Store16 | Store32 => assert_num_constraints(&instr, 2), AddImmediate | AddImmediateUnsigned | SetLessThanImmediate