From 62fded5bdbb3ca4fc2a95612552d1c7db77ffe77 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Tue, 5 Dec 2023 16:55:24 +0000 Subject: [PATCH] Add parsing for rtype instructions --- optimism/src/mips/interpreter.rs | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/optimism/src/mips/interpreter.rs b/optimism/src/mips/interpreter.rs index a2909a55c3..5acff85f08 100644 --- a/optimism/src/mips/interpreter.rs +++ b/optimism/src/mips/interpreter.rs @@ -436,6 +436,47 @@ pub fn interpret_instruction(env: &mut Env, instr: Instruct } pub fn interpret_rtype(env: &mut Env, instr: RTypeInstruction) { + let instruction_pointer = env.get_instruction_pointer(); + let instruction = { + let v0 = env.read_memory(&instruction_pointer); + let v1 = env.read_memory(&(instruction_pointer.clone() + Env::constant(1))); + let v2 = env.read_memory(&(instruction_pointer.clone() + Env::constant(2))); + let v3 = env.read_memory(&(instruction_pointer + Env::constant(3))); + (v0 * Env::constant(1 << 24)) + + (v1 * Env::constant(1 << 16)) + + (v2 * Env::constant(1 << 8)) + + v3 + }; + let _opcode = { + // FIXME: Requires a range check + let pos = env.alloc_scratch(); + unsafe { env.bitmask(&instruction, 32, 26, pos) } + }; + let _rs = { + // FIXME: Requires a range check + let pos = env.alloc_scratch(); + unsafe { env.bitmask(&instruction, 26, 21, pos) } + }; + let _rt = { + // FIXME: Requires a range check + let pos = env.alloc_scratch(); + unsafe { env.bitmask(&instruction, 21, 16, pos) } + }; + let _rd = { + // FIXME: Requires a range check + let pos = env.alloc_scratch(); + unsafe { env.bitmask(&instruction, 16, 11, pos) } + }; + let _shamt = { + // FIXME: Requires a range check + let pos = env.alloc_scratch(); + unsafe { env.bitmask(&instruction, 11, 6, pos) } + }; + let _funct = { + // FIXME: Requires a range check + let pos = env.alloc_scratch(); + unsafe { env.bitmask(&instruction, 6, 0, pos) } + }; match instr { RTypeInstruction::ShiftLeftLogical => (), RTypeInstruction::ShiftRightLogical => (),