From 6ec50cd441b5c33f6487015ddb7843e7d37f0a1e Mon Sep 17 00:00:00 2001 From: Sai Vegasena Date: Wed, 20 Nov 2024 12:31:24 +0100 Subject: [PATCH] o1vm/riscv32: implement R type instruction sll --- o1vm/src/interpreters/riscv32im/interpreter.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/o1vm/src/interpreters/riscv32im/interpreter.rs b/o1vm/src/interpreters/riscv32im/interpreter.rs index 072d6b6e51..180cbfd216 100644 --- a/o1vm/src/interpreters/riscv32im/interpreter.rs +++ b/o1vm/src/interpreters/riscv32im/interpreter.rs @@ -1312,7 +1312,17 @@ pub fn interpret_rtype(env: &mut Env, instr: RInstruction) env.set_next_instruction_pointer(next_instruction_pointer + Env::constant(4u32)); } RInstruction::ShiftLeftLogical => { - unimplemented!("ShiftLeftLogical"); + /* sll: x[rd] = x[rs1] << x[rs2] */ + let local_rs1 = env.read_register(&rs1); + let local_rs2 = env.read_register(&rs2); + let local_rd = unsafe { + let rd_scratch = env.alloc_scratch(); + env.shift_left(&local_rs1, &local_rs2, rd_scratch) + }; + env.write_register(&rd, local_rd); + + env.set_instruction_pointer(next_instruction_pointer.clone()); + env.set_next_instruction_pointer(next_instruction_pointer + Env::constant(4u32)); } RInstruction::SetLessThan => { unimplemented!("SetLessThan");