From df8418119ca732babce256aef46b6f2175be62cf Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Tue, 5 Dec 2023 23:40:02 +0000 Subject: [PATCH] Implement `slti` --- optimism/src/mips/interpreter.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/optimism/src/mips/interpreter.rs b/optimism/src/mips/interpreter.rs index 797d08b320..f3b7b83085 100644 --- a/optimism/src/mips/interpreter.rs +++ b/optimism/src/mips/interpreter.rs @@ -1001,7 +1001,19 @@ pub fn interpret_itype(env: &mut Env, instr: ITypeInstructi // REMOVEME: when all itype instructions are implemented. return; } - ITypeInstruction::SetLessThanImmediate => (), + ITypeInstruction::SetLessThanImmediate => { + let rs = env.read_register(&rs); + let immediate = env.sign_extend(&immediate, 16); + let res = { + // FIXME: Constrain + let pos = env.alloc_scratch(); + unsafe { env.test_less_than_signed(&rs, &immediate, pos) } + }; + env.write_register(&rt, res); + env.set_instruction_pointer(next_instruction_pointer.clone()); + env.set_next_instruction_pointer(next_instruction_pointer + Env::constant(4u32)); + return; + } ITypeInstruction::SetLessThanImmediateUnsigned => { let rs = env.read_register(&rs); let immediate = env.sign_extend(&immediate, 16);