centered standard MIPS PC-relative branch stuff to its own func
This commit is contained in:
parent
d39b58ae9a
commit
767756cfb4
|
@ -472,3 +472,18 @@ DWORD RunInterpreterCPU(DWORD Cycles) {
|
||||||
return Cycles;
|
return Cycles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int RSP_branch_if(int condition)
|
||||||
|
{
|
||||||
|
unsigned int new_PC;
|
||||||
|
|
||||||
|
/* RSP_NextInstruction = DELAY_SLOT; */
|
||||||
|
if (condition)
|
||||||
|
{
|
||||||
|
new_PC = *PrgCount + 4 + ((short)RSPOpC.offset << 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
new_PC = *PrgCount + 4 + 4;
|
||||||
|
}
|
||||||
|
return (new_PC & 0xFFC);
|
||||||
|
}
|
||||||
|
|
|
@ -38,5 +38,11 @@
|
||||||
|
|
||||||
extern DWORD RSP_NextInstruction, RSP_JumpTo, RSP_MfStatusCount;
|
extern DWORD RSP_NextInstruction, RSP_JumpTo, RSP_MfStatusCount;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* standard MIPS PC-relative branch
|
||||||
|
* returns the new PC, based on whether the condition passes
|
||||||
|
*/
|
||||||
|
unsigned int RSP_branch_if(int condition);
|
||||||
|
|
||||||
void BuildInterpreterCPU(void);
|
void BuildInterpreterCPU(void);
|
||||||
DWORD RunInterpreterCPU(DWORD Cycles);
|
DWORD RunInterpreterCPU(DWORD Cycles);
|
||||||
|
|
|
@ -63,38 +63,22 @@ void RSP_Opcode_JAL ( void ) {
|
||||||
|
|
||||||
void RSP_Opcode_BEQ ( void ) {
|
void RSP_Opcode_BEQ ( void ) {
|
||||||
RSP_NextInstruction = DELAY_SLOT;
|
RSP_NextInstruction = DELAY_SLOT;
|
||||||
if (RSP_GPR[RSPOpC.rs].W == RSP_GPR[RSPOpC.rt].W) {
|
RSP_JumpTo = RSP_branch_if(RSP_GPR[RSPOpC.rs].W == RSP_GPR[RSPOpC.rt].W);
|
||||||
RSP_JumpTo = ( *PrgCount + ((short)RSPOpC.offset << 2) + 4 ) & 0xFFC;
|
|
||||||
} else {
|
|
||||||
RSP_JumpTo = ( *PrgCount + 8 ) & 0xFFC;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RSP_Opcode_BNE ( void ) {
|
void RSP_Opcode_BNE ( void ) {
|
||||||
RSP_NextInstruction = DELAY_SLOT;
|
RSP_NextInstruction = DELAY_SLOT;
|
||||||
if (RSP_GPR[RSPOpC.rs].W != RSP_GPR[RSPOpC.rt].W) {
|
RSP_JumpTo = RSP_branch_if(RSP_GPR[RSPOpC.rs].W != RSP_GPR[RSPOpC.rt].W);
|
||||||
RSP_JumpTo = ( *PrgCount + ((short)RSPOpC.offset << 2) + 4 ) & 0xFFC;
|
|
||||||
} else {
|
|
||||||
RSP_JumpTo = ( *PrgCount + 8 ) & 0xFFC;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RSP_Opcode_BLEZ ( void ) {
|
void RSP_Opcode_BLEZ ( void ) {
|
||||||
RSP_NextInstruction = DELAY_SLOT;
|
RSP_NextInstruction = DELAY_SLOT;
|
||||||
if (RSP_GPR[RSPOpC.rs].W <= 0) {
|
RSP_JumpTo = RSP_branch_if(RSP_GPR[RSPOpC.rs].W <= 0);
|
||||||
RSP_JumpTo = ( *PrgCount + ((short)RSPOpC.offset << 2) + 4 ) & 0xFFC;
|
|
||||||
} else {
|
|
||||||
RSP_JumpTo = ( *PrgCount + 8 ) & 0xFFC;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RSP_Opcode_BGTZ ( void ) {
|
void RSP_Opcode_BGTZ ( void ) {
|
||||||
RSP_NextInstruction = DELAY_SLOT;
|
RSP_NextInstruction = DELAY_SLOT;
|
||||||
if (RSP_GPR[RSPOpC.rs].W > 0) {
|
RSP_JumpTo = RSP_branch_if(RSP_GPR[RSPOpC.rs].W > 0);
|
||||||
RSP_JumpTo = ( *PrgCount + ((short)RSPOpC.offset << 2) + 4 ) & 0xFFC;
|
|
||||||
} else {
|
|
||||||
RSP_JumpTo = ( *PrgCount + 8 ) & 0xFFC;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RSP_Opcode_ADDI ( void ) {
|
void RSP_Opcode_ADDI ( void ) {
|
||||||
|
@ -293,40 +277,24 @@ void RSP_Special_SLTU (void) {
|
||||||
/********************** R4300i OpCodes: RegImm **********************/
|
/********************** R4300i OpCodes: RegImm **********************/
|
||||||
void RSP_Opcode_BLTZ ( void ) {
|
void RSP_Opcode_BLTZ ( void ) {
|
||||||
RSP_NextInstruction = DELAY_SLOT;
|
RSP_NextInstruction = DELAY_SLOT;
|
||||||
if (RSP_GPR[RSPOpC.rs].W < 0) {
|
RSP_JumpTo = RSP_branch_if(RSP_GPR[RSPOpC.rs].W < 0);
|
||||||
RSP_JumpTo = ( *PrgCount + ((short)RSPOpC.offset << 2) + 4 ) & 0xFFC;
|
|
||||||
} else {
|
|
||||||
RSP_JumpTo = ( *PrgCount + 8 ) & 0xFFC;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RSP_Opcode_BGEZ ( void ) {
|
void RSP_Opcode_BGEZ ( void ) {
|
||||||
RSP_NextInstruction = DELAY_SLOT;
|
RSP_NextInstruction = DELAY_SLOT;
|
||||||
if (RSP_GPR[RSPOpC.rs].W >= 0) {
|
RSP_JumpTo = RSP_branch_if(RSP_GPR[RSPOpC.rs].W >= 0);
|
||||||
RSP_JumpTo = ( *PrgCount + ((short)RSPOpC.offset << 2) + 4 ) & 0xFFC;
|
|
||||||
} else {
|
|
||||||
RSP_JumpTo = ( *PrgCount + 8 ) & 0xFFC;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RSP_Opcode_BLTZAL ( void ) {
|
void RSP_Opcode_BLTZAL ( void ) {
|
||||||
RSP_NextInstruction = DELAY_SLOT;
|
RSP_NextInstruction = DELAY_SLOT;
|
||||||
RSP_GPR[31].UW = ( *PrgCount + 8 ) & 0xFFC;
|
RSP_GPR[31].UW = ( *PrgCount + 8 ) & 0xFFC;
|
||||||
if (RSP_GPR[RSPOpC.rs].W < 0) {
|
RSP_JumpTo = RSP_branch_if(RSP_GPR[RSPOpC.rs].W < 0);
|
||||||
RSP_JumpTo = ( *PrgCount + ((short)RSPOpC.offset << 2) + 4 ) & 0xFFC;
|
|
||||||
} else {
|
|
||||||
RSP_JumpTo = ( *PrgCount + 8 ) & 0xFFC;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RSP_Opcode_BGEZAL ( void ) {
|
void RSP_Opcode_BGEZAL ( void ) {
|
||||||
RSP_NextInstruction = DELAY_SLOT;
|
RSP_NextInstruction = DELAY_SLOT;
|
||||||
RSP_GPR[31].UW = ( *PrgCount + 8 ) & 0xFFC;
|
RSP_GPR[31].UW = ( *PrgCount + 8 ) & 0xFFC;
|
||||||
if (RSP_GPR[RSPOpC.rs].W >= 0) {
|
RSP_JumpTo = RSP_branch_if(RSP_GPR[RSPOpC.rs].W >= 0);
|
||||||
RSP_JumpTo = ( *PrgCount + ((short)RSPOpC.offset << 2) + 4 ) & 0xFFC;
|
|
||||||
} else {
|
|
||||||
RSP_JumpTo = ( *PrgCount + 8 ) & 0xFFC;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************** Cop0 functions *************************/
|
/************************** Cop0 functions *************************/
|
||||||
|
|
Loading…
Reference in New Issue