Implemented the remaining N64 R4300 trap instructions besides TEQ

This commit is contained in:
MrCheeze 2019-12-16 21:17:04 -05:00
parent 5dd226db94
commit b90f72c34d
10 changed files with 155 additions and 10 deletions

View File

@ -978,10 +978,30 @@ void gendsubu()
{
}
void gentge()
{
}
void gentgeu()
{
}
void gentlt()
{
}
void gentltu()
{
}
void genteq()
{
}
void gentne()
{
}
void gendsll()
{
}

View File

@ -354,6 +354,46 @@ DECLARE_INSTRUCTION(DSUBU)
ADD_TO_PC(1);
}
DECLARE_INSTRUCTION(TGE)
{
if (rrs >= rrt)
{
DebugMessage(M64MSG_ERROR, "trap exception in TGE");
//stop=1;
}
ADD_TO_PC(1);
}
DECLARE_INSTRUCTION(TGEU)
{
if ((unsigned long long)rrs >= (unsigned long long)rrt)
{
DebugMessage(M64MSG_ERROR, "trap exception in TGEU");
//stop=1;
}
ADD_TO_PC(1);
}
DECLARE_INSTRUCTION(TLT)
{
if (rrs < rrt)
{
DebugMessage(M64MSG_ERROR, "trap exception in TLT");
//stop=1;
}
ADD_TO_PC(1);
}
DECLARE_INSTRUCTION(TLTU)
{
if ((unsigned long long)rrs < (unsigned long long)rrt)
{
DebugMessage(M64MSG_ERROR, "trap exception in TLTU");
//stop=1;
}
ADD_TO_PC(1);
}
DECLARE_INSTRUCTION(TEQ)
{
if (rrs == rrt)
@ -364,6 +404,16 @@ DECLARE_INSTRUCTION(TEQ)
ADD_TO_PC(1);
}
DECLARE_INSTRUCTION(TNE)
{
if (rrs != rrt)
{
DebugMessage(M64MSG_ERROR, "trap exception in TNE");
//stop=1;
}
ADD_TO_PC(1);
}
DECLARE_INSTRUCTION(DSLL)
{
rrd = rrt << rsa;

View File

@ -306,7 +306,12 @@ typedef struct _cpu_instruction_table
void (*SYSCALL)(void);
// Exception instructions
void (*TGE)(void);
void (*TGEU)(void);
void (*TLT)(void);
void (*TLTU)(void);
void (*TEQ)(void);
void (*TNE)(void);
// Emulator helper functions
void (*NOP)(void); // No operation (used to nullify R0 writes)

View File

@ -373,7 +373,12 @@ static cpu_instruction_table pure_interpreter_table = {
SYSCALL,
TGE,
TGEU,
TLT,
TLTU,
TEQ,
TNE,
NOP,
RESERVED,

View File

@ -523,7 +523,12 @@ const cpu_instruction_table cached_interpreter_table = {
SYSCALL,
TGE,
TGEU,
TLT,
TLTU,
TEQ,
TNE,
NOP,
RESERVED,

View File

@ -430,26 +430,30 @@ static void RDSUBU(void)
static void RTGE(void)
{
dst->ops = current_instruction_table.NI;
recomp_func = genni;
dst->ops = current_instruction_table.TGE;
recomp_func = gentge;
recompile_standard_r_type();
}
static void RTGEU(void)
{
dst->ops = current_instruction_table.NI;
recomp_func = genni;
dst->ops = current_instruction_table.TGEU;
recomp_func = gentgeu;
recompile_standard_r_type();
}
static void RTLT(void)
{
dst->ops = current_instruction_table.NI;
recomp_func = genni;
dst->ops = current_instruction_table.TLT;
recomp_func = gentlt;
recompile_standard_r_type();
}
static void RTLTU(void)
{
dst->ops = current_instruction_table.NI;
recomp_func = genni;
dst->ops = current_instruction_table.TLTU;
recomp_func = gentltu;
recompile_standard_r_type();
}
static void RTEQ(void)
@ -461,8 +465,9 @@ static void RTEQ(void)
static void RTNE(void)
{
dst->ops = current_instruction_table.NI;
recomp_func = genni;
dst->ops = current_instruction_table.TNE;
recomp_func = gentne;
recompile_standard_r_type();
}
static void RDSLL(void)

View File

@ -193,7 +193,12 @@ void gendadd(void);
void gendaddu(void);
void gendsub(void);
void gendsubu(void);
void gentge(void);
void gentgeu(void);
void gentlt(void);
void gentltu(void);
void genteq(void);
void gentne(void);
void gendsrl(void);
void gendsrl32(void);
void genbltz_idle(void);

View File

@ -1041,11 +1041,36 @@ void gendsubu(void)
#endif
}
void gentge(void)
{
gencallinterp((unsigned int)cached_interpreter_table.TGE, 0);
}
void gentgeu(void)
{
gencallinterp((unsigned int)cached_interpreter_table.TGEU, 0);
}
void gentlt(void)
{
gencallinterp((unsigned int)cached_interpreter_table.TLT, 0);
}
void gentltu(void)
{
gencallinterp((unsigned int)cached_interpreter_table.TLTU, 0);
}
void genteq(void)
{
gencallinterp((unsigned int)cached_interpreter_table.TEQ, 0);
}
void gentne(void)
{
gencallinterp((unsigned int)cached_interpreter_table.TNE, 0);
}
void gendsll(void)
{
#ifdef INTERPRET_DSLL

View File

@ -956,6 +956,26 @@ void gendsubu(void)
#endif
}
void gentge(void)
{
gencallinterp((unsigned long long)cached_interpreter_table.TGE, 0);
}
void gentgeu(void)
{
gencallinterp((unsigned long long)cached_interpreter_table.TGEU, 0);
}
void gentlt(void)
{
gencallinterp((unsigned long long)cached_interpreter_table.TLT, 0);
}
void gentltu(void)
{
gencallinterp((unsigned long long)cached_interpreter_table.TLTU, 0);
}
void genteq(void)
{
#if defined(COUNT_INSTR)
@ -964,6 +984,11 @@ void genteq(void)
gencallinterp((unsigned long long)cached_interpreter_table.TEQ, 0);
}
void gentne(void)
{
gencallinterp((unsigned long long)cached_interpreter_table.TNE, 0);
}
void gendsll(void)
{
#if defined(COUNT_INSTR)

Binary file not shown.