Skip to content

Commit 62fded5

Browse files
committed
Add parsing for rtype instructions
1 parent f117bc0 commit 62fded5

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

optimism/src/mips/interpreter.rs

+41
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,47 @@ pub fn interpret_instruction<Env: InterpreterEnv>(env: &mut Env, instr: Instruct
436436
}
437437

438438
pub fn interpret_rtype<Env: InterpreterEnv>(env: &mut Env, instr: RTypeInstruction) {
439+
let instruction_pointer = env.get_instruction_pointer();
440+
let instruction = {
441+
let v0 = env.read_memory(&instruction_pointer);
442+
let v1 = env.read_memory(&(instruction_pointer.clone() + Env::constant(1)));
443+
let v2 = env.read_memory(&(instruction_pointer.clone() + Env::constant(2)));
444+
let v3 = env.read_memory(&(instruction_pointer + Env::constant(3)));
445+
(v0 * Env::constant(1 << 24))
446+
+ (v1 * Env::constant(1 << 16))
447+
+ (v2 * Env::constant(1 << 8))
448+
+ v3
449+
};
450+
let _opcode = {
451+
// FIXME: Requires a range check
452+
let pos = env.alloc_scratch();
453+
unsafe { env.bitmask(&instruction, 32, 26, pos) }
454+
};
455+
let _rs = {
456+
// FIXME: Requires a range check
457+
let pos = env.alloc_scratch();
458+
unsafe { env.bitmask(&instruction, 26, 21, pos) }
459+
};
460+
let _rt = {
461+
// FIXME: Requires a range check
462+
let pos = env.alloc_scratch();
463+
unsafe { env.bitmask(&instruction, 21, 16, pos) }
464+
};
465+
let _rd = {
466+
// FIXME: Requires a range check
467+
let pos = env.alloc_scratch();
468+
unsafe { env.bitmask(&instruction, 16, 11, pos) }
469+
};
470+
let _shamt = {
471+
// FIXME: Requires a range check
472+
let pos = env.alloc_scratch();
473+
unsafe { env.bitmask(&instruction, 11, 6, pos) }
474+
};
475+
let _funct = {
476+
// FIXME: Requires a range check
477+
let pos = env.alloc_scratch();
478+
unsafe { env.bitmask(&instruction, 6, 0, pos) }
479+
};
439480
match instr {
440481
RTypeInstruction::ShiftLeftLogical => (),
441482
RTypeInstruction::ShiftRightLogical => (),

0 commit comments

Comments
 (0)