From a3871de50d40d293b145f5f97f2507de6a9e0ba8 Mon Sep 17 00:00:00 2001 From: Ronit Dsilva <124994670+Cherrytree56567@users.noreply.github.com> Date: Wed, 18 Oct 2023 20:20:52 +1100 Subject: [PATCH] update PSEMU/CPU.cpp --- PSEMU/CPU.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/PSEMU/CPU.cpp b/PSEMU/CPU.cpp index 2bf81dc..113265b 100644 --- a/PSEMU/CPU.cpp +++ b/PSEMU/CPU.cpp @@ -135,6 +135,11 @@ void CPU::decode_execute(Instruction instruction) { std::cout << "[CPU] INFO: MTHI (R-Type)\n"; break; + case (0b000100): + op_sllv(instruction); + std::cout << "[CPU] INFO: SLLV (R-Type)\n"; + break; + default: std::cout << "[CPU] ERROR: Unhandled Function Instruction \n"; exit(0); @@ -924,4 +929,15 @@ void CPU::op_lhu(Instruction instruction) { } else { exception(Exception::LoadAddressError); } -} \ No newline at end of file +} + +void CPU::op_sllv(Instruction instruction) { + uint32_t d = instruction.rd(); + uint32_t s = instruction.rs(); + uint32_t t = instruction.rt(); + + // Shift amount is truncated to 5 bits + uint32_t v = regs[t] << (regs[s] & 0x1f); + + set_reg(d, v); + } \ No newline at end of file