3#include "core/cpu/cpu.hpp"
19 ss <<
"Unhandled instruction (SPECIAL): " << std::hex <<
ir;
20 throw std::runtime_error(ss.str());
137 if(((extended_op1 & 0x80000000) && (extended_op2 & 0x80000000) && (((extended_op1 + extended_op2) & 0x80000000) == 0))
138 || (((extended_op1 & 0x80000000) == 0) && ((extended_op2 & 0x80000000) == 0) && ((extended_op1 + extended_op2) & 0x80000000)))
141 std::stringstream ss;
142 ss <<
"Signed overflow in ADD: " << std::hex <<
ir;
143 throw std::runtime_error(ss.str());
182 uint32_t sign_bit = data & 0x80000000;
183 for(uint32_t i = 0; i < shamt; i++)
237 std::stringstream ss;
238 ss <<
"Division by zero in DIV: " << std::hex <<
ir;
239 throw std::runtime_error(ss.str());
241 if(op1 == 0x80000000 && op2 == 0xffffffff)
247 lo = int32_t(op1) / int32_t(op2);
248 hi = int32_t(op1) % int32_t(op2);
306 std::stringstream ss;
307 ss <<
"Division by zero in DIVU: " << std::hex <<
ir;
308 throw std::runtime_error(ss.str());
void SLTU()
Set on Less Than Unsigned.
void SRA()
Shift Right Arithmetic.
void SUBU()
Subtract Unsigned.
uint32_t ir
Instruction register.
void SLL()
Shift Left Logical.
void SLT()
Set on Less Than.
void SRL()
Shift Right Logical.
std::map< uint8_t, void(CPU::*)()> lookup_special
Lookup table for special instructions (opcode = 0b000000)
Instruction ins
Instruction in the form of the Instruction structure.
void JALR()
Jump and Link Register.
void DIVU()
Divide Unsigned.
uint32_t pc
Program counter.
void set_reg(uint8_t reg, uint32_t data)
Sets the value of the given register from the general purpose registers.
uint32_t get_reg(uint8_t reg)
Gets the value of the given register from the general purpose registers.
void SPECIAL()
Looks up and executes the appropriate SPECIAL instruction.
uint32_t rt()
Target register for the instruction. Size: 5 bits [20-16].
uint32_t rd()
Destination register for the instruction. Size: 5 bits [15-11].
uint32_t funct()
Function field for the instruction. Size: 6 bits [5-0].
uint32_t rs()
Source register for the instruction. Size: 5 bits [25-21].
uint32_t shamt()
Shift amount for the instruction. Size: 5 bits [10-6].