mirror of
https://github.com/dingusdev/dingusppc.git
synced 2024-06-17 13:29:37 +00:00
poweropcodes: Fix doz.
Calculate overflow first before calculating condition codes because the overflow condition is copied from XER. Fix OV calculation. Previously, it was using power_setsoov which I think is only for add and subtract operations. doz does a subtract but only if the result is supposed to be positive, therefore a negative result indicates an overflow.
This commit is contained in:
parent
0d1ce68d19
commit
df7ff76404
|
@ -175,13 +175,18 @@ template void dppc_interpreter::power_divs<RC1, OV1>();
|
||||||
template <field_rc rec, field_ov ov>
|
template <field_rc rec, field_ov ov>
|
||||||
void dppc_interpreter::power_doz() {
|
void dppc_interpreter::power_doz() {
|
||||||
ppc_grab_regsdab(ppc_cur_instruction);
|
ppc_grab_regsdab(ppc_cur_instruction);
|
||||||
uint32_t ppc_result_d = (int32_t(ppc_result_a) >= int32_t(ppc_result_b)) ? 0 :
|
uint32_t ppc_result_d = (int32_t(ppc_result_a) < int32_t(ppc_result_b)) ?
|
||||||
ppc_result_b - ppc_result_a;
|
ppc_result_b - ppc_result_a : 0;
|
||||||
|
|
||||||
|
if (ov) {
|
||||||
|
if (int32_t(ppc_result_d) < 0) {
|
||||||
|
ppc_state.spr[SPR::XER] |= XER::SO | XER::OV;
|
||||||
|
} else {
|
||||||
|
ppc_state.spr[SPR::XER] &= ~XER::OV;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (rec)
|
if (rec)
|
||||||
ppc_changecrf0(ppc_result_d);
|
ppc_changecrf0(ppc_result_d);
|
||||||
if (ov)
|
|
||||||
power_setsoov(ppc_result_a, ppc_result_b, ppc_result_d);
|
|
||||||
|
|
||||||
ppc_store_iresult_reg(reg_d, ppc_result_d);
|
ppc_store_iresult_reg(reg_d, ppc_result_d);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user