diff --git a/cpu/ppc/ppcfpopcodes.cpp b/cpu/ppc/ppcfpopcodes.cpp index f024e08..af21f12 100644 --- a/cpu/ppc/ppcfpopcodes.cpp +++ b/cpu/ppc/ppcfpopcodes.cpp @@ -122,7 +122,7 @@ inline void ppc_update_cr1() { ((ppc_state.fpscr >> 4) & CR_select::CR1_field); } -int64_t round_to_nearest(double f) { +int32_t round_to_nearest(double f) { if (f >= 0.0) { return static_cast(static_cast (std::ceil(f))); } else { @@ -154,15 +154,15 @@ void update_fpscr(uint32_t new_fpscr) { ppc_state.fpscr = new_fpscr; } -int64_t round_to_zero(double f) { +int32_t round_to_zero(double f) { return static_cast(std::trunc(f)); } -int64_t round_to_pos_inf(double f) { +int32_t round_to_pos_inf(double f) { return static_cast(std::ceil(f)); } -int64_t round_to_neg_inf(double f) { +int32_t round_to_neg_inf(double f) { return static_cast(std::floor(f)); } @@ -663,19 +663,21 @@ static void round_to_int(const uint8_t mode) { } else { switch (mode & 0x3) { case 0: - ppc_result64_d = round_to_nearest(val_reg_b); + ppc_result64_d = (uint32_t)round_to_nearest(val_reg_b); break; case 1: - ppc_result64_d = round_to_zero(val_reg_b); + ppc_result64_d = (uint32_t)round_to_zero(val_reg_b); break; case 2: - ppc_result64_d = round_to_pos_inf(val_reg_b); + ppc_result64_d = (uint32_t)round_to_pos_inf(val_reg_b); break; case 3: - ppc_result64_d = round_to_neg_inf(val_reg_b); + ppc_result64_d = (uint32_t)round_to_neg_inf(val_reg_b); break; } + ppc_result64_d |= 0xFFF8000000000000ULL; + ppc_store_dfpresult_int(reg_d); }