Skip to content

Commit

Permalink
update PSEMU/CPU.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Cherrytree56567 committed Oct 18, 2023
1 parent 530cc50 commit a3871de
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion PSEMU/CPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -924,4 +929,15 @@ void CPU::op_lhu(Instruction instruction) {
} else {
exception(Exception::LoadAddressError);
}
}
}

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);
}

0 comments on commit a3871de

Please sign in to comment.