diff options
author | notaz | 2011-06-26 03:23:15 +0300 |
---|---|---|
committer | notaz | 2011-07-08 00:15:08 +0300 |
commit | 44a80f6a19c52fc9680c852c62ad27081d44c674 (patch) | |
tree | 3a35f371d31c1c2a9c31e2173049920078e7aeea | |
parent | c7a56f4f574167acc7e3751cf04aa9bf9ebba913 (diff) | |
download | pcsx_rearmed-44a80f6a19c52fc9680c852c62ad27081d44c674.tar.gz pcsx_rearmed-44a80f6a19c52fc9680c852c62ad27081d44c674.tar.bz2 pcsx_rearmed-44a80f6a19c52fc9680c852c62ad27081d44c674.zip |
drc: handle division by 0 correctly
-rw-r--r-- | libpcsxcore/new_dynarec/assem_arm.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/libpcsxcore/new_dynarec/assem_arm.c b/libpcsxcore/new_dynarec/assem_arm.c index 5ee226b..0c668d3 100644 --- a/libpcsxcore/new_dynarec/assem_arm.c +++ b/libpcsxcore/new_dynarec/assem_arm.c @@ -4493,7 +4493,9 @@ void multdiv_assemble_arm(int i,struct regstat *i_regs) assert(quotient>=0); assert(remainder>=0); emit_movs(d1,remainder); - emit_negmi(remainder,remainder); + emit_movimm(0xffffffff,quotient); + emit_negmi(quotient,quotient); // .. quotient and .. + emit_negmi(remainder,remainder); // .. remainder for div0 case (will be negated back after jump) emit_movs(d2,HOST_TEMPREG); emit_jeq((int)out+52); // Division by zero emit_negmi(HOST_TEMPREG,HOST_TEMPREG); @@ -4521,12 +4523,13 @@ void multdiv_assemble_arm(int i,struct regstat *i_regs) signed char remainder=get_reg(i_regs->regmap,HIREG); assert(quotient>=0); assert(remainder>=0); + emit_mov(d1,remainder); + emit_movimm(0xffffffff,quotient); // div0 case emit_test(d2,d2); - emit_jeq((int)out+44); // Division by zero + emit_jeq((int)out+40); // Division by zero emit_clz(d2,HOST_TEMPREG); emit_movimm(1<<31,quotient); emit_shl(d2,HOST_TEMPREG,d2); - emit_mov(d1,remainder); emit_shr(quotient,HOST_TEMPREG,quotient); emit_cmp(remainder,d2); emit_subcs(remainder,d2,remainder); |