unaligned jump exceptions handled properly now

This commit is contained in:
SimoneN64
2023-09-09 07:19:55 +02:00
parent f143da561b
commit b14977547d
3 changed files with 15 additions and 17 deletions

View File

@@ -1,6 +1,5 @@
#include <core/Interpreter.hpp>
#define check_address_error(mask, vaddr) (((!regs.cop0.is_64bit_addressing) && (s32)(vaddr) != (vaddr)) || (((vaddr) & (mask)) != 0))
#define check_signed_overflow(op1, op2, res) (((~((op1) ^ (op2)) & ((op1) ^ (res))) >> ((sizeof(res) * 8) - 1)) & 1)
#define check_signed_underflow(op1, op2, res) (((((op1) ^ (op2)) & ((op1) ^ (res))) >> ((sizeof(res) * 8) - 1)) & 1)
@@ -663,16 +662,17 @@ void Interpreter::jal(u32 instr) {
void Interpreter::jalr(u32 instr) {
u64 addr = regs.gpr[RS(instr)];
if(check_address_error(0b11, addr)) {
FireException(regs, ExceptionCode::AddressErrorLoad, 0, true);
} else {
branch(true, addr);
if (RD(instr) != 0) [[likely]] {
regs.gpr[RD(instr)] = regs.pc + 4;
}
branch(true, addr);
if (RD(instr) != 0) [[likely]] {
regs.gpr[RD(instr)] = regs.pc + 4;
}
}
void Interpreter::jr(u32 instr) {
u64 address = regs.gpr[RS(instr)];
branch(true, address);
}
void Interpreter::slti(u32 instr) {
s16 imm = instr;
if (RT(instr) != 0) [[likely]] {
@@ -858,15 +858,6 @@ void Interpreter::dsra32(u32 instr) {
}
}
void Interpreter::jr(u32 instr) {
s64 address = regs.gpr[RS(instr)];
if(check_address_error(0b11, address)) {
FireException(regs, ExceptionCode::AddressErrorLoad, 0, true);
} else {
branch(true, address);
}
}
void Interpreter::dsub(u32 instr) {
s64 rt = regs.gpr[RT(instr)];
s64 rs = regs.gpr[RS(instr)];