From 6a083869e1d34eadd92866e7f2e916acd126c948 Mon Sep 17 00:00:00 2001 From: dingusdev Date: Tue, 21 Jan 2020 19:25:50 -0700 Subject: [PATCH] Started a massive FP fix-up --- cpu/ppc/ppcemu.h | 30 +- cpu/ppc/ppcfpopcodes.cpp | 1611 +++++++++++++++++++------------------- cpu/ppc/ppcopcodes.cpp | 381 ++++----- main.cpp | 3 +- 4 files changed, 1007 insertions(+), 1018 deletions(-) diff --git a/cpu/ppc/ppcemu.h b/cpu/ppc/ppcemu.h index 9832e1b..b79531b 100644 --- a/cpu/ppc/ppcemu.h +++ b/cpu/ppc/ppcemu.h @@ -28,6 +28,11 @@ enum endian_switch {big_end = 0, little_end = 1}; typedef void (*PPCOpcode)(void); +typedef union FPR_storage { + double dbl64_r = 0.0; // double floating-point representation + uint64_t int64_r; // double integer representation +}; + /** Except for the floating-point registers, all registers require 32 bits for representation. Floating-point registers need 64 bits. @@ -43,7 +48,7 @@ fpscr = FP Status and Condition Register **/ typedef struct struct_ppc_state { - uint64_t ppc_fpr [32]; + FPR_storage ppc_fpr [32]; uint32_t ppc_pc; //Referred as the CIA in the PPC manual uint32_t ppc_gpr [32]; uint32_t ppc_cr; @@ -59,7 +64,7 @@ extern SetPRS ppc_state; /** typedef struct struct_ppc64_state { - uint64_t ppc_fpr [32]; + FPR_storage ppc_fpr [32]; uint64_t ppc_pc; //Referred as the CIA in the PPC manual uint64_t ppc_gpr [32]; uint32_t ppc_cr; @@ -138,7 +143,6 @@ extern uint32_t uimm; extern uint32_t not_this; extern uint32_t grab_sr; extern uint32_t grab_inb; //This is for grabbing the number of immediate bytes for loading and storing -extern uint32_t grab_d; //This is for grabbing d from Store and Load instructions extern uint32_t ppc_to; extern int32_t simm; extern int32_t adr_li; @@ -224,6 +228,10 @@ void ppc_opcode31(); void ppc_opcode59(); void ppc_opcode63(); +extern bool ppc_confirm_inf_nan(uint64_t input_a, uint64_t input_b, bool is_single, uint32_t op); +extern double fp_return_double(uint32_t reg); +extern uint64_t fp_return_uint64(uint32_t reg); + extern void ppc_grab_regsda(); extern void ppc_grab_regsdb(); @@ -238,17 +246,17 @@ extern void ppc_grab_regsdauimm(); extern void ppc_grab_regsasimm(); extern void ppc_grab_regssauimm(); -extern void ppc_grab_regsfpdb(); -extern void ppc_grab_regsfpdab(); -extern void ppc_grab_regsfpdia(); -extern void ppc_grab_regsfpdiab(); -extern void ppc_grab_regsfpsia(); -extern void ppc_grab_regsfpsiab(); +extern void ppc_grab_regsfpdb(bool int_rep); +extern void ppc_grab_regsfpdab(bool int_rep); +extern void ppc_grab_regsfpdia(bool int_rep); +extern void ppc_grab_regsfpdiab(bool int_rep); +extern void ppc_grab_regsfpsia(bool int_rep); +extern void ppc_grab_regsfpsiab(bool int_rep); extern void ppc_store_result_regd(); extern void ppc_store_result_rega(); -extern void ppc_store_sfpresult(); -extern void ppc_store_dfpresult(); +extern void ppc_store_sfpresult(bool int_rep); +extern void ppc_store_dfpresult(bool int_rep); void ppc_carry(uint32_t a, uint32_t b); void ppc_setsoov(uint32_t a, uint32_t b); diff --git a/cpu/ppc/ppcfpopcodes.cpp b/cpu/ppc/ppcfpopcodes.cpp index a1d88df..c33dc7c 100644 --- a/cpu/ppc/ppcfpopcodes.cpp +++ b/cpu/ppc/ppcfpopcodes.cpp @@ -21,1090 +21,1053 @@ #include //Used for FP calcs - uint64_t ppc_result64_a; - uint64_t ppc_result64_b; - uint64_t ppc_result64_c; - uint64_t ppc_result64_d; +uint64_t ppc_result64_a; +uint64_t ppc_result64_b; +uint64_t ppc_result64_c; +uint64_t ppc_result64_d; - double snan = std::numeric_limits::signaling_NaN(); - double qnan = std::numeric_limits::quiet_NaN(); +double ppc_dblresult64_a; +double ppc_dblresult64_b; +double ppc_dblresult64_c; +double ppc_dblresult64_d; + +double snan = std::numeric_limits::signaling_NaN(); +double qnan = std::numeric_limits::quiet_NaN(); //Storage and register retrieval functions for the floating point functions. -void ppc_store_sfpresult(){ - ppc_state.ppc_fpr[reg_d] = (uint64_t)ppc_result_d; +double fp_return_double(uint32_t reg) { + return ppc_state.ppc_fpr[reg].dbl64_r; } -void ppc_store_dfpresult(){ - ppc_state.ppc_fpr[reg_d] = ppc_result64_d; +uint64_t fp_return_uint64(uint32_t reg) { + return ppc_state.ppc_fpr[reg].int64_r; } -void ppc_grab_regsfpdb(){ +void ppc_store_sfpresult(bool int_rep) { + if (int_rep) { + ppc_state.ppc_fpr[reg_d].int64_r = ppc_result64_d; + ppc_state.ppc_fpr[reg_d].dbl64_r = static_cast(ppc_result64_d); + } + else { + ppc_state.ppc_fpr[reg_d].dbl64_r = ppc_dblresult64_d; + ppc_state.ppc_fpr[reg_d].int64_r = *(uint64_t*)&ppc_dblresult64_d; + } +} + +void ppc_store_dfpresult(bool int_rep) { + if (int_rep) { + ppc_state.ppc_fpr[reg_d].int64_r = ppc_result64_d; + ppc_state.ppc_fpr[reg_d].dbl64_r = static_cast(ppc_result64_d); + } + else { + ppc_state.ppc_fpr[reg_d].dbl64_r = ppc_dblresult64_d; + ppc_state.ppc_fpr[reg_d].int64_r = *(uint64_t*)&ppc_dblresult64_d; + } +} + +void ppc_grab_regsfpdb(bool int_rep) { reg_d = (ppc_cur_instruction >> 21) & 31; reg_b = (ppc_cur_instruction >> 11) & 31; - ppc_result64_b = ppc_state.ppc_fpr[reg_b]; + if (int_rep) { + ppc_result64_b = ppc_state.ppc_fpr[reg_b].int64_r; + } + else { + ppc_dblresult64_b = ppc_state.ppc_fpr[reg_b].dbl64_r; + } } -void ppc_grab_regsfpdiab(){ +void ppc_grab_regsfpdiab(bool int_rep) { reg_d = (ppc_cur_instruction >> 21) & 31; reg_a = (ppc_cur_instruction >> 16) & 31; reg_b = (ppc_cur_instruction >> 11) & 31; + if (int_rep == true) { + + } ppc_result_a = ppc_state.ppc_gpr[reg_a]; ppc_result_b = ppc_state.ppc_gpr[reg_b]; } -void ppc_grab_regsfpdia(){ +void ppc_grab_regsfpdia(bool int_rep) { reg_d = (ppc_cur_instruction >> 21) & 31; reg_a = (ppc_cur_instruction >> 16) & 31; ppc_result_a = ppc_state.ppc_gpr[reg_a]; } -void ppc_grab_regsfpsia(){ +void ppc_grab_regsfpsia(bool int_rep) { reg_s = (ppc_cur_instruction >> 21) & 31; reg_a = (ppc_cur_instruction >> 16) & 31; ppc_result_d = ppc_state.ppc_gpr[reg_s]; ppc_result_a = ppc_state.ppc_gpr[reg_a]; } -void ppc_grab_regsfpsiab(){ +void ppc_grab_regsfpsiab(bool int_rep) { reg_s = (ppc_cur_instruction >> 21) & 31; reg_a = (ppc_cur_instruction >> 16) & 31; reg_b = (ppc_cur_instruction >> 11) & 31; - ppc_result64_d = ppc_state.ppc_fpr[reg_s]; + ppc_result64_d = ppc_state.ppc_fpr[reg_s].int64_r; ppc_result_a = ppc_state.ppc_gpr[reg_a]; ppc_result_b = ppc_state.ppc_gpr[reg_b]; } -void ppc_grab_regsfpsab(){ +void ppc_grab_regsfpsab(bool int_rep) { reg_s = (ppc_cur_instruction >> 21) & 31; reg_a = (ppc_cur_instruction >> 16) & 31; reg_b = (ppc_cur_instruction >> 11) & 31; - ppc_result64_d = ppc_state.ppc_fpr[reg_s]; - ppc_result64_a = ppc_state.ppc_fpr[reg_a]; - ppc_result64_b = ppc_state.ppc_fpr[reg_b]; + if (int_rep) { + ppc_result64_d = ppc_state.ppc_fpr[reg_s].int64_r; + ppc_result64_a = ppc_state.ppc_fpr[reg_a].int64_r; + ppc_result64_b = ppc_state.ppc_fpr[reg_b].int64_r; + } + else { + ppc_dblresult64_a = fp_return_double(reg_a); + ppc_dblresult64_c = fp_return_double(reg_c); + } } -void ppc_grab_regsfpdab(){ +void ppc_grab_regsfpdab(bool int_rep) { reg_d = (ppc_cur_instruction >> 21) & 31; reg_a = (ppc_cur_instruction >> 16) & 31; reg_b = (ppc_cur_instruction >> 11) & 31; - ppc_result64_a = ppc_state.ppc_fpr[reg_a]; - ppc_result64_b = ppc_state.ppc_fpr[reg_b]; + if (int_rep) { + ppc_result64_a = fp_return_uint64(reg_a); + ppc_result64_b = fp_return_uint64(reg_b); + } + else { + ppc_dblresult64_a = fp_return_double(reg_a); + ppc_dblresult64_b = fp_return_double(reg_b); + } } -void ppc_grab_regsfpdac(){ +void ppc_grab_regsfpdac(bool int_rep) { reg_d = (ppc_cur_instruction >> 21) & 31; reg_a = (ppc_cur_instruction >> 16) & 31; reg_c = (ppc_cur_instruction >> 6) & 31; - ppc_result64_a = ppc_state.ppc_fpr[reg_a]; - ppc_result64_c = ppc_state.ppc_fpr[reg_c]; + if (int_rep) { + ppc_result64_a = fp_return_uint64(reg_a); + ppc_result64_c = fp_return_uint64(reg_c); + } + else { + ppc_dblresult64_a = fp_return_double(reg_a); + ppc_dblresult64_c = fp_return_double(reg_c); + } } -void ppc_grab_regsfpdabc(){ +void ppc_grab_regsfpdabc(bool int_rep) { reg_d = (ppc_cur_instruction >> 21) & 31; reg_a = (ppc_cur_instruction >> 16) & 31; reg_b = (ppc_cur_instruction >> 11) & 31; reg_c = (ppc_cur_instruction >> 6) & 31; - ppc_result64_a = ppc_state.ppc_fpr[reg_a]; - ppc_result64_b = ppc_state.ppc_fpr[reg_b]; - ppc_result64_c = ppc_state.ppc_fpr[reg_c]; + if (int_rep) { + ppc_result64_a = fp_return_uint64(reg_a); + ppc_result64_b = fp_return_uint64(reg_b); + ppc_result64_c = fp_return_uint64(reg_c); + } + else { + ppc_dblresult64_a = fp_return_double(reg_a); + ppc_dblresult64_b = fp_return_double(reg_b); + ppc_dblresult64_c = fp_return_double(reg_c); + } +} + +void fp_save_float(float entry) { + ppc_state.ppc_fpr[reg_d].dbl64_r = (double)entry; + ppc_state.ppc_fpr[reg_d].int64_r = (uint64_t)entry; +} + +void fp_save_double(double entry) { + ppc_state.ppc_fpr[reg_d].dbl64_r = entry; + ppc_state.ppc_fpr[reg_d].int64_r = *(uint64_t*)&entry; +} + +void fp_save_uint64(uint64_t entry) { + ppc_state.ppc_fpr[reg_d].int64_r = entry; + ppc_state.ppc_fpr[reg_d].dbl64_r = (double)entry; +} + +void fp_save_uint32(uint32_t entry) { + ppc_state.ppc_fpr[reg_d].int64_r = entry; + ppc_state.ppc_fpr[reg_d].dbl64_r = (double)entry; + } void ppc_fp_changecrf1() { ppc_state.ppc_fpscr |= 0xf0000000; } -void ppc_divbyzero(uint64_t input_a, uint64_t input_b, bool is_single){ - if (input_b == 0){ +void ppc_divbyzero(uint64_t input_a, uint64_t input_b, bool is_single) { + if (input_b == 0) { ppc_state.ppc_fpscr |= 0x84000000; - - if (input_a == 0){ + if (input_a == 0) { ppc_state.ppc_fpscr |= 0x200000; } - } - } -bool ppc_confirm_inf_nan(uint64_t input_a, uint64_t input_b, bool is_single, uint32_t op){ - if (is_single){ + +bool ppc_confirm_inf_nan(uint64_t input_a, uint64_t input_b, bool is_single, uint32_t op) { + if (is_single) { uint32_t exp_a = (input_a >> 23) & 0xff; uint32_t exp_b = (input_b >> 23) & 0xff; ppc_state.ppc_fpscr &= 0x7fbfffff; - switch(op){ - case 36: - if ((exp_a == 0xff) & (exp_b == 0xff)){ - ppc_state.ppc_fpscr |= 0x80400000; - return true; - } - else if ((input_a == 0) & (input_b == 0)){ - ppc_state.ppc_fpscr |= 0x80200000; - return true; - } - break; - case 40: - if ((exp_a == 0xff) & (exp_b == 0xff)){ - ppc_state.ppc_fpscr |= 0x80800000; - return true; - } - break; - case 50: - if (((exp_a == 0xff) & (input_b == 0)) | ((exp_b == 0xff) & (input_a == 0))){ - ppc_state.ppc_fpscr |= 0x80100000; - return true; - } - break; - case 56: - case 58: - if ((exp_a == 0xff) & (exp_b == 0xff)) { - ppc_state.ppc_fpscr |= 0x80800000; - return true; - } - break; + switch (op) { + case 36: + if ((exp_a == 0xff) & (exp_b == 0xff)) { + ppc_state.ppc_fpscr |= 0x80400000; + return true; + } + else if ((input_a == 0) & (input_b == 0)) { + ppc_state.ppc_fpscr |= 0x80200000; + return true; + } + break; + case 40: + if ((exp_a == 0xff) & (exp_b == 0xff)) { + ppc_state.ppc_fpscr |= 0x80800000; + return true; + } + break; + case 50: + if (((exp_a == 0xff) & (input_b == 0)) | ((exp_b == 0xff) & (input_a == 0))) { + ppc_state.ppc_fpscr |= 0x80100000; + return true; + } + break; + case 56: + case 58: + if ((exp_a == 0xff) & (exp_b == 0xff)) { + ppc_state.ppc_fpscr |= 0x80800000; + return true; + } + break; + default: + return false; } } - else{ + else { uint32_t exp_a = (input_a >> 52) & 0x7ff; uint32_t exp_b = (input_b >> 52) & 0x7ff; ppc_state.ppc_fpscr &= 0x7fbfffff; - switch(op){ - case 36: - if ((exp_a == 0x7ff) & (exp_b == 0x7ff)){ - ppc_state.ppc_fpscr |= 0x80400000; - return true; - } - else if ((input_a == 0) & (input_b == 0)){ - ppc_state.ppc_fpscr |= 0x80200000; - return true; - } - break; - case 40: - if ((exp_a == 0x7ff) & (exp_b == 0x7ff)){ - ppc_state.ppc_fpscr |= 0x80800000; - return true; - } - break; - case 50: - if (((exp_a == 0x7ff) & (input_b == 0)) | ((exp_b == 0x7ff) & (input_a == 0))){ - ppc_state.ppc_fpscr |= 0x80100000; - return true; - } - break; - case 56: - case 58: - if ((exp_a == 0xff) & (exp_b == 0xff)) { - ppc_state.ppc_fpscr |= 0x80800000; - return true; - } - break; + switch (op) { + case 36: + if ((exp_a == 0x7ff) & (exp_b == 0x7ff)) { + ppc_state.ppc_fpscr |= 0x80400000; + return true; + } + else if ((input_a == 0) & (input_b == 0)) { + ppc_state.ppc_fpscr |= 0x80200000; + return true; + } + break; + case 40: + if ((exp_a == 0x7ff) & (exp_b == 0x7ff)) { + ppc_state.ppc_fpscr |= 0x80800000; + return true; + } + break; + case 50: + if (((exp_a == 0x7ff) & (input_b == 0)) | ((exp_b == 0x7ff) & (input_a == 0))) { + ppc_state.ppc_fpscr |= 0x80100000; + return true; + } + break; + case 56: + case 58: + if ((exp_a == 0xff) & (exp_b == 0xff)) { + ppc_state.ppc_fpscr |= 0x80800000; + return true; + } + break; + default: + return false; } } } -void ppc_fpresult_update(uint64_t set_result, bool confirm_arc){ +void ppc_fpresult_update(uint64_t set_result, bool confirm_arc) { bool confirm_ov = (bool)std::fetestexcept(FE_OVERFLOW); - if (confirm_ov){ + if (confirm_ov) { ppc_state.ppc_fpscr |= 0x80001000; } - if (confirm_arc){ + if (confirm_arc) { ppc_state.ppc_fpscr |= 0x80010000; ppc_state.ppc_fpscr &= 0xFFFF0FFF; - if (set_result < 0){ + if (set_result < 0) { ppc_state.ppc_fpscr |= 0x8000; } - else if (set_result > 0){ + else if (set_result > 0) { ppc_state.ppc_fpscr |= 0x4000; } - else if (set_result == 0){ + else if (set_result == 0) { ppc_state.ppc_fpscr |= 0x2000; } - else{ + else { ppc_state.ppc_fpscr |= 0x1000; } } } -void ppc_changecrf1(){ +void ppc_frsqrte_result() { + + if (ppc_result64_d) { + + } +} + +void ppc_changecrf1() { ppc_state.ppc_cr &= 0xF0FFFFFF; ppc_state.ppc_cr |= (ppc_state.ppc_fpscr & 0xF0000000) >> 4; } //Floating Point Arithmetic void ppc_fadd() { - ppc_grab_regsfpdab(); - double testd1 = (double)ppc_result64_a; - double testd2 = (double)ppc_result64_b; + ppc_grab_regsfpdab(false); if (!ppc_confirm_inf_nan(ppc_result64_a, ppc_result64_b, false, 58)) { - double testd3 = testd1 + testd2; - - uint64_t* pre_final = (uint64_t*)&testd3; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); + ppc_dblresult64_d = ppc_dblresult64_a + ppc_dblresult64_b; + ppc_store_dfpresult(false); } } -void ppc_fadddot(){ - ppc_grab_regsfpdab(); - double testd1 = (double)ppc_result64_a; - double testd2 = (double)ppc_result64_b; +void ppc_fadddot() { + ppc_grab_regsfpdab(false); - double testd3 = testd1 + testd2; - - ppc_result64_d = (uint64_t)testd3; - ppc_store_dfpresult(); - ppc_changecrf1(); -} - -void ppc_fsub(){ - ppc_grab_regsfpdab(); - double testd1 = (double)ppc_result64_a; - double testd2 = (double)ppc_result64_b; - - double testd3 = testd1 - testd2; - - uint64_t *pre_final = (uint64_t *)&testd3; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); -} - -void ppc_fsubdot(){ - ppc_grab_regsfpdab(); - double testd1 = (double)ppc_result64_a; - double testd2 = (double)ppc_result64_b; - - double testd3 = testd1 - testd2; - - uint64_t *pre_final = (uint64_t *)&testd3; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); - ppc_changecrf1(); -} - -void ppc_fdiv(){ - ppc_grab_regsfpdab(); - double testd1 = (double)ppc_result64_a; - double testd2 = (double)ppc_result64_b; - - double testd3 = testd1 / testd2; - - uint64_t *pre_final = (uint64_t *)&testd3; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); -} - -void ppc_fdivdot(){ - ppc_grab_regsfpdab(); - double testd1 = (double)ppc_result64_a; - double testd2 = (double)ppc_result64_b; - - double testd3 = testd1 / testd2; - - uint64_t *pre_final = (uint64_t *)&testd3; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); - ppc_changecrf1(); -} - -void ppc_fmult(){ - ppc_grab_regsfpdac(); - double testd1 = (double)ppc_result64_a; - double testd2 = (double)ppc_result64_c; - - double testd3 = testd1 * testd2; - - uint64_t *pre_final = (uint64_t *)&testd3; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); -} - -void ppc_fmultdot(){ - ppc_grab_regsfpdac(); - double testd1 = (double)ppc_result64_a; - double testd2 = (double)ppc_result64_c; - - double testd3 = testd1 * testd2; - - uint64_t *pre_final = (uint64_t *)&testd3; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); - ppc_changecrf1(); -} - -void ppc_fmadd(){ - ppc_grab_regsfpdabc(); - double testd1 = (double)ppc_result64_a; - double testd2 = (double)ppc_result64_b; - double testd3 = (double)ppc_result64_c; - - double testd4 = (testd1 * testd3); - testd4 += testd2; - - uint64_t *pre_final = (uint64_t *)&testd4; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); -} - -void ppc_fmadddot(){ - ppc_grab_regsfpdabc(); - double testd1 = (double)ppc_result64_a; - double testd2 = (double)ppc_result64_b; - double testd3 = (double)ppc_result64_c; - - double testd4 = (testd1 * testd3); - testd4 += testd2; - - uint64_t *pre_final = (uint64_t *)&testd4; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); - ppc_changecrf1(); -} - -void ppc_fmsub(){ - ppc_grab_regsfpdabc(); - double testd1 = (double)ppc_result64_a; - double testd2 = (double)ppc_result64_b; - double testd3 = (double)ppc_result64_c; - - double testd4 = (testd1 * testd3); - testd4 -= testd2; - - uint64_t *pre_final = (uint64_t *)&testd4; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); -} - -void ppc_fmsubdot(){ - ppc_grab_regsfpdabc(); - double testd1 = (double)ppc_result64_a; - double testd2 = (double)ppc_result64_b; - double testd3 = (double)ppc_result64_c; - - double testd4 = (testd1 * testd3); - testd4 -= testd2; - - uint64_t *pre_final = (uint64_t *)&testd4; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); - ppc_changecrf1(); -} - -void ppc_fnmadd(){ - ppc_grab_regsfpdabc(); - double testd1 = (double)ppc_result64_a; - double testd2 = (double)ppc_result64_b; - double testd3 = (double)ppc_result64_c; - - double testd4 = (testd1 * testd3); - testd4 += testd2; - testd4 = -testd4; - - uint64_t *pre_final = (uint64_t *)&testd4; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); -} - -void ppc_fnmadddot(){ - ppc_grab_regsfpdabc(); - double testd1 = (double)ppc_result64_a; - double testd2 = (double)ppc_result64_b; - double testd3 = (double)ppc_result64_c; - - double testd4 = (testd1 * testd3); - testd4 += testd2; - testd4 = -testd4; - - uint64_t *pre_final = (uint64_t *)&testd4; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); - ppc_changecrf1(); -} - -void ppc_fnmsub(){ - ppc_grab_regsfpdabc(); - double testd1 = (double)ppc_result64_a; - double testd2 = (double)ppc_result64_b; - double testd3 = (double)ppc_result64_c; - - double testd4 = (testd1 * testd3); - testd4 -= testd2; - testd4 = -testd4; - - uint64_t *pre_final = (uint64_t *)&testd4; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); -} - -void ppc_fnmsubdot(){ - ppc_grab_regsfpdabc(); - double testd1 = (double)ppc_result64_a; - double testd2 = (double)ppc_result64_b; - double testd3 = (double)ppc_result64_c; - - double testd4 = (testd1 * testd3); - testd4 -= testd2; - testd4 = -testd4; - - uint64_t *pre_final = (uint64_t *)&testd4; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); - ppc_changecrf1(); -} - -void ppc_fadds(){ - ppc_grab_regsfpdab(); - float testf1 = (float)ppc_result64_a; - float testf2 = (float)ppc_result64_b; - - float testf3 = testf1 + testf2; - - uint64_t *pre_final = (uint64_t *)&testf3; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); -} - -void ppc_faddsdot(){ - ppc_grab_regsfpdab(); - float testf1 = (float)ppc_result64_a; - float testf2 = (float)ppc_result64_b; - - float testf3 = testf1 + testf2; - - uint64_t *pre_final = (uint64_t *)&testf3; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); - ppc_changecrf1(); -} - -void ppc_fsubs(){ - ppc_grab_regsfpdab(); - float testf1 = (float)ppc_result64_a; - float testf2 = (float)ppc_result64_b; - - float testf3 = testf1 - testf2; - - uint64_t *pre_final = (uint64_t *)&testf3; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); -} - -void ppc_fsubsdot(){ - ppc_grab_regsfpdab(); - float testf1 = (float)ppc_result64_a; - float testf2 = (float)ppc_result64_b; - - float testf3 = testf1 - testf2; - - uint64_t *pre_final = (uint64_t *)&testf3; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); - ppc_changecrf1(); -} - -void ppc_fmults(){ - ppc_grab_regsfpdac(); - float testf1 = (float)ppc_result64_a; - float testf2 = (float)ppc_result64_c; - - float testf3 = testf1 * testf2; - - ppc_result64_d = (uint64_t)testf3; - ppc_store_dfpresult(); -} - -void ppc_fmultsdot(){ - ppc_grab_regsfpdac(); - float testf1 = (float)ppc_result64_a; - float testf2 = (float)ppc_result64_c; - - float testf3 = testf1 * testf2; - - uint64_t *pre_final = (uint64_t *)&testf3; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); - ppc_changecrf1(); -} - -void ppc_fdivs(){ - ppc_grab_regsfpdab(); - float testf1 = (float)ppc_result64_a; - float testf2 = (float)ppc_result64_b; - - float testf3 = testf1 / testf2; - - uint64_t *pre_final = (uint64_t *)&testf3; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); -} - -void ppc_fdivsdot(){ - ppc_grab_regsfpdab(); - float testf1 = (float)ppc_result64_a; - float testf2 = (float)ppc_result64_b; - - float testf3 = testf1 / testf2; - - uint64_t *pre_final = (uint64_t *)&testf3; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); - ppc_changecrf1(); -} - -void ppc_fmadds(){ - ppc_grab_regsfpdabc(); - float testf1 = (float)ppc_result64_a; - float testf2 = (float)ppc_result64_b; - float testf3 = (float)ppc_result64_c; - - float testf4 = (testf1 * testf3); - testf4 += testf2; - - uint64_t *pre_final = (uint64_t *)&testf4; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); -} - -void ppc_fmaddsdot(){ - ppc_grab_regsfpdabc(); - float testf1 = (float)ppc_result64_a; - float testf2 = (float)ppc_result64_b; - float testf3 = (float)ppc_result64_c; - - float testf4 = (testf1 * testf3); - testf4 += testf2; - - uint64_t *pre_final = (uint64_t *)&testf4; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); - ppc_changecrf1(); -} - -void ppc_fmsubs(){ - ppc_grab_regsfpdabc(); - float testf1 = (float)ppc_result64_a; - float testf2 = (float)ppc_result64_b; - float testf3 = (float)ppc_result64_c; - - float testf4 = (testf1 * testf3); - testf4 -= testf2; - - uint64_t *pre_final = (uint64_t *)&testf4; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); -} - -void ppc_fmsubsdot(){ - ppc_grab_regsfpdabc(); - float testf1 = (float)ppc_result64_a; - float testf2 = (float)ppc_result64_b; - float testf3 = (float)ppc_result64_c; - - float testf4 = (testf1 * testf3); - testf4 -= testf2; - - uint64_t *pre_final = (uint64_t *)&testf4; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); - ppc_changecrf1(); -} - -void ppc_fnmadds(){ - ppc_grab_regsfpdabc(); - float testf1 = (float)ppc_result64_a; - float testf2 = (float)ppc_result64_b; - float testf3 = (float)ppc_result64_c; - - float testf4 = (testf1 * testf3); - testf4 += testf2; - testf4 = -testf4; - - uint64_t *pre_final = (uint64_t *)&testf4; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); -} - -void ppc_fnmaddsdot(){ - ppc_grab_regsfpdabc(); - float testf1 = (float)ppc_result64_a; - float testf2 = (float)ppc_result64_b; - float testf3 = (float)ppc_result64_c; - - float testf4 = (testf1 * testf3); - testf4 += testf2; - testf4 = -testf4; - - uint64_t *pre_final = (uint64_t *)&testf4; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); - ppc_changecrf1(); -} - -void ppc_fnmsubs(){ - ppc_grab_regsfpdabc(); - float testf1 = (float)ppc_result64_a; - float testf2 = (float)ppc_result64_b; - float testf3 = (float)ppc_result64_c; - - float testf4 = (testf1 * testf3); - testf4 -= testf2; - testf4 = -testf4; - - uint64_t *pre_final = (uint64_t *)&testf4; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); -} - -void ppc_fnmsubsdot(){ - ppc_grab_regsfpdabc(); - float testf1 = (float)ppc_result64_a; - float testf2 = (float)ppc_result64_b; - float testf3 = (float)ppc_result64_c; - - float testf4 = (testf1 * testf3); - testf4 -= testf2; - testf4 = -testf4; - - uint64_t *pre_final = (uint64_t *)&testf4; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); - ppc_changecrf1(); -} - -void ppc_fabs(){ - ppc_grab_regsfpdb(); - double testd1 = (double)ppc_result64_b; - - ppc_result64_d = (uint64_t)(abs(testd1)); - - ppc_store_dfpresult(); -} - -void ppc_fabsdot(){ - ppc_grab_regsfpdb(); - double testd1 = (double)ppc_result64_b; - - ppc_result64_d = (uint64_t)-(abs(testd1)); - - ppc_store_dfpresult(); - ppc_changecrf1(); -} - -void ppc_fnabs(){ - ppc_grab_regsfpdb(); - double testd1 = (double)ppc_result64_b; - - ppc_result64_d = (uint64_t)(abs(testd1)); - - ppc_store_dfpresult(); -} - -void ppc_fnabsdot(){ - ppc_grab_regsfpdb(); - double testd1 = (double)ppc_result64_b; - - ppc_result64_d = (uint64_t)-(abs(testd1)); - - ppc_store_dfpresult(); - ppc_changecrf1(); -} - -void ppc_fneg(){ - ppc_grab_regsfpdb(); - double testd1 = (double)ppc_result64_a; - - double testd3 = -testd1; - - ppc_result64_d = (double)testd3; - ppc_store_dfpresult(); -} - -void ppc_fnegdot(){ - ppc_grab_regsfpdb(); - double testd1 = (double)ppc_result64_a; - - double testd3 = -testd1; - - ppc_result64_d = (double)testd3; - ppc_store_dfpresult(); - ppc_changecrf1(); -} - -void ppc_fsel(){ - ppc_grab_regsfpdabc(); - double testd1 = (double)ppc_result64_a; - double testd2 = (double)ppc_result64_b; - double testd3 = (double)ppc_result64_c; - - if (testd1 >= 0.0){ - ppc_result64_d = (uint64_t)testd3; + if (!ppc_confirm_inf_nan(ppc_result64_a, ppc_result64_b, false, 58)) { + ppc_dblresult64_d = ppc_dblresult64_a + ppc_dblresult64_b; + ppc_store_dfpresult(false); } - else{ - ppc_result64_d = (uint64_t)testd2; - } - ppc_store_dfpresult(); -} - -void ppc_fseldot(){ - ppc_grab_regsfpdabc(); - double testd1 = (double)ppc_result64_a; - double testd2 = (double)ppc_result64_b; - double testd3 = (double)ppc_result64_c; - - if (testd1 >= 0.0){ - ppc_result64_d = (uint64_t)testd3; - } - else{ - ppc_result64_d = (uint64_t)testd2; - } - ppc_store_dfpresult(); ppc_changecrf1(); } -void ppc_fsqrt(){ - ppc_grab_regsfpdb(); - double test = (double)ppc_result64_b; - std::sqrt(test); - uint64_t *pre_final = (uint64_t *)&test; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); +void ppc_fsub() { + ppc_grab_regsfpdab(false); + + if (!ppc_confirm_inf_nan(ppc_result64_a, ppc_result64_b, false, 56)) { + ppc_dblresult64_d = ppc_dblresult64_a - ppc_dblresult64_b; + ppc_store_dfpresult(false); + } } -void ppc_fsqrtdot(){ - ppc_grab_regsfpdb(); - double test = (double)ppc_result64_b; - std::sqrt(test); - uint64_t *pre_final = (uint64_t *)&test; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); +void ppc_fsubdot() { + ppc_grab_regsfpdab(false); + + if (!ppc_confirm_inf_nan(ppc_result64_a, ppc_result64_b, false, 56)) { + ppc_dblresult64_d = ppc_dblresult64_a - ppc_dblresult64_b; + ppc_store_dfpresult(false); + } ppc_changecrf1(); } -void ppc_fsqrts(){ - ppc_grab_regsfpdb(); +void ppc_fdiv() { + ppc_grab_regsfpdab(false); + + if (!ppc_confirm_inf_nan(ppc_result64_a, ppc_result64_b, false, 36)) { + ppc_dblresult64_d = ppc_dblresult64_a / ppc_dblresult64_b; + ppc_store_dfpresult(false); + } +} + +void ppc_fdivdot() { + ppc_grab_regsfpdab(false); + + if (!ppc_confirm_inf_nan(ppc_result64_a, ppc_result64_b, false, 36)) { + ppc_dblresult64_d = ppc_dblresult64_a / ppc_dblresult64_b; + ppc_store_dfpresult(false); + } + ppc_changecrf1(); +} + +void ppc_fmult() { + ppc_grab_regsfpdac(false); + + if (!ppc_confirm_inf_nan(ppc_result64_a, ppc_result64_b, false, 50)) { + ppc_dblresult64_d = ppc_dblresult64_a * ppc_dblresult64_b; + ppc_store_dfpresult(false); + } +} + +void ppc_fmultdot() { + ppc_grab_regsfpdac(false); + + if (!ppc_confirm_inf_nan(ppc_result64_a, ppc_result64_b, false, 50)) { + ppc_dblresult64_d = ppc_dblresult64_a * ppc_dblresult64_b; + ppc_store_dfpresult(false); + } + + ppc_changecrf1(); +} + +void ppc_fmadd() { + ppc_grab_regsfpdabc(false); + + ppc_dblresult64_d = (ppc_dblresult64_a * ppc_dblresult64_c); + ppc_dblresult64_d += ppc_dblresult64_b; + + ppc_store_dfpresult(false); +} + +void ppc_fmadddot() { + ppc_grab_regsfpdabc(false); + + ppc_dblresult64_d = (ppc_dblresult64_a * ppc_dblresult64_c); + ppc_dblresult64_d += ppc_dblresult64_b; + + ppc_store_dfpresult(false); + ppc_changecrf1(); +} + +void ppc_fmsub() { + ppc_grab_regsfpdabc(false); + + ppc_dblresult64_d = (ppc_dblresult64_a * ppc_dblresult64_c); + ppc_dblresult64_d -= ppc_dblresult64_b; + + ppc_store_dfpresult(false); +} + +void ppc_fmsubdot() { + ppc_grab_regsfpdabc(false); + + ppc_dblresult64_d = (ppc_dblresult64_a * ppc_dblresult64_c); + ppc_dblresult64_d -= ppc_dblresult64_b; + + ppc_store_dfpresult(false); + ppc_changecrf1(); +} + +void ppc_fnmadd() { + ppc_grab_regsfpdabc(false); + + ppc_dblresult64_d = ppc_dblresult64_a * ppc_result64_c; + ppc_dblresult64_d += -ppc_dblresult64_b; + ppc_store_dfpresult(false); +} + +void ppc_fnmadddot() { + ppc_grab_regsfpdabc(false); + + ppc_dblresult64_d = ppc_dblresult64_a * ppc_result64_c; + ppc_dblresult64_d += ppc_dblresult64_b; + ppc_dblresult64_d = -ppc_dblresult64_d; + + ppc_store_dfpresult(false); + ppc_changecrf1(); +} + +void ppc_fnmsub() { + ppc_grab_regsfpdabc(false); + + ppc_dblresult64_d = ppc_dblresult64_a * ppc_result64_c; + ppc_dblresult64_d -= ppc_dblresult64_b; + ppc_dblresult64_d = -ppc_dblresult64_d; + + ppc_store_dfpresult(false); +} + +void ppc_fnmsubdot() { + ppc_grab_regsfpdabc(false); + + ppc_dblresult64_d = ppc_dblresult64_a * ppc_result64_c; + ppc_dblresult64_d -= ppc_dblresult64_b; + ppc_dblresult64_d = -ppc_dblresult64_d; + + ppc_store_dfpresult(false); + ppc_changecrf1(); +} + +void ppc_fadds() { + ppc_grab_regsfpdab(false); + + if (!ppc_confirm_inf_nan(ppc_result64_a, ppc_result64_b, true, 58)) { + float intermediate = (float)ppc_dblresult64_a + (float)ppc_dblresult64_b; + ppc_dblresult64_d = static_cast(intermediate); + ppc_store_dfpresult(false); + } +} + +void ppc_faddsdot() { + ppc_grab_regsfpdab(false); + + if (!ppc_confirm_inf_nan(ppc_result64_a, ppc_result64_b, true, 58)) { + float intermediate = (float)ppc_dblresult64_a + (float)ppc_dblresult64_b; + ppc_dblresult64_d = static_cast(intermediate); + ppc_store_dfpresult(false); + } + + ppc_changecrf1(); +} + +void ppc_fsubs() { + ppc_grab_regsfpdab(false); + + if (!ppc_confirm_inf_nan(ppc_result64_a, ppc_result64_b, true, 56)) { + float intermediate = (float)ppc_dblresult64_a - (float)ppc_dblresult64_b; + ppc_dblresult64_d = static_cast(intermediate); + ppc_store_dfpresult(false); + } +} + +void ppc_fsubsdot() { + ppc_grab_regsfpdab(false); + + if (!ppc_confirm_inf_nan(ppc_result64_a, ppc_result64_b, true, 56)) { + float intermediate = (float)ppc_dblresult64_a - (float)ppc_dblresult64_b; + ppc_dblresult64_d = static_cast(intermediate); + ppc_store_dfpresult(false); + } + + ppc_changecrf1(); +} + +void ppc_fmults() { + ppc_grab_regsfpdac(false); + + if (!ppc_confirm_inf_nan(ppc_result64_a, ppc_result64_b, true, 50)) { + float intermediate = (float)ppc_dblresult64_a * (float)ppc_dblresult64_b; + ppc_dblresult64_d = static_cast(intermediate); + ppc_store_dfpresult(false); + } +} + +void ppc_fmultsdot() { + ppc_grab_regsfpdac(false); + + if (!ppc_confirm_inf_nan(ppc_result64_a, ppc_result64_b, true, 50)) { + + float intermediate = (float)ppc_dblresult64_a * (float)ppc_dblresult64_b; + ppc_dblresult64_d = static_cast(intermediate); + ppc_store_dfpresult(false); + } + ppc_changecrf1(); +} + +void ppc_fdivs() { + ppc_grab_regsfpdab(false); + + if (!ppc_confirm_inf_nan(ppc_result64_a, ppc_result64_b, true, 36)) { + float intermediate = (float)ppc_dblresult64_a / (float)ppc_dblresult64_b; + ppc_dblresult64_d = static_cast(intermediate); + ppc_store_dfpresult(false); + } +} + +void ppc_fdivsdot() { + ppc_grab_regsfpdab(false); + + if (!ppc_confirm_inf_nan(ppc_result64_a, ppc_result64_b, true, 36)) { + float intermediate = (float)ppc_dblresult64_a / (float)ppc_dblresult64_b; + ppc_dblresult64_d = static_cast(intermediate); + ppc_store_dfpresult(false); + } + + ppc_changecrf1(); +} + +void ppc_fmadds() { + ppc_grab_regsfpdabc(false); + + float intermediate = (float)ppc_dblresult64_a * (float)ppc_dblresult64_c; + intermediate += (float)ppc_dblresult64_b; + ppc_dblresult64_d = static_cast(intermediate); + + ppc_store_dfpresult(false); +} + +void ppc_fmaddsdot() { + ppc_grab_regsfpdabc(false); + + float intermediate = (float)ppc_dblresult64_a * (float)ppc_dblresult64_c; + intermediate += (float)ppc_dblresult64_b; + ppc_dblresult64_d = static_cast(intermediate); + + ppc_store_dfpresult(false); + ppc_changecrf1(); +} + +void ppc_fmsubs() { + ppc_grab_regsfpdabc(false); + + float intermediate = (float)ppc_dblresult64_a * (float)ppc_dblresult64_c; + intermediate -= (float)ppc_dblresult64_b; + ppc_dblresult64_d = static_cast(intermediate); + + ppc_store_dfpresult(false); +} + +void ppc_fmsubsdot() { + ppc_grab_regsfpdabc(false); + + float intermediate = (float)ppc_dblresult64_a * (float)ppc_dblresult64_c; + intermediate -= (float)ppc_dblresult64_b; + ppc_dblresult64_d = static_cast(intermediate); + + ppc_store_dfpresult(false); + ppc_changecrf1(); +} + +void ppc_fnmadds() { + ppc_grab_regsfpdabc(false); + + float intermediate = (float)ppc_dblresult64_a * (float)ppc_dblresult64_c; + intermediate += (float)ppc_dblresult64_b; + intermediate = -intermediate; + ppc_dblresult64_d = static_cast(intermediate); + + ppc_store_dfpresult(false); +} + +void ppc_fnmaddsdot() { + ppc_grab_regsfpdabc(false); + + float intermediate = (float)ppc_dblresult64_a * (float)ppc_dblresult64_c; + intermediate += (float)ppc_dblresult64_b; + intermediate = -intermediate; + ppc_dblresult64_d = static_cast(intermediate); + + ppc_store_dfpresult(false); + ppc_changecrf1(); +} + +void ppc_fnmsubs() { + ppc_grab_regsfpdabc(false); + + float intermediate = (float)ppc_dblresult64_a * (float)ppc_dblresult64_c; + intermediate -= (float)ppc_dblresult64_b; + intermediate = -intermediate; + ppc_dblresult64_d = static_cast(intermediate); + + ppc_store_dfpresult(false); +} + +void ppc_fnmsubsdot() { + ppc_grab_regsfpdabc(false); + + float intermediate = (float)ppc_dblresult64_a * (float)ppc_dblresult64_c; + intermediate -= (float)ppc_dblresult64_b; + intermediate = -intermediate; + ppc_dblresult64_d = static_cast(intermediate); + + ppc_store_dfpresult(false); + ppc_changecrf1(); +} + +void ppc_fabs() { + ppc_grab_regsfpdb(false); + + ppc_dblresult64_d = abs(ppc_dblresult64_b); + + ppc_store_dfpresult(false); +} + +void ppc_fabsdot() { + ppc_grab_regsfpdb(false); + + ppc_dblresult64_d = abs(ppc_dblresult64_b); + + ppc_store_dfpresult(false); + ppc_changecrf1(); +} + +void ppc_fnabs() { + ppc_grab_regsfpdb(false); + + ppc_dblresult64_d = abs(ppc_dblresult64_b); + ppc_dblresult64_d = -ppc_dblresult64_d; + + ppc_store_dfpresult(false); +} + +void ppc_fnabsdot() { + ppc_grab_regsfpdb(false); + + ppc_dblresult64_d = abs(ppc_dblresult64_b); + ppc_dblresult64_d = -ppc_dblresult64_d; + + ppc_store_dfpresult(false); + ppc_changecrf1(); +} + +void ppc_fneg() { + ppc_grab_regsfpdb(false); + + ppc_dblresult64_d = -ppc_dblresult64_d; + + ppc_store_dfpresult(false); +} + +void ppc_fnegdot() { + ppc_grab_regsfpdb(false); + + ppc_dblresult64_d = -ppc_dblresult64_d; + + ppc_store_dfpresult(false); + ppc_changecrf1(); +} + +void ppc_fsel() { + ppc_grab_regsfpdabc(false); + + if (ppc_dblresult64_a >= 0.0) { + ppc_dblresult64_d = ppc_dblresult64_c; + } + else { + ppc_dblresult64_d = ppc_dblresult64_b; + } + + ppc_store_dfpresult(false); +} + +void ppc_fseldot() { + ppc_grab_regsfpdabc(false); + + if (ppc_dblresult64_a >= 0.0) { + ppc_dblresult64_d = ppc_dblresult64_c; + } + else { + ppc_dblresult64_d = ppc_dblresult64_b; + } + + ppc_store_dfpresult(false); + ppc_changecrf1(); +} + +void ppc_fsqrt() { + ppc_grab_regsfpdb(false); + ppc_dblresult64_d = std::sqrt(ppc_dblresult64_b); + ppc_store_dfpresult(false); +} + +void ppc_fsqrtdot() { + ppc_grab_regsfpdb(false); + ppc_dblresult64_d = std::sqrt(ppc_dblresult64_b); + ppc_store_dfpresult(false); + ppc_changecrf1(); +} + +void ppc_fsqrts() { + ppc_grab_regsfpdb(true); uint32_t test = (uint32_t)ppc_result64_b; test += 127 << 23; test >>= 1; - uint64_t *pre_final = (uint64_t *)&test; + uint64_t* pre_final = (uint64_t*)&test; ppc_result64_d = *pre_final; - ppc_store_dfpresult(); + ppc_store_dfpresult(true); } -void ppc_fsqrtsdot(){ - ppc_grab_regsfpdb(); +void ppc_fsqrtsdot() { + ppc_grab_regsfpdb(true); uint32_t test = (uint32_t)ppc_result64_b; test += 127 << 23; test >>= 1; - uint64_t *pre_final = (uint64_t *)&test; + uint64_t* pre_final = (uint64_t*)&test; ppc_result64_d = *pre_final; - ppc_store_dfpresult(); + ppc_store_dfpresult(true); ppc_changecrf1(); } -void ppc_frsqrte(){ - ppc_grab_regsfpdb(); +void ppc_frsqrte() { + ppc_grab_regsfpdb(false); double testd2 = (double)ppc_result64_b; for (int i = 0; i < 10; i++){ testd2 = testd2 * (1.5 - (testd2 * .5) * testd2 * testd2); } - uint64_t *pre_final = (uint64_t *)&testd2; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); + ppc_dblresult64_d = testd2; + + ppc_store_dfpresult(false); } -void ppc_frsqrtedot(){ - ppc_grab_regsfpdb(); +void ppc_frsqrtedot() { + ppc_grab_regsfpdb(false); double testd2 = (double)ppc_result64_b; - for (int i = 0; i < 10; i++){ + for (int i = 0; i < 10; i++) { testd2 = testd2 * (1.5 - (testd2 * .5) * testd2 * testd2); } - uint64_t *pre_final = (uint64_t *)&testd2; - ppc_result64_d = *pre_final; - ppc_store_dfpresult(); + ppc_dblresult64_d = testd2; + + ppc_store_dfpresult(false); ppc_changecrf1(); } -void ppc_frsp(){ - ppc_grab_regsfpdb(); +void ppc_frsp() { + ppc_grab_regsfpdb(false); double testd2 = (double)ppc_result64_b; float testf2 = (float) testd2; - ppc_result64_d = (uint64_t) testf2; - ppc_store_dfpresult(); + ppc_result64_d = (double) testf2; + ppc_store_dfpresult(false); } -void ppc_frspdot(){ - ppc_grab_regsfpdb(); +void ppc_frspdot() { + ppc_grab_regsfpdb(false); double testd2 = (double)ppc_result64_b; - float testf2 = (float) testd2; - ppc_result64_d = (uint64_t) testf2; - ppc_store_dfpresult(); + float testf2 = (float)testd2; + ppc_result64_d = (double)testf2; + ppc_store_dfpresult(false); ppc_changecrf1(); } -void ppc_fres(){ - ppc_grab_regsfpdb(); - float testf2 = (float)ppc_result64_b; - testf2 = 1/testf2; - ppc_result64_d = (uint64_t) testf2; - ppc_store_dfpresult(); +void ppc_fres() { + ppc_grab_regsfpdb(false); + float testf2 = (float)ppc_dblresult64_b; + testf2 = 1 / testf2; + ppc_dblresult64_d = (double)testf2; + ppc_store_dfpresult(false); } -void ppc_fresdot(){ - ppc_grab_regsfpdb(); - float testf2 = (float)ppc_result64_b; - testf2 = 1/testf2; - ppc_result64_d = (uint64_t) testf2; - ppc_store_dfpresult(); +void ppc_fresdot() { + ppc_grab_regsfpdb(false); + float testf2 = (float)ppc_dblresult64_b; + testf2 = 1 / testf2; + ppc_dblresult64_d = (double)testf2; + ppc_store_dfpresult(false); ppc_changecrf1(); } -void ppc_fctiw(){ +void ppc_fctiw() { //PLACEHOLDER! - ppc_grab_regsfpdiab(); + /*ppc_grab_regsfpdiab(); double testd1 = (double)ppc_result64_b; ppc_result_d = (uint32_t)(testd1); ppc_store_result_regd(); - ppc_changecrf1(); + ppc_changecrf1(); */ } -void ppc_fctiwdot(){ +void ppc_fctiwdot() { //PLACEHOLDER! - ppc_grab_regsfpdiab(); + /*ppc_grab_regsfpdiab(); double testd1 = (double)ppc_result64_b; ppc_result_d = (uint32_t)(testd1); - ppc_store_result_regd(); + ppc_store_result_regd(); */ } -void ppc_fctiwz(){ +void ppc_fctiwz() { //PLACEHOLDER! - ppc_grab_regsfpdiab(); + /*ppc_grab_regsfpdiab(); double testd1 = (double)ppc_result64_a; ppc_result_d = (uint32_t)(testd1); ppc_store_result_regd(); - ppc_changecrf1(); + ppc_changecrf1(); */ } -void ppc_fctiwzdot(){ +void ppc_fctiwzdot() { //PLACEHOLDER! + /* ppc_grab_regsfpdiab(); double testd1 = (double)ppc_result64_a; ppc_result_d = (uint32_t)(testd1); - ppc_store_result_regd(); + ppc_store_result_regd();*/ } //Floating Point Store and Load -void ppc_lfs(){ - ppc_grab_regsfpdia(); - grab_d = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); - ppc_effective_address = (reg_a == 0)?grab_d:ppc_result_a + grab_d; +void ppc_lfs() { + ppc_grab_regsfpdia(true); + ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); + ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0; address_quickgrab_translate(ppc_effective_address, 4); ppc_result64_d = (uint64_t)return_value; - ppc_store_dfpresult(); + ppc_store_dfpresult(true); } -void ppc_lfsu(){ - ppc_grab_regsfpdia(); - grab_d = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); - ppc_effective_address = (reg_a == 0)?grab_d:ppc_result_a + grab_d; +void ppc_lfsu() { + ppc_grab_regsfpdia(true); + ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); + ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0; address_quickgrab_translate(ppc_effective_address, 4); ppc_result64_d = (uint64_t)return_value; ppc_result_a = ppc_effective_address; - ppc_store_dfpresult(); + ppc_store_dfpresult(true); ppc_store_result_rega(); } -void ppc_lfsx(){ - ppc_grab_regsfpdiab(); - ppc_effective_address = (reg_a == 0)?ppc_result_b:ppc_result_a + ppc_result_b; +void ppc_lfsx() { + ppc_grab_regsfpdiab(true); + ppc_effective_address = (reg_a == 0) ? ppc_result_b : ppc_result_a + ppc_result_b; address_quickgrab_translate(ppc_effective_address, 4); ppc_result64_d = (uint64_t)return_value; - ppc_store_dfpresult(); + ppc_store_dfpresult(true); } -void ppc_lfsux(){ - ppc_grab_regsfpdiab(); - ppc_effective_address = (reg_a == 0)?ppc_result_b:ppc_result_a + ppc_result_b; +void ppc_lfsux() { + ppc_grab_regsfpdiab(true); + ppc_effective_address = (reg_a == 0) ? ppc_result_b : ppc_result_a + ppc_result_b; address_quickgrab_translate(ppc_effective_address, 4); ppc_result64_d = (uint64_t)return_value; ppc_result_a = ppc_effective_address; - ppc_store_dfpresult(); + ppc_store_dfpresult(true); ppc_store_result_rega(); } -void ppc_lfd(){ - ppc_grab_regsfpdia(); - grab_d = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); - ppc_effective_address = (reg_a == 0)?grab_d:ppc_result_a + grab_d; +void ppc_lfd() { + ppc_grab_regsfpdia(true); + ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); + ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0; address_quickgrab_translate(ppc_effective_address, 4); uint64_t combine_result1 = (uint64_t)(return_value); address_quickgrab_translate((ppc_effective_address + 4), 4); uint64_t combine_result2 = (uint64_t)(return_value); ppc_result64_d = (combine_result1 << 32) | combine_result2; - ppc_store_dfpresult(); + ppc_store_dfpresult(true); } -void ppc_lfdu(){ - ppc_grab_regsfpdia(); - grab_d = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); - ppc_effective_address = (reg_a == 0)?grab_d:ppc_result_a + grab_d; +void ppc_lfdu() { + ppc_grab_regsfpdia(true); + ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); + ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0; address_quickgrab_translate(ppc_effective_address, 4); uint64_t combine_result1 = (uint64_t)(return_value); address_quickgrab_translate((ppc_effective_address + 4), 4); uint64_t combine_result2 = (uint64_t)(return_value); ppc_result64_d = (combine_result1 << 32) | combine_result2; - ppc_store_dfpresult(); + ppc_store_dfpresult(true); ppc_result_a = ppc_effective_address; ppc_store_result_rega(); } - -void ppc_stfs(){ - ppc_grab_regsfpsia(); - grab_d = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); - ppc_effective_address = (reg_a == 0)?grab_d:ppc_result_a + grab_d; - address_quickinsert_translate(ppc_state.ppc_fpr[reg_s], ppc_effective_address, 4); +void ppc_stfs() { + ppc_grab_regsfpsia(true); + ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); + ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0; + address_quickinsert_translate(uint32_t(ppc_state.ppc_fpr[reg_s].int64_r), ppc_effective_address, 4); } -void ppc_stfsu(){ - ppc_grab_regsfpsia(); - grab_d = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); - ppc_effective_address = (reg_a == 0)?grab_d:ppc_result_a + grab_d; - uint32_t split_result1 = (uint32_t)((float)(ppc_state.ppc_fpr[reg_s])); - address_quickinsert_translate(split_result1, ppc_effective_address, 4); +void ppc_stfsu() { + ppc_grab_regsfpsia(true); + ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); + ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0; + address_quickinsert_translate(uint32_t(ppc_state.ppc_fpr[reg_s].int64_r), ppc_effective_address, 4); ppc_result_a = ppc_effective_address; ppc_store_result_rega(); } -void ppc_stfsux(){ - ppc_grab_regsfpsiab(); - ppc_effective_address = (reg_a == 0)?ppc_result_b:ppc_result_a + ppc_result_b; - uint32_t split_result1 = (uint32_t)((float)(ppc_state.ppc_fpr[reg_s])); - address_quickinsert_translate(split_result1, ppc_effective_address, 4); +void ppc_stfsux() { + ppc_grab_regsfpsiab(true); + ppc_effective_address = (reg_a == 0) ? ppc_result_b : ppc_result_a + ppc_result_b; + address_quickinsert_translate(uint32_t(ppc_state.ppc_fpr[reg_s].int64_r), ppc_effective_address, 4); ppc_result_a = ppc_effective_address; ppc_store_result_rega(); } -void ppc_stfd(){ - ppc_grab_regsfpsia(); - grab_d = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); - ppc_effective_address = (reg_a == 0)?grab_d:ppc_result_a + grab_d; - uint32_t split_result1 = (uint32_t)(ppc_state.ppc_fpr[reg_s] >> 32); +void ppc_stfd() { + ppc_grab_regsfpsia(true); + ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); + ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0; + uint32_t split_result1 = (uint32_t)(ppc_state.ppc_fpr[reg_s].int64_r >> 32); address_quickinsert_translate(split_result1, ppc_effective_address, 4); - uint32_t split_result2 = (uint32_t)(ppc_state.ppc_fpr[reg_s]); + uint32_t split_result2 = (uint32_t)(ppc_state.ppc_fpr[reg_s].int64_r); address_quickinsert_translate(split_result2, ppc_effective_address, 4); } -void ppc_stfdu(){ - ppc_grab_regsfpsia(); - grab_d = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); - ppc_effective_address = (reg_a == 0)?grab_d:ppc_result_a + grab_d; - uint32_t split_result1 = (uint32_t)(ppc_state.ppc_fpr[reg_s] >> 32); +void ppc_stfdu() { + ppc_grab_regsfpsia(true); + ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); + ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0; + uint32_t split_result1 = (uint32_t)(ppc_state.ppc_fpr[reg_s].int64_r >> 32); address_quickinsert_translate(split_result1, ppc_effective_address, 4); - uint32_t split_result2 = (uint32_t)(ppc_state.ppc_fpr[reg_s]); + uint32_t split_result2 = (uint32_t)(ppc_state.ppc_fpr[reg_s].int64_r); address_quickinsert_translate(split_result2, ppc_effective_address, 4); ppc_result_a = ppc_effective_address; ppc_store_result_rega(); } -void ppc_stfdx(){ - ppc_grab_regsfpsiab(); - ppc_effective_address = (reg_a == 0)?ppc_result_b:ppc_result_a + ppc_result_b; - uint32_t split_result1 = (uint32_t)(ppc_state.ppc_fpr[reg_s] >> 32); +void ppc_stfdx() { + ppc_grab_regsfpsiab(true); + ppc_effective_address = (reg_a == 0) ? ppc_result_b : ppc_result_a + ppc_result_b; + uint32_t split_result1 = (uint32_t)(ppc_state.ppc_fpr[reg_s].int64_r >> 32); address_quickinsert_translate(split_result1, ppc_effective_address, 4); - uint32_t split_result2 = (uint32_t)(ppc_state.ppc_fpr[reg_s]); + uint32_t split_result2 = (uint32_t)(ppc_state.ppc_fpr[reg_s].int64_r); address_quickinsert_translate(split_result2, ppc_effective_address, 4); } -void ppc_stfdux(){ - ppc_grab_regsfpsiab(); - ppc_effective_address = (reg_a == 0)?ppc_result_b:ppc_result_a + ppc_result_b; - uint32_t split_result1 = (uint32_t)(ppc_state.ppc_fpr[reg_s] >> 32); +void ppc_stfdux() { + ppc_grab_regsfpsiab(true); + ppc_effective_address = (reg_a == 0) ? ppc_result_b : ppc_result_a + ppc_result_b; + uint32_t split_result1 = (uint32_t)(ppc_state.ppc_fpr[reg_s].int64_r >> 32); address_quickinsert_translate(split_result1, ppc_effective_address, 4); - uint32_t split_result2 = (uint32_t)(ppc_state.ppc_fpr[reg_s]); + uint32_t split_result2 = (uint32_t)(ppc_state.ppc_fpr[reg_s].int64_r); address_quickinsert_translate(split_result2, ppc_effective_address, 4); ppc_result_a = ppc_effective_address; ppc_store_result_rega(); } -void ppc_stfiwx(){ - ppc_grab_regsfpsiab(); - ppc_effective_address = (reg_a == 0)?ppc_result_b:ppc_result_a + ppc_result_b; - uint32_t split_result1 = (uint32_t)(ppc_state.ppc_fpr[reg_s] & 0xFFFFFFFF); +void ppc_stfiwx() { + ppc_grab_regsfpsiab(true); + ppc_effective_address = (reg_a == 0) ? ppc_result_b : ppc_result_a + ppc_result_b; + uint32_t split_result1 = (uint32_t)(ppc_state.ppc_fpr[reg_s].int64_r); address_quickinsert_translate(split_result1, ppc_effective_address, 4); } + //Floating Point Register Transfer -void ppc_fmr(){ - ppc_grab_regsfpdb(); +void ppc_fmr() { + ppc_grab_regsfpdb(true); ppc_state.ppc_fpr[reg_d] = ppc_state.ppc_fpr[reg_b]; - ppc_store_dfpresult(); + ppc_store_dfpresult(true); } -void ppc_mffs(){ + +void ppc_mffs() { ppc_grab_regsda(); - uint64_t fpstore1 = ppc_state.ppc_fpr[reg_d] & 0xFFFFFFFF00000000; + uint64_t fpstore1 = ppc_state.ppc_fpr[reg_d].int64_r & 0xFFFFFFFF00000000; uint64_t fpstore2 = ppc_state.ppc_fpscr & 0x00000000FFFFFFFF; fpstore1 |= fpstore2; - ppc_state.ppc_fpr[reg_d] = fpstore1; - ppc_store_sfpresult(); + fp_save_uint64(fpstore1); } -void ppc_mffsdot(){ +void ppc_mffsdot() { ppc_grab_regsda(); - uint64_t fpstore1 = ppc_state.ppc_fpr[reg_d] & 0xFFFFFFFF00000000; + uint64_t fpstore1 = ppc_state.ppc_fpr[reg_d].int64_r & 0xFFFFFFFF00000000; uint64_t fpstore2 = ppc_state.ppc_fpscr & 0x00000000FFFFFFFF; fpstore1 |= fpstore2; - ppc_state.ppc_fpr[reg_d] = fpstore1; - ppc_store_sfpresult(); + fp_save_uint64(fpstore1); ppc_fp_changecrf1(); } -void ppc_mtfsf(){ +void ppc_mtfsf() { reg_b = (ppc_cur_instruction >> 11) & 31; uint32_t fm_mask = (ppc_cur_instruction >> 17) & 255; - crm = ((fm_mask & 1) == 1)? 0xF0000000 : 0x00000000; - crm += (((fm_mask >> 1) & 1) == 1)? 0x0F000000 : 0x00000000; - crm += (((fm_mask >> 2) & 1) == 1)? 0x00F00000 : 0x00000000; - crm += (((fm_mask >> 3) & 1) == 1)? 0x000F0000 : 0x00000000; - crm += (((fm_mask >> 4) & 1) == 1)? 0x0000F000 : 0x00000000; - crm += (((fm_mask >> 5) & 1) == 1)? 0x00000F00 : 0x00000000; - crm += (((fm_mask >> 6) & 1) == 1)? 0x000000F0 : 0x00000000; - crm += (((fm_mask >> 7) & 1) == 1)? 0x0000000F : 0x00000000; - uint32_t quickfprval = (uint32_t)ppc_state.ppc_fpr[reg_b]; + crm += ((fm_mask & 1) == 1) ? 0xF0000000 : 0x00000000; + crm += (((fm_mask >> 1) & 1) == 1) ? 0x0F000000 : 0x00000000; + crm += (((fm_mask >> 2) & 1) == 1) ? 0x00F00000 : 0x00000000; + crm += (((fm_mask >> 3) & 1) == 1) ? 0x000F0000 : 0x00000000; + crm += (((fm_mask >> 4) & 1) == 1) ? 0x0000F000 : 0x00000000; + crm += (((fm_mask >> 5) & 1) == 1) ? 0x00000F00 : 0x00000000; + crm += (((fm_mask >> 6) & 1) == 1) ? 0x000000F0 : 0x00000000; + crm += (((fm_mask >> 7) & 1) == 1) ? 0x0000000F : 0x00000000; + uint32_t quickfprval = (uint32_t)ppc_state.ppc_fpr[reg_b].int64_r; ppc_state.ppc_fpscr = (quickfprval & crm) | (quickfprval & ~(crm)); } -void ppc_mtfsfdot(){ +void ppc_mtfsfdot() { reg_b = (ppc_cur_instruction >> 11) & 31; uint32_t fm_mask = (ppc_cur_instruction >> 17) & 255; - crm = ((fm_mask & 1) == 1)? 0xF0000000 : 0x00000000; - crm += (((fm_mask >> 1) & 1) == 1)? 0x0F000000 : 0x00000000; - crm += (((fm_mask >> 2) & 1) == 1)? 0x00F00000 : 0x00000000; - crm += (((fm_mask >> 3) & 1) == 1)? 0x000F0000 : 0x00000000; - crm += (((fm_mask >> 4) & 1) == 1)? 0x0000F000 : 0x00000000; - crm += (((fm_mask >> 5) & 1) == 1)? 0x00000F00 : 0x00000000; - crm += (((fm_mask >> 6) & 1) == 1)? 0x000000F0 : 0x00000000; - crm += (((fm_mask >> 7) & 1) == 1)? 0x0000000F : 0x00000000; - uint32_t quickfprval = (uint32_t)ppc_state.ppc_fpr[reg_b]; + crm += ((fm_mask & 1) == 1) ? 0xF0000000 : 0x00000000; + crm += (((fm_mask >> 1) & 1) == 1) ? 0x0F000000 : 0x00000000; + crm += (((fm_mask >> 2) & 1) == 1) ? 0x00F00000 : 0x00000000; + crm += (((fm_mask >> 3) & 1) == 1) ? 0x000F0000 : 0x00000000; + crm += (((fm_mask >> 4) & 1) == 1) ? 0x0000F000 : 0x00000000; + crm += (((fm_mask >> 5) & 1) == 1) ? 0x00000F00 : 0x00000000; + crm += (((fm_mask >> 6) & 1) == 1) ? 0x000000F0 : 0x00000000; + crm += (((fm_mask >> 7) & 1) == 1) ? 0x0000000F : 0x00000000; + uint32_t quickfprval = (uint32_t)ppc_state.ppc_fpr[reg_b].int64_r; ppc_state.ppc_fpscr = (quickfprval & crm) | (quickfprval & ~(crm)); ppc_fp_changecrf1(); } @@ -1124,48 +1087,49 @@ void ppc_mtfsfidot() { ppc_fp_changecrf1(); } -void ppc_mtfsb0(){ +void ppc_mtfsb0() { crf_d = (ppc_cur_instruction >> 21) & 0x31; - if ((crf_d == 0) || (crf_d > 2)){ + if ((crf_d == 0) || (crf_d > 2)) { ppc_state.ppc_fpscr &= ~(1 << (31 - crf_d)); } } -void ppc_mtfsb0dot(){ +void ppc_mtfsb0dot() { crf_d = (ppc_cur_instruction >> 21) & 0x31; - if ((crf_d == 0) || (crf_d > 2)){ + if ((crf_d == 0) || (crf_d > 2)) { ppc_state.ppc_fpscr &= ~(1 << crf_d); } ppc_fp_changecrf1(); } -void ppc_mtfsb1(){ +void ppc_mtfsb1() { crf_d = (ppc_cur_instruction >> 21) & 0x31; - if ((crf_d == 0) || (crf_d > 2)){ + if ((crf_d == 0) || (crf_d > 2)) { ppc_state.ppc_fpscr |= (1 << crf_d); } } -void ppc_mtfsb1dot(){ +void ppc_mtfsb1dot() { crf_d = ~(ppc_cur_instruction >> 21) & 0x31; - if ((crf_d == 0) || (crf_d > 2)){ + if ((crf_d == 0) || (crf_d > 2)) { ppc_state.ppc_fpscr |= (1 << crf_d); } ppc_fp_changecrf1(); } -void ppc_mcrfs(){ +void ppc_mcrfs() { crf_d = (ppc_cur_instruction >> 23) & 7; crf_d = crf_d << 2; crf_s = (ppc_cur_instruction >> 18) & 7; crf_s = crf_d << 2; - ppc_state.ppc_cr = ~(ppc_state.ppc_cr & ((15 << (28- crf_d)))) & (ppc_state.ppc_fpscr & (15 << (28- crf_s))); + ppc_state.ppc_cr = ~(ppc_state.ppc_cr & ((15 << (28 - crf_d)))) & (ppc_state.ppc_fpscr & (15 << (28 - crf_s))); } //Floating Point Comparisons -void ppc_fcmpo(){ - ppc_grab_regsfpsab(); +void ppc_fcmpo() { + ppc_grab_regsfpsab(true); + crf_d = (ppc_cur_instruction >> 23) & 7; crf_d = crf_d << 2; @@ -1174,36 +1138,37 @@ void ppc_fcmpo(){ ppc_state.ppc_fpscr &= 0xFFFF0FFF; - if (std::isnan(db_test_a) || std::isnan(db_test_b)){ + if (std::isnan(db_test_a) || std::isnan(db_test_b)) { cmp_c |= 0x01; } - else if (db_test_a < db_test_b){ + else if (db_test_a < db_test_b) { cmp_c |= 0x08; } - else if (db_test_a > db_test_b){ + else if (db_test_a > db_test_b) { cmp_c |= 0x04; } - else{ + else { cmp_c |= 0x02; } ppc_state.ppc_fpscr |= (cmp_c << 12); - ppc_state.ppc_cr = ((ppc_state.ppc_cr & ~(0xf0000000 >> crf_d)) | ((cmp_c + xercon) >> crf_d)); + ppc_state.ppc_cr = ((ppc_state.ppc_cr & ~(0xf0000000 >> crf_d)) | ((cmp_c + xercon) >> crf_d)); - if ((db_test_a == snan) || (db_test_b == snan)){ + if ((db_test_a == snan) || (db_test_b == snan)) { ppc_state.ppc_fpscr |= 0x1000000; - if (ppc_state.ppc_fpscr & 0x80){ + if (ppc_state.ppc_fpscr & 0x80) { ppc_state.ppc_fpscr |= 0x80000; } } - else if ((db_test_a == qnan) || (db_test_b == qnan)){ + else if ((db_test_a == qnan) || (db_test_b == qnan)) { ppc_state.ppc_fpscr |= 0x80000; } } -void ppc_fcmpu(){ - ppc_grab_regsfpsab(); +void ppc_fcmpu() { + ppc_grab_regsfpsab(true); + crf_d = (ppc_cur_instruction >> 23) & 7; crf_d = crf_d << 2; @@ -1212,23 +1177,23 @@ void ppc_fcmpu(){ ppc_state.ppc_fpscr &= 0xFFFF0FFF; - if (std::isnan(db_test_a) || std::isnan(db_test_b)){ + if (std::isnan(db_test_a) || std::isnan(db_test_b)) { cmp_c |= 0x01; } - else if (db_test_a < db_test_b){ + else if (db_test_a < db_test_b) { cmp_c |= 0x08; } - else if (db_test_a > db_test_b){ + else if (db_test_a > db_test_b) { cmp_c |= 0x04; } - else{ + else { cmp_c |= 0x02; } ppc_state.ppc_fpscr |= (cmp_c << 12); - ppc_state.ppc_cr = ((ppc_state.ppc_cr & ~(0xf0000000 >> crf_d)) | ((cmp_c + xercon) >> crf_d)); + ppc_state.ppc_cr = ((ppc_state.ppc_cr & ~(0xf0000000 >> crf_d)) | ((cmp_c + xercon) >> crf_d)); - if ((db_test_a == snan) || (db_test_b == snan)){ + if ((db_test_a == snan) || (db_test_b == snan)) { ppc_state.ppc_fpscr |= 0x1000000; } -} +} \ No newline at end of file diff --git a/cpu/ppc/ppcopcodes.cpp b/cpu/ppc/ppcopcodes.cpp index 33d4b84..afbcae4 100644 --- a/cpu/ppc/ppcopcodes.cpp +++ b/cpu/ppc/ppcopcodes.cpp @@ -32,7 +32,6 @@ uint32_t not_this; uint32_t grab_sr; uint32_t grab_inb; //This is for grabbing the number of immediate bytes for loading and storing - uint32_t grab_d; //This is for grabbing d from Store and Load instructions uint32_t ppc_to; int32_t simm; int32_t adr_li; @@ -1867,58 +1866,59 @@ void ppc_dcbz(){ } } + //Integer Load and Store Functions -void ppc_stb(){ +void ppc_stb() { ppc_grab_regssa(); - grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF))); - ppc_effective_address = (reg_a == 0)?grab_d:(ppc_result_a + grab_d); + ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); + ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0; address_quickinsert_translate(ppc_result_d, ppc_effective_address, 1); } -void ppc_stbx(){ +void ppc_stbx() { ppc_grab_regssab(); - ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b); + ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b); address_quickinsert_translate(ppc_result_d, ppc_effective_address, 1); } -void ppc_stbu(){ +void ppc_stbu() { ppc_grab_regssa(); - if (reg_a != 0){ - grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF))); - ppc_effective_address = ppc_result_a + grab_d; + if (reg_a != 0) { + ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); + ppc_effective_address += ppc_result_a; address_quickinsert_translate(ppc_result_d, ppc_effective_address, 1); ppc_state.ppc_gpr[reg_a] = ppc_effective_address; } - else{ + else { ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x20000); } } -void ppc_stbux(){ +void ppc_stbux() { ppc_grab_regssab(); - if (reg_a != 0){ + if (reg_a != 0) { ppc_effective_address = ppc_result_a + ppc_result_b; address_quickinsert_translate(ppc_result_d, ppc_effective_address, 1); ppc_state.ppc_gpr[reg_a] = ppc_effective_address; } - else{ + else { ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x20000); } } -void ppc_sth(){ +void ppc_sth() { ppc_grab_regssa(); - grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF))); - ppc_effective_address = (reg_a == 0)?grab_d:(ppc_result_a + grab_d); + ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); + ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0; address_quickinsert_translate(ppc_result_d, ppc_effective_address, 2); } -void ppc_sthu(){ +void ppc_sthu() { ppc_grab_regssa(); if (reg_a != 0) { - grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF))); - ppc_effective_address = ppc_result_a + grab_d; + ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); + ppc_effective_address += ppc_result_a; address_quickinsert_translate(ppc_result_d, ppc_effective_address, 2); ppc_state.ppc_gpr[reg_a] = ppc_effective_address; } @@ -1927,7 +1927,7 @@ void ppc_sthu(){ } } -void ppc_sthux(){ +void ppc_sthux() { ppc_grab_regssab(); if (reg_a != 0) { ppc_effective_address = ppc_result_a + ppc_result_b; @@ -1939,51 +1939,51 @@ void ppc_sthux(){ } } -void ppc_sthx(){ +void ppc_sthx() { ppc_grab_regssab(); ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b); address_quickinsert_translate(ppc_result_d, ppc_effective_address, 2); } -void ppc_sthbrx(){ +void ppc_sthbrx() { ppc_grab_regssab(); - ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b); + ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b); ppc_result_d = (uint32_t)(BYTESWAP_16((uint16_t)ppc_result_d)); address_quickinsert_translate(ppc_result_d, ppc_effective_address, 2); -} -void ppc_stw(){ +} +void ppc_stw() { ppc_grab_regssa(); - grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF))); - ppc_effective_address = (reg_a == 0)?grab_d:(ppc_result_a + grab_d); + ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); + ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0; address_quickinsert_translate(ppc_result_d, ppc_effective_address, 4); } -void ppc_stwx(){ +void ppc_stwx() { ppc_grab_regssab(); - ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b); + ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b); address_quickinsert_translate(ppc_result_d, ppc_effective_address, 4); } -void ppc_stwcx(){ +void ppc_stwcx() { //PLACEHOLDER CODE FOR STWCX - We need to check for reserve memory ppc_grab_regssab(); - ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b); - if (ppc_state.ppc_reserve){ + ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b); + if (ppc_state.ppc_reserve) { address_quickinsert_translate(ppc_result_d, ppc_effective_address, 4); ppc_state.ppc_cr |= (ppc_state.ppc_spr[1] & 0x80000000) ? 0x30000000 : 0x20000000; ppc_state.ppc_reserve = false; } - else{ + else { ppc_state.ppc_cr |= (ppc_state.ppc_spr[1] & 0x80000000) ? 0x10000000 : 0; } } -void ppc_stwu(){ +void ppc_stwu() { ppc_grab_regssa(); if (reg_a != 0) { - grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF))); - ppc_effective_address = ppc_result_a + grab_d; + ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); + ppc_effective_address += ppc_result_a; address_quickinsert_translate(ppc_result_d, ppc_effective_address, 4); ppc_state.ppc_gpr[reg_a] = ppc_effective_address; } @@ -1992,7 +1992,7 @@ void ppc_stwu(){ } } -void ppc_stwux(){ +void ppc_stwux() { ppc_grab_regssab(); if (reg_a != 0) { ppc_effective_address = ppc_result_a + ppc_result_b; @@ -2004,148 +2004,181 @@ void ppc_stwux(){ } } -void ppc_stwbrx(){ +void ppc_stwbrx() { ppc_grab_regssab(); - ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b); + ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b); ppc_result_d = BYTESWAP_32(ppc_result_d); address_quickinsert_translate(ppc_result_d, ppc_effective_address, 4); } -void ppc_stmw(){ +void ppc_stmw() { ppc_grab_regssa(); - grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF))); - ppc_effective_address = (reg_a == 0)?grab_d:(ppc_result_a + grab_d); + ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); + ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0; //How many words to store in memory - using a do-while for this - do{ + do { address_quickinsert_translate(ppc_result_d, ppc_effective_address, 4); - ppc_effective_address +=4; + ppc_effective_address += 4; reg_d++; - }while (reg_d < 32); + } while (reg_d < 32); } -void ppc_lbz(){ +void ppc_lbz() { ppc_grab_regsda(); - grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF))); - ppc_effective_address = (reg_a == 0)?grab_d:(ppc_result_a + grab_d); + ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); + ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0; address_quickgrab_translate(ppc_effective_address, 1); ppc_result_d = return_value; return_value = 0; ppc_store_result_regd(); } -void ppc_lbzu(){ +void ppc_lbzu() { ppc_grab_regsda(); - grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF))); - if ((reg_a != reg_d) || reg_a != 0){ - ppc_effective_address = ppc_result_a + grab_d; + ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); + if ((reg_a != reg_d) || reg_a != 0) { + ppc_effective_address += ppc_result_a; + address_quickgrab_translate(ppc_effective_address, 1); + ppc_result_d = return_value; + return_value = 0; + ppc_result_a = ppc_effective_address; + ppc_store_result_regd(); + ppc_store_result_rega(); } - else{ + else { ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x20000); } - address_quickgrab_translate(ppc_effective_address, 1); - ppc_result_d = return_value; - return_value = 0; - ppc_result_a = ppc_effective_address; - ppc_store_result_regd(); - ppc_store_result_rega(); } -void ppc_lbzx(){ +void ppc_lbzx() { ppc_grab_regsdab(); - ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b); + ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b); address_quickgrab_translate(ppc_effective_address, 1); ppc_result_d = return_value; return_value = 0; ppc_store_result_regd(); } -void ppc_lbzux(){ +void ppc_lbzux() { ppc_grab_regsdab(); - if ((reg_a != reg_d) || reg_a != 0){ + if ((reg_a != reg_d) || reg_a != 0) { ppc_effective_address = ppc_result_a + ppc_result_b; + address_quickgrab_translate(ppc_effective_address, 1); + ppc_result_d = return_value; + return_value = 0; + ppc_result_a = ppc_effective_address; + ppc_store_result_regd(); + ppc_store_result_rega(); } - else{ + else { ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x20000); } - address_quickgrab_translate(ppc_effective_address, 1); - ppc_result_d = return_value; - return_value = 0; - ppc_result_a = ppc_effective_address; - ppc_store_result_regd(); - ppc_store_result_rega(); } -void ppc_lhz(){ +void ppc_lhz() { ppc_grab_regsda(); - grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF))); - ppc_effective_address = (reg_a == 0)?grab_d:(ppc_result_a + grab_d); + ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); + ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0; address_quickgrab_translate(ppc_effective_address, 2); ppc_result_d = return_value; return_value = 0; ppc_store_result_regd(); } -void ppc_lhzu(){ +void ppc_lhzu() { ppc_grab_regsda(); - grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF))); - ppc_effective_address = ppc_result_a + grab_d; - address_quickgrab_translate(ppc_effective_address, 2); - ppc_result_d = return_value; - return_value = 0; - ppc_result_a = ppc_effective_address; - ppc_store_result_regd(); - ppc_store_result_rega(); + if ((reg_a != reg_d) || reg_a != 0) { + ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); + ppc_effective_address += ppc_result_a; + address_quickgrab_translate(ppc_effective_address, 2); + ppc_result_d = return_value; + return_value = 0; + ppc_result_a = ppc_effective_address; + ppc_store_result_regd(); + ppc_store_result_rega(); + } + else { + ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x20000); + } } -void ppc_lhzx(){ +void ppc_lhzx() { ppc_grab_regsdab(); - ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b); + ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b); address_quickgrab_translate(ppc_effective_address, 2); ppc_result_d = return_value; return_value = 0; ppc_store_result_regd(); } -void ppc_lhzux(){ +void ppc_lhzux() { ppc_grab_regsdab(); - ppc_effective_address = ppc_result_a + ppc_result_b; - address_quickgrab_translate(ppc_effective_address, 2); - ppc_result_d = return_value; - return_value = 0; - ppc_result_a = ppc_effective_address; - ppc_store_result_regd(); - ppc_store_result_rega(); + if ((reg_a != reg_d) || reg_a != 0) { + ppc_effective_address = ppc_result_a + ppc_result_b; + address_quickgrab_translate(ppc_effective_address, 2); + ppc_result_d = return_value; + return_value = 0; + ppc_result_a = ppc_effective_address; + ppc_store_result_regd(); + ppc_store_result_rega(); + } + else { + ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x20000); + } } -void ppc_lha(){ +void ppc_lha() { ppc_grab_regsda(); - grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF))); - ppc_effective_address = (reg_a == 0)?grab_d:(uint32_t)(ppc_result_a + grab_d); + ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); + ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0; address_quickgrab_translate(ppc_effective_address, 2); uint16_t go_this = (uint16_t)return_value; - if (go_this & 0x8000){ + if (go_this & 0x8000) { ppc_result_d = 0xFFFF0000UL | (uint32_t)return_value; ppc_store_result_regd(); } - else{ + else { ppc_result_d = (uint32_t)return_value; ppc_store_result_regd(); } return_value = 0; } -void ppc_lhau(){ +void ppc_lhau() { ppc_grab_regsda(); - grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF))); - ppc_effective_address = (reg_a == 0)?grab_d:(uint32_t)(ppc_result_a + grab_d); + if ((reg_a != reg_d) || reg_a != 0) { + ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); + ppc_effective_address += ppc_result_a; + address_quickgrab_translate(ppc_effective_address, 2); + uint16_t go_this = (uint16_t)return_value; + if (go_this & 0x8000) { + ppc_result_d = 0xFFFF0000UL | (uint32_t)return_value; + ppc_store_result_regd(); + } + else { + ppc_result_d = (uint32_t)return_value; + ppc_store_result_regd(); + } + return_value = 0; + ppc_result_a = ppc_effective_address; + ppc_store_result_rega(); + } + else { + ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x20000); + } +} + +void ppc_lhaux() { + ppc_grab_regsdab(); + ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b); address_quickgrab_translate(ppc_effective_address, 2); uint16_t go_this = (uint16_t)return_value; - if (go_this & 0x8000){ + if (go_this & 0x8000) { ppc_result_d = 0xFFFF0000UL | (uint32_t)return_value; ppc_store_result_regd(); } - else{ + else { ppc_result_d = (uint32_t)return_value; ppc_store_result_regd(); } @@ -2154,100 +2187,82 @@ void ppc_lhau(){ ppc_store_result_rega(); } -void ppc_lhaux(){ +void ppc_lhax() { ppc_grab_regsdab(); - ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b); + ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b); address_quickgrab_translate(ppc_effective_address, 2); uint16_t go_this = (uint16_t)return_value; - if (go_this & 0x8000){ + if (go_this & 0x8000) { ppc_result_d = 0xFFFF0000UL | (uint32_t)return_value; ppc_store_result_regd(); } - else{ - ppc_result_d = (uint32_t)return_value; - ppc_store_result_regd(); - } - return_value = 0; - ppc_result_a = ppc_effective_address; - ppc_store_result_rega(); -} - -void ppc_lhax(){ - ppc_grab_regsdab(); - ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b); - address_quickgrab_translate(ppc_effective_address, 2); - uint16_t go_this = (uint16_t)return_value; - if (go_this & 0x8000){ - ppc_result_d = 0xFFFF0000UL | (uint32_t)return_value; - ppc_store_result_regd(); - } - else{ + else { ppc_result_d = (uint32_t)return_value; ppc_store_result_regd(); } return_value = 0; } -void ppc_lhbrx(){ +void ppc_lhbrx() { ppc_grab_regsdab(); - ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b); + ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b); address_quickgrab_translate(ppc_effective_address, 2); ppc_result_d = (uint32_t)(BYTESWAP_16((uint16_t)ppc_result_d)); return_value = 0; ppc_store_result_regd(); } -void ppc_lwz(){ +void ppc_lwz() { ppc_grab_regsda(); - grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF))); - ppc_effective_address = (reg_a == 0)?grab_d:(ppc_result_a + grab_d); + ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); + ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0; address_quickgrab_translate(ppc_effective_address, 4); ppc_result_d = return_value; return_value = 0; ppc_store_result_regd(); } -void ppc_lwbrx(){ +void ppc_lwbrx() { ppc_grab_regsdab(); - ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b); + ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b); address_quickgrab_translate(ppc_effective_address, 4); ppc_result_d = BYTESWAP_32(return_value); return_value = 0; ppc_store_result_regd(); } -void ppc_lwzu(){ +void ppc_lwzu() { ppc_grab_regsda(); - grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF))); - if ((reg_a != reg_d) || reg_a != 0){ - ppc_effective_address = ppc_result_a + grab_d; + ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); + if ((reg_a != reg_d) || reg_a != 0) { + ppc_effective_address += ppc_result_a; + address_quickgrab_translate(ppc_effective_address, 4); + ppc_result_d = return_value; + return_value = 0; + ppc_store_result_regd(); + ppc_result_a = ppc_effective_address; + ppc_store_result_rega(); } - else{ + else { ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x20000); } - address_quickgrab_translate(ppc_effective_address, 4); - ppc_result_d = return_value; - return_value = 0; - ppc_store_result_regd(); - ppc_result_a = ppc_effective_address; - ppc_store_result_rega(); } -void ppc_lwzx(){ +void ppc_lwzx() { ppc_grab_regsdab(); - ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b); + ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b); address_quickgrab_translate(ppc_effective_address, 4); ppc_result_d = return_value; return_value = 0; ppc_store_result_regd(); } -void ppc_lwzux(){ +void ppc_lwzux() { ppc_grab_regsdab(); - if ((reg_a != reg_d) || reg_a != 0){ + if ((reg_a != reg_d) || reg_a != 0) { ppc_effective_address = ppc_result_a + ppc_result_b; } - else{ + else { ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x20000); } address_quickgrab_translate(ppc_effective_address, 4); @@ -2258,10 +2273,10 @@ void ppc_lwzux(){ ppc_store_result_rega(); } -void ppc_lwarx(){ +void ppc_lwarx() { //Placeholder - Get the reservation of memory implemented! ppc_grab_regsdab(); - ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b); + ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b); ppc_state.ppc_reserve = true; address_quickgrab_translate(ppc_effective_address, 4); ppc_result_d = return_value; @@ -2269,21 +2284,21 @@ void ppc_lwarx(){ ppc_store_result_regd(); } -void ppc_lmw(){ +void ppc_lmw() { ppc_grab_regsda(); - grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF))); - ppc_effective_address = (reg_a == 0)?grab_d:(ppc_result_a + grab_d); + ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)); + ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0; //How many words to load in memory - using a do-while for this - do{ + do { address_quickgrab_translate(ppc_effective_address, 4); ppc_state.ppc_gpr[reg_d] = return_value; return_value = 0; - ppc_effective_address +=4; + ppc_effective_address += 4; reg_d++; - }while (reg_d < 32); + } while (reg_d < 32); } -void ppc_lswi(){ +void ppc_lswi() { ppc_grab_regsda(); ppc_effective_address = ppc_result_a; grab_inb = (ppc_cur_instruction >> 11) & 31; @@ -2291,8 +2306,8 @@ void ppc_lswi(){ uint32_t shift_times = 0; - while (grab_inb > 0){ - switch(shift_times){ + while (grab_inb > 0) { + switch (shift_times) { case 0: address_quickgrab_translate(ppc_effective_address, 1); ppc_state.ppc_gpr[reg_d] = (ppc_result_d & 0x00FFFFFFUL) | (return_value << 24); @@ -2320,11 +2335,11 @@ void ppc_lswi(){ default: printf("Something really horrible happened with lswi."); } - if (shift_times == 3){ + if (shift_times == 3) { shift_times = 0; reg_d = (reg_d + 1) & 0x1F; } - else{ + else { shift_times++; } return_value = 0; @@ -2333,20 +2348,20 @@ void ppc_lswi(){ } } -void ppc_lswx(){ +void ppc_lswx() { ppc_grab_regsdab(); //Invalid instruction forms - if ((ppc_result_d == 0) && (ppc_result_a == 0)){ + if ((ppc_result_d == 0) && (ppc_result_a == 0)) { ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x100000); } - if ((ppc_result_d == ppc_result_a) || (ppc_result_a == ppc_result_b)){ + if ((ppc_result_d == ppc_result_a) || (ppc_result_a == ppc_result_b)) { ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x100000); } - ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b); + ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b); grab_inb = ppc_state.ppc_spr[1] & 127; uint32_t shift_times = 0; - while (grab_inb > 0){ - switch(shift_times){ + while (grab_inb > 0) { + switch (shift_times) { case 0: address_quickgrab_translate(ppc_effective_address, 1); ppc_result_d = (ppc_result_d & 0x00FFFFFFUL) | (return_value << 24); @@ -2374,11 +2389,11 @@ void ppc_lswx(){ default: printf("Something really horrible happened with lswx."); } - if (shift_times == 3){ + if (shift_times == 3) { shift_times = 0; reg_d = (reg_d + 1) & 0x1F; } - else{ + else { shift_times++; } return_value = 0; @@ -2388,14 +2403,14 @@ void ppc_lswx(){ } -void ppc_stswi(){ +void ppc_stswi() { ppc_grab_regssa(); - ppc_effective_address = (reg_a == 0)?0:ppc_result_a; + ppc_effective_address = (reg_a == 0) ? 0 : ppc_result_a; grab_inb = (ppc_cur_instruction >> 11) & 31; grab_inb = (grab_inb & 32) == 0 ? 32 : grab_inb; uint32_t shift_times = 0; - while (grab_inb > 0){ - switch(shift_times){ + while (grab_inb > 0) { + switch (shift_times) { case 0: strwrd_replace_value = (ppc_result_d >> 24); address_quickinsert_translate(strwrd_replace_value, ppc_effective_address, 1); @@ -2415,11 +2430,11 @@ void ppc_stswi(){ default: printf("Something really horrible happened with stswi."); } - if (shift_times == 3){ + if (shift_times == 3) { shift_times = 0; reg_s = (reg_s + 1) & 0x1F; } - else{ + else { shift_times++; } return_value = 0; @@ -2428,13 +2443,13 @@ void ppc_stswi(){ } } -void ppc_stswx(){ +void ppc_stswx() { ppc_grab_regssab(); - ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b); + ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b); grab_inb = ppc_state.ppc_spr[1] & 127; uint32_t shift_times = 0; - while (grab_inb > 0){ - switch(shift_times){ + while (grab_inb > 0) { + switch (shift_times) { case 0: strwrd_replace_value = (ppc_result_d >> 24); address_quickinsert_translate(strwrd_replace_value, ppc_effective_address, 1); @@ -2454,17 +2469,17 @@ void ppc_stswx(){ default: printf("Something really horrible happened with stswx."); } - if (shift_times == 3){ + if (shift_times == 3) { shift_times = 0; reg_s = (reg_s + 1) & 0x1F; - } - else{ + } + else { shift_times++; } return_value = 0; ppc_effective_address++; grab_inb--; - } +} } //TLB Instructions diff --git a/main.cpp b/main.cpp index f5f0bec..57a9149 100644 --- a/main.cpp +++ b/main.cpp @@ -100,7 +100,8 @@ uint8_t write_char; //Initialize the PPC's registers. void reg_init(){ for (uint32_t i = 0; i < 32; i++){ - ppc_state.ppc_fpr[i] = 0; + ppc_state.ppc_fpr[i].dbl64_r = 0.0; + ppc_state.ppc_fpr[i].int64_r = 0; } ppc_state.ppc_pc = 0; for (uint32_t i = 0; i < 32; i++){