Refactor recent subfme fix.

This commit is contained in:
Maxim Poliakovski 2023-12-24 02:35:38 +01:00
parent dc00879419
commit fef5bde0c7

View File

@ -1,6 +1,6 @@
/* /*
DingusPPC - The Experimental PowerPC Macintosh emulator DingusPPC - The Experimental PowerPC Macintosh emulator
Copyright (C) 2018-21 divingkatae and maximum Copyright (C) 2018-23 divingkatae and maximum
(theweirdo) spatium (theweirdo) spatium
(Contact divingkatae#1017 or powermax#2286 on Discord for more info) (Contact divingkatae#1017 or powermax#2286 on Discord for more info)
@ -362,20 +362,19 @@ void dppc_interpreter::ppc_subfe() {
void dppc_interpreter::ppc_subfme() { void dppc_interpreter::ppc_subfme() {
ppc_grab_regsda(); ppc_grab_regsda();
uint32_t grab_xer = !!(ppc_state.spr[SPR::XER] & 0x20000000); uint32_t grab_ca = !!(ppc_state.spr[SPR::XER] & XER::CA);
ppc_result_d = ~ppc_result_a + grab_xer - 1; ppc_result_d = ~ppc_result_a + grab_ca - 1;
if (ppc_result_d == ppc_result_a) { if (ppc_result_a == 0xFFFFFFFFUL && !grab_ca)
// this only occurs when CA is 0 and ppc_result_a is 0x7fffffff or 0xffffffff ppc_state.spr[SPR::XER] &= ~XER::CA;
if ((int32_t)ppc_result_d > 0) { else
ppc_state.spr[SPR::XER] |= oe_flag ? 0xE0000000UL : 0x20000000UL; // set SO,OV,CA ppc_state.spr[SPR::XER] |= XER::CA;
} else {
ppc_state.spr[SPR::XER] &= oe_flag ? ~0x60000000UL : ~0x20000000UL; // clear OV,CA if (oe_flag) {
} if (ppc_result_d == ppc_result_a && (int32_t)ppc_result_d > 0)
} else { ppc_state.spr[SPR::XER] |= XER::SO | XER::OV;
ppc_state.spr[SPR::XER] |= 0x20000000UL; // set CA else
if (oe_flag) ppc_state.spr[SPR::XER] &= ~XER::OV;
ppc_state.spr[SPR::XER] &= ~0x40000000UL; // clear OV
} }
if (rc_flag) if (rc_flag)