From e11a19c4f979270487ca685de010cacf5d098675 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Tue, 5 Dec 2023 22:30:49 +0000 Subject: [PATCH] Implement `lb` --- 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 a2543c4558..1688798677 100644 --- a/optimism/src/mips/interpreter.rs +++ b/optimism/src/mips/interpreter.rs @@ -926,7 +926,19 @@ pub fn interpret_itype(env: &mut Env, instr: ITypeInstructi // REMOVEME: when all itype instructions are implemented. return; } - ITypeInstruction::Load8 => (), + ITypeInstruction::Load8 => { + let base = env.read_register(&rs); + let dest = rt; + let offset = env.sign_extend(&immediate, 16); + let addr = base + offset; + let v0 = env.read_memory(&addr); + let value = env.sign_extend(&v0, 8); + env.write_register(&dest, value); + env.set_instruction_pointer(next_instruction_pointer.clone()); + env.set_next_instruction_pointer(next_instruction_pointer + Env::constant(4u32)); + // REMOVEME: when all itype instructions are implemented. + return; + } ITypeInstruction::Load16 => (), ITypeInstruction::Load32 => { let base = env.read_register(&rs);