cpu: don't store opcode in cpu struct

This commit is contained in:
Jakub Czekański 2021-12-21 18:14:42 +01:00
parent ea84c175d3
commit bcb98952ff
3 changed files with 6 additions and 8 deletions

View file

@ -4,7 +4,7 @@
#include "system.h"
namespace mips {
CPU::CPU(System* sys) : sys(sys), _opcode(0) {
CPU::CPU(System* sys) : sys(sys) {
setPC(0xBFC00000);
inBranchDelay = false;
icacheEnabled = false;
@ -90,13 +90,11 @@ bool CPU::executeInstructions(int count) {
if (handleSoftwareBreakpoints()) return false;
}
_opcode = Opcode(fetchInstruction(PC));
const auto& op = instructions::OpcodeTable[_opcode.op];
const auto opcode = Opcode(fetchInstruction(PC));
const auto& op = instructions::OpcodeTable[opcode.op];
setPC(nextPC);
op.instruction(this, _opcode);
op.instruction(this, opcode);
moveLoadDelaySlots();
sys->cycles++;

View file

@ -82,7 +82,6 @@ struct CPU {
COP0 cop0;
GTE gte;
System* sys;
Opcode _opcode;
bool icacheEnabled;
CacheLine icache[1024];

View file

@ -177,7 +177,8 @@ void exception(CPU *cpu, COP0::CAUSE::Exception cause) {
cpu->cop0.status.enterException();
if (cause != Exception::busErrorInstruction) {
cpu->cop0.cause.coprocessorNumber = cpu->_opcode.op & 3;
Opcode i(cpu->sys->readMemory32(cpu->exceptionPC));
cpu->cop0.cause.coprocessorNumber = i.op & 3;
}
if (cause == Exception::interrupt) {