endif
# base CFLAGS, LDLIBS, and LDFLAGS
-OPTFLAGS ?= -O3 -flto -fuse-linker-plugin
+OPTFLAGS ?= -O3
WARNFLAGS ?= -Wall
CFLAGS += $(OPTFLAGS) $(WARNFLAGS) -ffast-math -fno-strict-aliasing -fvisibility=hidden -I../../src -DM64P_PARALLEL
CXXFLAGS += -fvisibility-inlines-hidden
interupt_unsafe_state = 1;
if (next_interupt <= Count) gen_interupt();
interupt_unsafe_state = 0;
- debug_count += Count;
translate_event_queue((unsigned int) rrt & 0xFFFFFFFF);
Count = (unsigned int) rrt & 0xFFFFFFFF;
- debug_count -= Count;
break;
case 10: // EntryHi
EntryHi = (unsigned int) rrt & 0xFFFFE0FF;
}
if(opcode2[i]==0x1A) // DIV
{
+ #if 1
+ signed char m1l=get_reg(i_regs->regmap,rs1[i]);
+ signed char m2l=get_reg(i_regs->regmap,rs2[i]);
+ assert(m1l>=0);
+ assert(m2l>=0);
+ save_regs(0x100f);
+ if(m1l!=0) emit_mov(m1l,0);
+ if(m2l<1) emit_readword((int)&dynarec_local,1);
+ else if(m2l>1) emit_mov(m2l,1);
+ emit_call((int)&div32);
+ restore_regs(0x100f);
+ signed char hil=get_reg(i_regs->regmap,HIREG);
+ if(hil>=0) emit_loadreg(HIREG,hil);
+ signed char lol=get_reg(i_regs->regmap,LOREG);
+ if(lol>=0) emit_loadreg(LOREG,lol);
+ #else
signed char d1=get_reg(i_regs->regmap,rs1[i]);
signed char d2=get_reg(i_regs->regmap,rs2[i]);
assert(d1>=0);
emit_negmi(quotient,quotient);
emit_test(d1,d1);
emit_negmi(remainder,remainder);
+ #endif
}
if(opcode2[i]==0x1B) // DIVU
{
restore_regs(0x100f);
signed char hih=get_reg(i_regs->regmap,HIREG|64);
signed char hil=get_reg(i_regs->regmap,HIREG);
+ if(hih>=0) emit_loadreg(HIREG|64,hih);
+ if(hil>=0) emit_loadreg(HIREG,hil);
signed char loh=get_reg(i_regs->regmap,LOREG|64);
signed char lol=get_reg(i_regs->regmap,LOREG);
+ if(loh>=0) emit_loadreg(LOREG|64,loh);
+ if(lol>=0) emit_loadreg(LOREG,lol);
/*signed char temp=get_reg(i_regs->regmap,-1);
signed char rh=get_reg(i_regs->regmap,HIREG|64);
signed char rl=get_reg(i_regs->regmap,HIREG);
// Multiply by zero is zero.
// MIPS does not have a divide by zero exception.
// The result is undefined, we return zero.
-/* if((opcode2[i]&4)!=0) // 64-bit
+ if((opcode2[i]&4)!=0) // 64-bit
{
signed char hih=get_reg(i_regs->regmap,HIREG|64);
signed char hr=get_reg(i_regs->regmap,HIREG);
if(hr>=0) emit_zeroreg(hr);
if(loh>=0) emit_zeroreg(loh);
if(lr>=0) emit_zeroreg(lr);
- } else */
+ } else
{
signed char hr=get_reg(i_regs->regmap,HIREG);
signed char lr=get_reg(i_regs->regmap,LOREG);
static void div64(int64_t dividend,int64_t divisor)
{
+ if ((dividend) && (divisor)) {
lo=dividend/divisor;
hi=dividend%divisor;
+ } else {
+ lo=0;
+ hi=0;
+ }
//DebugMessage(M64MSG_VERBOSE, "TRACE: ddiv %8x%8x %8x%8x" ,(int)reg[HIREG],(int)(reg[HIREG]>>32)
// ,(int)reg[LOREG],(int)(reg[LOREG]>>32));
}
static void divu64(uint64_t dividend,uint64_t divisor)
{
+ if ((dividend) && (divisor)) {
+ lo=dividend/divisor;
+ hi=dividend%divisor;
+ } else {
+ lo=0;
+ hi=0;
+ }
+ //DebugMessage(M64MSG_VERBOSE, "TRACE: ddivu %8x%8x %8x%8x",(int)reg[HIREG],(int)(reg[HIREG]>>32)
+ // ,(int)reg[LOREG],(int)(reg[LOREG]>>32));
+}
+static void div32(int32_t dividend,int32_t divisor)
+{
+ if ((dividend) && (divisor)) {
lo=dividend/divisor;
hi=dividend%divisor;
+ } else {
+ lo=0;
+ hi=0;
+ }
+ //DebugMessage(M64MSG_VERBOSE, "TRACE: ddiv %8x%8x %8x%8x" ,(int)reg[HIREG],(int)(reg[HIREG]>>32)
+ // ,(int)reg[LOREG],(int)(reg[LOREG]>>32));
+}
+static void divu32(uint32_t dividend,uint32_t divisor)
+{
+ if ((dividend) && (divisor)) {
+ lo=dividend/divisor;
+ hi=dividend%divisor;
+ } else {
+ lo=0;
+ hi=0;
+ }
//DebugMessage(M64MSG_VERBOSE, "TRACE: ddivu %8x%8x %8x%8x",(int)reg[HIREG],(int)(reg[HIREG]>>32)
// ,(int)reg[LOREG],(int)(reg[LOREG]>>32));
}
static void mult64(int64_t m1,int64_t m2)
{
- unsigned long long int op1, op2, op3, op4;
- unsigned long long int result1, result2, result3, result4;
- unsigned long long int temp1, temp2, temp3, temp4;
+ uint64_t op1, op2, op3, op4;
+ uint64_t result1, result2, result3, result4;
+ uint64_t temp1, temp2, temp3, temp4;
int sign = 0;
if (m1 < 0)
#if NEW_DYNAREC == NEW_DYNAREC_ARM
static void multu64(uint64_t m1,uint64_t m2)
{
- unsigned long long int op1, op2, op3, op4;
- unsigned long long int result1, result2, result3, result4;
- unsigned long long int temp1, temp2, temp3, temp4;
+ uint64_t op1, op2, op3, op4;
+ uint64_t result1, result2, result3, result4;
+ uint64_t temp1, temp2, temp3, temp4;
op1 = m1 & 0xFFFFFFFF;
op2 = (m1 >> 32) & 0xFFFFFFFF;
long long int reg_cop1_fgr_64[32];
tlb tlb_e[32];
unsigned int delay_slot, skip_jump = 0, dyna_interp = 0, last_addr;
-unsigned long long int debug_count = 0;
unsigned int CIC_Chip;
char invalid_code[0x100000];
current_instruction_table = cached_interpreter_table;
- debug_count = 0;
delay_slot=0;
stop = 0;
rompause = 0;
free_blocks();
}
- debug_count+= Count;
DebugMessage(M64MSG_INFO, "R4300 emulator finished.");
/* print instruction counts */
extern int FCR0, FCR31;
extern tlb tlb_e[32];
extern unsigned int delay_slot, skip_jump, dyna_interp, op;
-extern unsigned long long int debug_count;
extern unsigned int r4300emu;
extern unsigned int next_interupt, CIC_Chip;
extern int rounding_mode, trunc_mode, round_mode, ceil_mode, floor_mode;