2020-01-05 17:38:32 +00:00
|
|
|
//DingusPPC
|
|
|
|
//Written by divingkatae and maximum
|
|
|
|
//(c)2018-20 (theweirdo) spatium
|
2019-07-02 02:15:33 +00:00
|
|
|
//Please ask for permission
|
|
|
|
//if you want to distribute this.
|
2020-01-05 17:38:32 +00:00
|
|
|
//(divingkatae#1017 or powermax#2286 on Discord)
|
2019-07-02 02:15:33 +00:00
|
|
|
|
|
|
|
// The opcodes for the processor - ppcopcodes.cpp
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <map>
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <cinttypes>
|
|
|
|
#include <array>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdexcept>
|
2019-12-27 19:10:36 +00:00
|
|
|
#include "ppcemu.h"
|
2019-12-27 19:00:53 +00:00
|
|
|
#include "ppcmmu.h"
|
2019-07-12 05:27:14 +00:00
|
|
|
#include <cfenv>
|
2019-07-02 02:15:33 +00:00
|
|
|
#include <cmath>
|
|
|
|
#include <limits>
|
|
|
|
|
|
|
|
//Used for FP calcs
|
2020-01-22 02:25:50 +00:00
|
|
|
uint64_t ppc_result64_a;
|
|
|
|
uint64_t ppc_result64_b;
|
|
|
|
uint64_t ppc_result64_c;
|
|
|
|
uint64_t ppc_result64_d;
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
double ppc_dblresult64_a;
|
|
|
|
double ppc_dblresult64_b;
|
|
|
|
double ppc_dblresult64_c;
|
|
|
|
double ppc_dblresult64_d;
|
|
|
|
|
|
|
|
double snan = std::numeric_limits<double>::signaling_NaN();
|
|
|
|
double qnan = std::numeric_limits<double>::quiet_NaN();
|
2019-07-02 02:15:33 +00:00
|
|
|
|
|
|
|
//Storage and register retrieval functions for the floating point functions.
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
double fp_return_double(uint32_t reg) {
|
|
|
|
return ppc_state.ppc_fpr[reg].dbl64_r;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t fp_return_uint64(uint32_t reg) {
|
|
|
|
return ppc_state.ppc_fpr[reg].int64_r;
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_store_sfpresult(bool int_rep) {
|
|
|
|
if (int_rep) {
|
|
|
|
ppc_state.ppc_fpr[reg_d].int64_r = ppc_result64_d;
|
2020-01-29 01:45:36 +00:00
|
|
|
ppc_state.ppc_fpr[reg_d].dbl64_r = *(double*)&ppc_result64_d;
|
2020-01-22 02:25:50 +00:00
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_store_dfpresult(bool int_rep) {
|
|
|
|
if (int_rep) {
|
|
|
|
ppc_state.ppc_fpr[reg_d].int64_r = ppc_result64_d;
|
2020-01-29 01:45:36 +00:00
|
|
|
ppc_state.ppc_fpr[reg_d].dbl64_r = *(double*)&ppc_result64_d;
|
2020-01-22 02:25:50 +00:00
|
|
|
}
|
|
|
|
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) {
|
2019-07-02 02:15:33 +00:00
|
|
|
reg_d = (ppc_cur_instruction >> 21) & 31;
|
|
|
|
reg_b = (ppc_cur_instruction >> 11) & 31;
|
2020-01-22 02:25:50 +00:00
|
|
|
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;
|
|
|
|
}
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_grab_regsfpdiab(bool int_rep) {
|
2019-07-02 02:15:33 +00:00
|
|
|
reg_d = (ppc_cur_instruction >> 21) & 31;
|
|
|
|
reg_a = (ppc_cur_instruction >> 16) & 31;
|
|
|
|
reg_b = (ppc_cur_instruction >> 11) & 31;
|
2020-01-22 02:25:50 +00:00
|
|
|
if (int_rep == true) {
|
|
|
|
|
|
|
|
}
|
2019-07-02 02:15:33 +00:00
|
|
|
ppc_result_a = ppc_state.ppc_gpr[reg_a];
|
|
|
|
ppc_result_b = ppc_state.ppc_gpr[reg_b];
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_grab_regsfpdia(bool int_rep) {
|
2019-07-02 02:15:33 +00:00
|
|
|
reg_d = (ppc_cur_instruction >> 21) & 31;
|
|
|
|
reg_a = (ppc_cur_instruction >> 16) & 31;
|
|
|
|
ppc_result_a = ppc_state.ppc_gpr[reg_a];
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_grab_regsfpsia(bool int_rep) {
|
2019-07-02 02:15:33 +00:00
|
|
|
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];
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_grab_regsfpsiab(bool int_rep) {
|
2019-07-02 02:15:33 +00:00
|
|
|
reg_s = (ppc_cur_instruction >> 21) & 31;
|
|
|
|
reg_a = (ppc_cur_instruction >> 16) & 31;
|
|
|
|
reg_b = (ppc_cur_instruction >> 11) & 31;
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_result64_d = ppc_state.ppc_fpr[reg_s].int64_r;
|
2019-07-02 02:15:33 +00:00
|
|
|
ppc_result_a = ppc_state.ppc_gpr[reg_a];
|
|
|
|
ppc_result_b = ppc_state.ppc_gpr[reg_b];
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_grab_regsfpsab(bool int_rep) {
|
2019-07-02 02:15:33 +00:00
|
|
|
reg_s = (ppc_cur_instruction >> 21) & 31;
|
|
|
|
reg_a = (ppc_cur_instruction >> 16) & 31;
|
|
|
|
reg_b = (ppc_cur_instruction >> 11) & 31;
|
2020-01-22 02:25:50 +00:00
|
|
|
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);
|
|
|
|
}
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_grab_regsfpdab(bool int_rep) {
|
2019-07-02 02:15:33 +00:00
|
|
|
reg_d = (ppc_cur_instruction >> 21) & 31;
|
|
|
|
reg_a = (ppc_cur_instruction >> 16) & 31;
|
|
|
|
reg_b = (ppc_cur_instruction >> 11) & 31;
|
2020-01-22 02:25:50 +00:00
|
|
|
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);
|
|
|
|
}
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_grab_regsfpdac(bool int_rep) {
|
2019-07-02 02:15:33 +00:00
|
|
|
reg_d = (ppc_cur_instruction >> 21) & 31;
|
|
|
|
reg_a = (ppc_cur_instruction >> 16) & 31;
|
|
|
|
reg_c = (ppc_cur_instruction >> 6) & 31;
|
2020-01-22 02:25:50 +00:00
|
|
|
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);
|
|
|
|
}
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_grab_regsfpdabc(bool int_rep) {
|
2019-07-02 02:15:33 +00:00
|
|
|
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;
|
2020-01-22 02:25:50 +00:00
|
|
|
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;
|
|
|
|
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-12 01:43:47 +00:00
|
|
|
void ppc_fp_changecrf1() {
|
|
|
|
ppc_state.ppc_fpscr |= 0xf0000000;
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_divbyzero(uint64_t input_a, uint64_t input_b, bool is_single) {
|
|
|
|
if (input_b == 0) {
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_state.ppc_fpscr |= 0x84000000;
|
2020-01-22 02:25:50 +00:00
|
|
|
if (input_a == 0) {
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_state.ppc_fpscr |= 0x200000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
|
|
|
|
bool ppc_confirm_inf_nan(uint64_t input_a, uint64_t input_b, bool is_single, uint32_t op) {
|
|
|
|
if (is_single) {
|
2019-07-12 05:27:14 +00:00
|
|
|
uint32_t exp_a = (input_a >> 23) & 0xff;
|
|
|
|
uint32_t exp_b = (input_b >> 23) & 0xff;
|
|
|
|
|
|
|
|
ppc_state.ppc_fpscr &= 0x7fbfffff;
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
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;
|
2020-01-26 02:30:55 +00:00
|
|
|
default:
|
|
|
|
return false;
|
2019-07-12 05:27:14 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-22 02:25:50 +00:00
|
|
|
else {
|
2019-07-12 05:27:14 +00:00
|
|
|
uint32_t exp_a = (input_a >> 52) & 0x7ff;
|
|
|
|
uint32_t exp_b = (input_b >> 52) & 0x7ff;
|
|
|
|
|
|
|
|
ppc_state.ppc_fpscr &= 0x7fbfffff;
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
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;
|
2020-01-26 02:30:55 +00:00
|
|
|
default:
|
|
|
|
return false;
|
2019-07-12 05:27:14 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-26 02:30:55 +00:00
|
|
|
|
2020-01-22 11:42:22 +00:00
|
|
|
return false;
|
2019-07-12 05:27:14 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fpresult_update(uint64_t set_result, bool confirm_arc) {
|
2019-07-12 05:27:14 +00:00
|
|
|
|
|
|
|
bool confirm_ov = (bool)std::fetestexcept(FE_OVERFLOW);
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
if (confirm_ov) {
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_state.ppc_fpscr |= 0x80001000;
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
if (confirm_arc) {
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_state.ppc_fpscr |= 0x80010000;
|
|
|
|
ppc_state.ppc_fpscr &= 0xFFFF0FFF;
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
if (set_result < 0) {
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_state.ppc_fpscr |= 0x8000;
|
|
|
|
}
|
2020-01-22 02:25:50 +00:00
|
|
|
else if (set_result > 0) {
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_state.ppc_fpscr |= 0x4000;
|
|
|
|
}
|
2020-01-22 02:25:50 +00:00
|
|
|
else if (set_result == 0) {
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_state.ppc_fpscr |= 0x2000;
|
|
|
|
}
|
2020-01-22 02:25:50 +00:00
|
|
|
else {
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_state.ppc_fpscr |= 0x1000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_frsqrte_result() {
|
|
|
|
|
|
|
|
if (ppc_result64_d) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ppc_changecrf1() {
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_state.ppc_cr &= 0xF0FFFFFF;
|
|
|
|
ppc_state.ppc_cr |= (ppc_state.ppc_fpscr & 0xF0000000) >> 4;
|
|
|
|
}
|
|
|
|
|
2019-07-02 02:15:33 +00:00
|
|
|
//Floating Point Arithmetic
|
2020-01-12 04:17:29 +00:00
|
|
|
void ppc_fadd() {
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_grab_regsfpdab(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-12 04:17:29 +00:00
|
|
|
if (!ppc_confirm_inf_nan(ppc_result64_a, ppc_result64_b, false, 58)) {
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_dblresult64_d = ppc_dblresult64_a + ppc_dblresult64_b;
|
|
|
|
ppc_store_dfpresult(false);
|
2020-01-12 04:17:29 +00:00
|
|
|
}
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fadddot() {
|
|
|
|
ppc_grab_regsfpdab(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
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);
|
|
|
|
}
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_changecrf1();
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fsub() {
|
|
|
|
ppc_grab_regsfpdab(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
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);
|
|
|
|
}
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fsubdot() {
|
|
|
|
ppc_grab_regsfpdab(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
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);
|
|
|
|
}
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_changecrf1();
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fdiv() {
|
|
|
|
ppc_grab_regsfpdab(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
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);
|
|
|
|
}
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fdivdot() {
|
|
|
|
ppc_grab_regsfpdab(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
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);
|
|
|
|
}
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_changecrf1();
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fmult() {
|
|
|
|
ppc_grab_regsfpdac(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
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);
|
|
|
|
}
|
2019-07-12 05:27:14 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fmultdot() {
|
|
|
|
ppc_grab_regsfpdac(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
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);
|
|
|
|
}
|
2019-07-12 05:27:14 +00:00
|
|
|
|
|
|
|
ppc_changecrf1();
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fmadd() {
|
|
|
|
ppc_grab_regsfpdabc(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_dblresult64_d = (ppc_dblresult64_a * ppc_dblresult64_c);
|
|
|
|
ppc_dblresult64_d += ppc_dblresult64_b;
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fmadddot() {
|
|
|
|
ppc_grab_regsfpdabc(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_dblresult64_d = (ppc_dblresult64_a * ppc_dblresult64_c);
|
|
|
|
ppc_dblresult64_d += ppc_dblresult64_b;
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_changecrf1();
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fmsub() {
|
|
|
|
ppc_grab_regsfpdabc(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_dblresult64_d = (ppc_dblresult64_a * ppc_dblresult64_c);
|
|
|
|
ppc_dblresult64_d -= ppc_dblresult64_b;
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fmsubdot() {
|
|
|
|
ppc_grab_regsfpdabc(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_dblresult64_d = (ppc_dblresult64_a * ppc_dblresult64_c);
|
|
|
|
ppc_dblresult64_d -= ppc_dblresult64_b;
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_changecrf1();
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fnmadd() {
|
|
|
|
ppc_grab_regsfpdabc(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_dblresult64_d = ppc_dblresult64_a * ppc_result64_c;
|
|
|
|
ppc_dblresult64_d += -ppc_dblresult64_b;
|
|
|
|
ppc_store_dfpresult(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fnmadddot() {
|
|
|
|
ppc_grab_regsfpdabc(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_dblresult64_d = ppc_dblresult64_a * ppc_result64_c;
|
|
|
|
ppc_dblresult64_d += ppc_dblresult64_b;
|
|
|
|
ppc_dblresult64_d = -ppc_dblresult64_d;
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_changecrf1();
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fnmsub() {
|
|
|
|
ppc_grab_regsfpdabc(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_dblresult64_d = ppc_dblresult64_a * ppc_result64_c;
|
|
|
|
ppc_dblresult64_d -= ppc_dblresult64_b;
|
|
|
|
ppc_dblresult64_d = -ppc_dblresult64_d;
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fnmsubdot() {
|
|
|
|
ppc_grab_regsfpdabc(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_dblresult64_d = ppc_dblresult64_a * ppc_result64_c;
|
|
|
|
ppc_dblresult64_d -= ppc_dblresult64_b;
|
|
|
|
ppc_dblresult64_d = -ppc_dblresult64_d;
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_changecrf1();
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fadds() {
|
|
|
|
ppc_grab_regsfpdab(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
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<double>(intermediate);
|
|
|
|
ppc_store_dfpresult(false);
|
|
|
|
}
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_faddsdot() {
|
|
|
|
ppc_grab_regsfpdab(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
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<double>(intermediate);
|
|
|
|
ppc_store_dfpresult(false);
|
|
|
|
}
|
2019-07-12 05:27:14 +00:00
|
|
|
|
|
|
|
ppc_changecrf1();
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fsubs() {
|
|
|
|
ppc_grab_regsfpdab(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
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<double>(intermediate);
|
|
|
|
ppc_store_dfpresult(false);
|
|
|
|
}
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fsubsdot() {
|
|
|
|
ppc_grab_regsfpdab(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
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<double>(intermediate);
|
|
|
|
ppc_store_dfpresult(false);
|
|
|
|
}
|
2019-07-12 05:27:14 +00:00
|
|
|
|
|
|
|
ppc_changecrf1();
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fmults() {
|
|
|
|
ppc_grab_regsfpdac(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
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<double>(intermediate);
|
|
|
|
ppc_store_dfpresult(false);
|
|
|
|
}
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fmultsdot() {
|
|
|
|
ppc_grab_regsfpdac(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
if (!ppc_confirm_inf_nan(ppc_result64_a, ppc_result64_b, true, 50)) {
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
float intermediate = (float)ppc_dblresult64_a * (float)ppc_dblresult64_b;
|
|
|
|
ppc_dblresult64_d = static_cast<double>(intermediate);
|
|
|
|
ppc_store_dfpresult(false);
|
|
|
|
}
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_changecrf1();
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fdivs() {
|
|
|
|
ppc_grab_regsfpdab(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
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<double>(intermediate);
|
|
|
|
ppc_store_dfpresult(false);
|
|
|
|
}
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fdivsdot() {
|
|
|
|
ppc_grab_regsfpdab(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
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<double>(intermediate);
|
|
|
|
ppc_store_dfpresult(false);
|
|
|
|
}
|
2019-07-12 05:27:14 +00:00
|
|
|
|
|
|
|
ppc_changecrf1();
|
|
|
|
}
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fmadds() {
|
|
|
|
ppc_grab_regsfpdabc(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
float intermediate = (float)ppc_dblresult64_a * (float)ppc_dblresult64_c;
|
|
|
|
intermediate += (float)ppc_dblresult64_b;
|
|
|
|
ppc_dblresult64_d = static_cast<double>(intermediate);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fmaddsdot() {
|
|
|
|
ppc_grab_regsfpdabc(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
float intermediate = (float)ppc_dblresult64_a * (float)ppc_dblresult64_c;
|
|
|
|
intermediate += (float)ppc_dblresult64_b;
|
|
|
|
ppc_dblresult64_d = static_cast<double>(intermediate);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_changecrf1();
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fmsubs() {
|
|
|
|
ppc_grab_regsfpdabc(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
float intermediate = (float)ppc_dblresult64_a * (float)ppc_dblresult64_c;
|
|
|
|
intermediate -= (float)ppc_dblresult64_b;
|
|
|
|
ppc_dblresult64_d = static_cast<double>(intermediate);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fmsubsdot() {
|
|
|
|
ppc_grab_regsfpdabc(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
float intermediate = (float)ppc_dblresult64_a * (float)ppc_dblresult64_c;
|
|
|
|
intermediate -= (float)ppc_dblresult64_b;
|
|
|
|
ppc_dblresult64_d = static_cast<double>(intermediate);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_changecrf1();
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fnmadds() {
|
|
|
|
ppc_grab_regsfpdabc(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
float intermediate = (float)ppc_dblresult64_a * (float)ppc_dblresult64_c;
|
|
|
|
intermediate += (float)ppc_dblresult64_b;
|
|
|
|
intermediate = -intermediate;
|
|
|
|
ppc_dblresult64_d = static_cast<double>(intermediate);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fnmaddsdot() {
|
|
|
|
ppc_grab_regsfpdabc(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
float intermediate = (float)ppc_dblresult64_a * (float)ppc_dblresult64_c;
|
|
|
|
intermediate += (float)ppc_dblresult64_b;
|
|
|
|
intermediate = -intermediate;
|
|
|
|
ppc_dblresult64_d = static_cast<double>(intermediate);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_changecrf1();
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fnmsubs() {
|
|
|
|
ppc_grab_regsfpdabc(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
float intermediate = (float)ppc_dblresult64_a * (float)ppc_dblresult64_c;
|
|
|
|
intermediate -= (float)ppc_dblresult64_b;
|
|
|
|
intermediate = -intermediate;
|
|
|
|
ppc_dblresult64_d = static_cast<double>(intermediate);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fnmsubsdot() {
|
|
|
|
ppc_grab_regsfpdabc(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
float intermediate = (float)ppc_dblresult64_a * (float)ppc_dblresult64_c;
|
|
|
|
intermediate -= (float)ppc_dblresult64_b;
|
|
|
|
intermediate = -intermediate;
|
|
|
|
ppc_dblresult64_d = static_cast<double>(intermediate);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_changecrf1();
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fabs() {
|
|
|
|
ppc_grab_regsfpdb(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_dblresult64_d = abs(ppc_dblresult64_b);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fabsdot() {
|
|
|
|
ppc_grab_regsfpdb(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_dblresult64_d = abs(ppc_dblresult64_b);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_changecrf1();
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fnabs() {
|
|
|
|
ppc_grab_regsfpdb(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_dblresult64_d = abs(ppc_dblresult64_b);
|
|
|
|
ppc_dblresult64_d = -ppc_dblresult64_d;
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fnabsdot() {
|
|
|
|
ppc_grab_regsfpdb(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_dblresult64_d = abs(ppc_dblresult64_b);
|
|
|
|
ppc_dblresult64_d = -ppc_dblresult64_d;
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_changecrf1();
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fneg() {
|
|
|
|
ppc_grab_regsfpdb(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_dblresult64_d = -ppc_dblresult64_d;
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fnegdot() {
|
|
|
|
ppc_grab_regsfpdb(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_dblresult64_d = -ppc_dblresult64_d;
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_changecrf1();
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fsel() {
|
|
|
|
ppc_grab_regsfpdabc(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
if (ppc_dblresult64_a >= 0.0) {
|
|
|
|
ppc_dblresult64_d = ppc_dblresult64_c;
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
2020-01-22 02:25:50 +00:00
|
|
|
else {
|
|
|
|
ppc_dblresult64_d = ppc_dblresult64_b;
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
2020-01-22 02:25:50 +00:00
|
|
|
|
|
|
|
ppc_store_dfpresult(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fseldot() {
|
|
|
|
ppc_grab_regsfpdabc(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
if (ppc_dblresult64_a >= 0.0) {
|
|
|
|
ppc_dblresult64_d = ppc_dblresult64_c;
|
2019-07-12 05:27:14 +00:00
|
|
|
}
|
2020-01-22 02:25:50 +00:00
|
|
|
else {
|
|
|
|
ppc_dblresult64_d = ppc_dblresult64_b;
|
2019-07-12 05:27:14 +00:00
|
|
|
}
|
2020-01-22 02:25:50 +00:00
|
|
|
|
|
|
|
ppc_store_dfpresult(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_changecrf1();
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fsqrt() {
|
|
|
|
ppc_grab_regsfpdb(false);
|
|
|
|
ppc_dblresult64_d = std::sqrt(ppc_dblresult64_b);
|
|
|
|
ppc_store_dfpresult(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fsqrtdot() {
|
|
|
|
ppc_grab_regsfpdb(false);
|
|
|
|
ppc_dblresult64_d = std::sqrt(ppc_dblresult64_b);
|
|
|
|
ppc_store_dfpresult(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_changecrf1();
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fsqrts() {
|
|
|
|
ppc_grab_regsfpdb(true);
|
2019-07-02 02:15:33 +00:00
|
|
|
uint32_t test = (uint32_t)ppc_result64_b;
|
|
|
|
test += 127 << 23;
|
|
|
|
test >>= 1;
|
2020-01-22 02:25:50 +00:00
|
|
|
uint64_t* pre_final = (uint64_t*)&test;
|
2019-10-09 01:39:39 +00:00
|
|
|
ppc_result64_d = *pre_final;
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(true);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fsqrtsdot() {
|
|
|
|
ppc_grab_regsfpdb(true);
|
2019-07-12 05:27:14 +00:00
|
|
|
uint32_t test = (uint32_t)ppc_result64_b;
|
|
|
|
test += 127 << 23;
|
|
|
|
test >>= 1;
|
2020-01-22 02:25:50 +00:00
|
|
|
uint64_t* pre_final = (uint64_t*)&test;
|
2019-10-09 01:39:39 +00:00
|
|
|
ppc_result64_d = *pre_final;
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(true);
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_changecrf1();
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_frsqrte() {
|
|
|
|
ppc_grab_regsfpdb(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
double testd2 = (double)ppc_result64_b;
|
2020-01-26 02:30:55 +00:00
|
|
|
for (int i = 0; i < 10; i++) {
|
2019-07-02 02:15:33 +00:00
|
|
|
testd2 = testd2 * (1.5 - (testd2 * .5) * testd2 * testd2);
|
|
|
|
}
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_dblresult64_d = testd2;
|
|
|
|
|
|
|
|
ppc_store_dfpresult(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_frsqrtedot() {
|
|
|
|
ppc_grab_regsfpdb(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
double testd2 = (double)ppc_result64_b;
|
2020-01-22 02:25:50 +00:00
|
|
|
for (int i = 0; i < 10; i++) {
|
2019-07-12 05:27:14 +00:00
|
|
|
testd2 = testd2 * (1.5 - (testd2 * .5) * testd2 * testd2);
|
|
|
|
}
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_dblresult64_d = testd2;
|
|
|
|
|
|
|
|
ppc_store_dfpresult(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_changecrf1();
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_frsp() {
|
|
|
|
ppc_grab_regsfpdb(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
double testd2 = (double)ppc_result64_b;
|
2020-01-26 02:30:55 +00:00
|
|
|
float testf2 = (float)testd2;
|
|
|
|
ppc_dblresult64_d = (double)testf2;
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_frspdot() {
|
|
|
|
ppc_grab_regsfpdb(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
double testd2 = (double)ppc_result64_b;
|
2020-01-22 02:25:50 +00:00
|
|
|
float testf2 = (float)testd2;
|
2020-01-26 02:30:55 +00:00
|
|
|
ppc_dblresult64_d = (double)testf2;
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_changecrf1();
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
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);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
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);
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_changecrf1();
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fctiw() {
|
2019-07-02 02:15:33 +00:00
|
|
|
//PLACEHOLDER!
|
2020-01-26 02:30:55 +00:00
|
|
|
ppc_grab_regsfpdiab(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-26 02:30:55 +00:00
|
|
|
ppc_result_d = (uint32_t)(ppc_dblresult64_d);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_store_result_regd();
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fctiwdot() {
|
2019-07-12 05:27:14 +00:00
|
|
|
//PLACEHOLDER!
|
2020-01-26 02:30:55 +00:00
|
|
|
ppc_grab_regsfpdiab(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-26 02:30:55 +00:00
|
|
|
ppc_result_d = (uint32_t)(ppc_dblresult64_d);
|
2019-07-12 05:27:14 +00:00
|
|
|
|
2020-01-26 02:30:55 +00:00
|
|
|
ppc_store_result_regd();
|
|
|
|
ppc_changecrf1();
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fctiwz() {
|
2019-07-02 02:15:33 +00:00
|
|
|
//PLACEHOLDER!
|
2020-01-26 02:30:55 +00:00
|
|
|
ppc_grab_regsfpdiab(false);
|
2019-07-02 02:15:33 +00:00
|
|
|
double testd1 = (double)ppc_result64_a;
|
|
|
|
|
|
|
|
ppc_result_d = (uint32_t)(testd1);
|
|
|
|
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_store_result_regd();
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fctiwzdot() {
|
2019-07-12 05:27:14 +00:00
|
|
|
//PLACEHOLDER!
|
2020-01-26 02:30:55 +00:00
|
|
|
|
|
|
|
ppc_grab_regsfpdiab(false);
|
2019-07-12 05:27:14 +00:00
|
|
|
double testd1 = (double)ppc_result64_a;
|
|
|
|
|
|
|
|
ppc_result_d = (uint32_t)(testd1);
|
|
|
|
|
2020-01-26 02:30:55 +00:00
|
|
|
ppc_store_result_regd();
|
|
|
|
ppc_changecrf1();
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//Floating Point Store and Load
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
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;
|
2020-01-27 00:36:22 +00:00
|
|
|
ppc_result64_d = mem_grab_dword(ppc_effective_address);
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(true);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_lfsu() {
|
|
|
|
ppc_grab_regsfpdia(true);
|
2020-01-26 02:30:55 +00:00
|
|
|
if (reg_a == 0) {
|
|
|
|
ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF));
|
|
|
|
ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0;
|
2020-01-27 00:36:22 +00:00
|
|
|
ppc_result64_d = mem_grab_dword(ppc_effective_address);
|
2020-01-26 02:30:55 +00:00
|
|
|
ppc_result_a = ppc_effective_address;
|
|
|
|
ppc_store_dfpresult(true);
|
|
|
|
ppc_store_result_rega();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x20000);
|
|
|
|
}
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_lfsx() {
|
|
|
|
ppc_grab_regsfpdiab(true);
|
|
|
|
ppc_effective_address = (reg_a == 0) ? ppc_result_b : ppc_result_a + ppc_result_b;
|
2020-01-27 00:36:22 +00:00
|
|
|
ppc_result64_d = mem_grab_dword(ppc_effective_address);
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(true);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_lfsux() {
|
|
|
|
ppc_grab_regsfpdiab(true);
|
2020-01-26 02:30:55 +00:00
|
|
|
if (reg_a == 0) {
|
|
|
|
ppc_effective_address = ppc_result_a + ppc_result_b;
|
2020-01-27 00:36:22 +00:00
|
|
|
ppc_result64_d = mem_grab_dword(ppc_effective_address);
|
2020-01-26 02:30:55 +00:00
|
|
|
ppc_result_a = ppc_effective_address;
|
|
|
|
ppc_store_dfpresult(true);
|
|
|
|
ppc_store_result_rega();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x20000);
|
|
|
|
}
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
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;
|
2020-01-27 00:36:22 +00:00
|
|
|
ppc_result64_d = mem_grab_qword(ppc_effective_address);
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(true);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_lfdu() {
|
|
|
|
ppc_grab_regsfpdia(true);
|
2020-01-26 02:30:55 +00:00
|
|
|
if (reg_a == 0) {
|
|
|
|
ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF));
|
|
|
|
ppc_effective_address += ppc_result_a;
|
2020-01-27 00:36:22 +00:00
|
|
|
ppc_result64_d = mem_grab_qword(ppc_effective_address);
|
2020-01-26 02:30:55 +00:00
|
|
|
ppc_store_dfpresult(true);
|
|
|
|
ppc_result_a = ppc_effective_address;
|
|
|
|
ppc_store_result_rega();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x20000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ppc_lfdx() {
|
|
|
|
ppc_grab_regsfpdia(true);
|
|
|
|
ppc_effective_address += (reg_a > 0) ? ppc_result_a + ppc_result_b : ppc_result_b;
|
2020-01-27 00:36:22 +00:00
|
|
|
ppc_result64_d = mem_grab_qword(ppc_effective_address);
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(true);
|
2020-01-26 02:30:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ppc_lfdux() {
|
|
|
|
ppc_grab_regsfpdiab(true);
|
|
|
|
if (reg_a == 0) {
|
|
|
|
ppc_effective_address = ppc_result_a + ppc_result_b;
|
2020-01-27 00:36:22 +00:00
|
|
|
ppc_result64_d = mem_grab_qword(ppc_effective_address);
|
2020-01-26 02:30:55 +00:00
|
|
|
ppc_store_dfpresult(true);
|
|
|
|
ppc_result_a = ppc_effective_address;
|
|
|
|
ppc_store_result_rega();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x20000);
|
|
|
|
}
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
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;
|
2020-01-27 00:36:22 +00:00
|
|
|
mem_write_dword(ppc_effective_address, uint32_t(ppc_state.ppc_fpr[reg_s].int64_r));
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_stfsu() {
|
|
|
|
ppc_grab_regsfpsia(true);
|
2020-01-26 02:30:55 +00:00
|
|
|
if (reg_a == 0) {
|
|
|
|
ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF));
|
|
|
|
ppc_effective_address += ppc_result_a;
|
2020-01-27 00:36:22 +00:00
|
|
|
mem_write_dword(ppc_effective_address, uint32_t(ppc_state.ppc_fpr[reg_s].int64_r));
|
2020-01-26 02:30:55 +00:00
|
|
|
ppc_result_a = ppc_effective_address;
|
|
|
|
ppc_store_result_rega();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x20000);
|
|
|
|
}
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-26 02:30:55 +00:00
|
|
|
void ppc_stfsx() {
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_grab_regsfpsiab(true);
|
|
|
|
ppc_effective_address = (reg_a == 0) ? ppc_result_b : ppc_result_a + ppc_result_b;
|
2020-01-27 00:36:22 +00:00
|
|
|
mem_write_dword(ppc_effective_address, uint32_t(ppc_state.ppc_fpr[reg_s].int64_r));
|
2020-01-26 02:30:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ppc_stfsux() {
|
|
|
|
ppc_grab_regsfpsiab(true);
|
|
|
|
if (reg_a == 0) {
|
|
|
|
ppc_effective_address = ppc_result_a + ppc_result_b;
|
2020-01-27 00:36:22 +00:00
|
|
|
mem_write_dword(ppc_effective_address, uint32_t(ppc_state.ppc_fpr[reg_s].int64_r));
|
2020-01-26 02:30:55 +00:00
|
|
|
ppc_result_a = ppc_effective_address;
|
|
|
|
ppc_store_result_rega();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x20000);
|
|
|
|
}
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
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;
|
2020-01-27 00:36:22 +00:00
|
|
|
mem_write_qword(ppc_effective_address, ppc_state.ppc_fpr[reg_s].int64_r);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_stfdu() {
|
|
|
|
ppc_grab_regsfpsia(true);
|
2020-01-26 02:30:55 +00:00
|
|
|
if (reg_a == 0) {
|
|
|
|
ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF));
|
|
|
|
ppc_effective_address += ppc_result_a;
|
2020-01-27 00:36:22 +00:00
|
|
|
mem_write_qword(ppc_effective_address, ppc_state.ppc_fpr[reg_s].int64_r);
|
2020-01-26 02:30:55 +00:00
|
|
|
ppc_result_a = ppc_effective_address;
|
|
|
|
ppc_store_result_rega();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x20000);
|
|
|
|
}
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_stfdx() {
|
|
|
|
ppc_grab_regsfpsiab(true);
|
|
|
|
ppc_effective_address = (reg_a == 0) ? ppc_result_b : ppc_result_a + ppc_result_b;
|
2020-01-27 00:36:22 +00:00
|
|
|
mem_write_qword(ppc_effective_address, ppc_state.ppc_fpr[reg_s].int64_r);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_stfdux() {
|
|
|
|
ppc_grab_regsfpsiab(true);
|
2020-01-26 02:30:55 +00:00
|
|
|
if (reg_a == 0) {
|
|
|
|
ppc_effective_address = ppc_result_a + ppc_result_b;
|
2020-01-27 00:36:22 +00:00
|
|
|
mem_write_qword(ppc_effective_address, ppc_state.ppc_fpr[reg_s].int64_r);
|
2020-01-26 02:30:55 +00:00
|
|
|
ppc_result_a = ppc_effective_address;
|
|
|
|
ppc_store_result_rega();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x20000);
|
|
|
|
}
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_stfiwx() {
|
|
|
|
ppc_grab_regsfpsiab(true);
|
|
|
|
ppc_effective_address = (reg_a == 0) ? ppc_result_b : ppc_result_a + ppc_result_b;
|
2020-01-27 00:36:22 +00:00
|
|
|
mem_write_dword(ppc_effective_address, (uint32_t)(ppc_state.ppc_fpr[reg_s].int64_r));
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
2020-01-22 02:25:50 +00:00
|
|
|
|
2019-07-02 02:15:33 +00:00
|
|
|
//Floating Point Register Transfer
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fmr() {
|
|
|
|
ppc_grab_regsfpdb(true);
|
2019-07-02 02:15:33 +00:00
|
|
|
ppc_state.ppc_fpr[reg_d] = ppc_state.ppc_fpr[reg_b];
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_store_dfpresult(true);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
|
|
|
|
void ppc_mffs() {
|
2019-07-02 02:15:33 +00:00
|
|
|
ppc_grab_regsda();
|
2020-01-22 02:25:50 +00:00
|
|
|
uint64_t fpstore1 = ppc_state.ppc_fpr[reg_d].int64_r & 0xFFFFFFFF00000000;
|
2019-07-02 02:15:33 +00:00
|
|
|
uint64_t fpstore2 = ppc_state.ppc_fpscr & 0x00000000FFFFFFFF;
|
|
|
|
fpstore1 |= fpstore2;
|
2020-01-22 02:25:50 +00:00
|
|
|
fp_save_uint64(fpstore1);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_mffsdot() {
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_grab_regsda();
|
2020-01-22 02:25:50 +00:00
|
|
|
uint64_t fpstore1 = ppc_state.ppc_fpr[reg_d].int64_r & 0xFFFFFFFF00000000;
|
2019-07-12 05:27:14 +00:00
|
|
|
uint64_t fpstore2 = ppc_state.ppc_fpscr & 0x00000000FFFFFFFF;
|
|
|
|
fpstore1 |= fpstore2;
|
2020-01-22 02:25:50 +00:00
|
|
|
fp_save_uint64(fpstore1);
|
2020-01-12 01:43:47 +00:00
|
|
|
ppc_fp_changecrf1();
|
2019-07-12 05:27:14 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_mtfsf() {
|
2019-07-02 02:15:33 +00:00
|
|
|
reg_b = (ppc_cur_instruction >> 11) & 31;
|
|
|
|
uint32_t fm_mask = (ppc_cur_instruction >> 17) & 255;
|
2020-01-22 02:25:50 +00:00
|
|
|
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;
|
2019-07-12 05:27:14 +00:00
|
|
|
ppc_state.ppc_fpscr = (quickfprval & crm) | (quickfprval & ~(crm));
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_mtfsfdot() {
|
2020-01-12 04:17:29 +00:00
|
|
|
reg_b = (ppc_cur_instruction >> 11) & 31;
|
|
|
|
uint32_t fm_mask = (ppc_cur_instruction >> 17) & 255;
|
2020-01-22 02:25:50 +00:00
|
|
|
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;
|
2019-07-02 02:15:33 +00:00
|
|
|
ppc_state.ppc_fpscr = (quickfprval & crm) | (quickfprval & ~(crm));
|
2020-01-12 01:43:47 +00:00
|
|
|
ppc_fp_changecrf1();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ppc_mtfsfi() {
|
|
|
|
ppc_result_b = (ppc_cur_instruction >> 11) & 15;
|
|
|
|
crf_d = (ppc_cur_instruction >> 23) & 7;
|
|
|
|
crf_d = crf_d << 2;
|
2020-01-28 03:39:23 +00:00
|
|
|
ppc_state.ppc_fpscr = (ppc_state.ppc_cr & ~(0xF0000000UL >> crf_d)) | ((ppc_state.ppc_spr[SPR::XER] & 0xF0000000UL) >> crf_d);
|
2020-01-12 01:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ppc_mtfsfidot() {
|
|
|
|
ppc_result_b = (ppc_cur_instruction >> 11) & 15;
|
|
|
|
crf_d = (ppc_cur_instruction >> 23) & 7;
|
|
|
|
crf_d = crf_d << 2;
|
2020-01-28 03:39:23 +00:00
|
|
|
ppc_state.ppc_fpscr = (ppc_state.ppc_cr & ~(0xF0000000UL >> crf_d)) | ((ppc_state.ppc_spr[SPR::XER] & 0xF0000000UL) >> crf_d);
|
2020-01-12 01:43:47 +00:00
|
|
|
ppc_fp_changecrf1();
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_mtfsb0() {
|
2019-07-02 02:15:33 +00:00
|
|
|
crf_d = (ppc_cur_instruction >> 21) & 0x31;
|
2020-01-22 02:25:50 +00:00
|
|
|
if ((crf_d == 0) || (crf_d > 2)) {
|
2019-07-02 02:15:33 +00:00
|
|
|
ppc_state.ppc_fpscr &= ~(1 << (31 - crf_d));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_mtfsb0dot() {
|
2019-07-02 02:15:33 +00:00
|
|
|
crf_d = (ppc_cur_instruction >> 21) & 0x31;
|
2020-01-22 02:25:50 +00:00
|
|
|
if ((crf_d == 0) || (crf_d > 2)) {
|
2019-07-02 02:15:33 +00:00
|
|
|
ppc_state.ppc_fpscr &= ~(1 << crf_d);
|
|
|
|
}
|
2020-01-12 01:43:47 +00:00
|
|
|
ppc_fp_changecrf1();
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_mtfsb1() {
|
2019-07-02 02:15:33 +00:00
|
|
|
crf_d = (ppc_cur_instruction >> 21) & 0x31;
|
2020-01-22 02:25:50 +00:00
|
|
|
if ((crf_d == 0) || (crf_d > 2)) {
|
2019-07-02 02:15:33 +00:00
|
|
|
ppc_state.ppc_fpscr |= (1 << crf_d);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_mtfsb1dot() {
|
2019-07-02 02:15:33 +00:00
|
|
|
crf_d = ~(ppc_cur_instruction >> 21) & 0x31;
|
2020-01-22 02:25:50 +00:00
|
|
|
if ((crf_d == 0) || (crf_d > 2)) {
|
2019-07-02 02:15:33 +00:00
|
|
|
ppc_state.ppc_fpscr |= (1 << crf_d);
|
|
|
|
}
|
2020-01-12 01:43:47 +00:00
|
|
|
ppc_fp_changecrf1();
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_mcrfs() {
|
2019-07-02 02:15:33 +00:00
|
|
|
crf_d = (ppc_cur_instruction >> 23) & 7;
|
|
|
|
crf_d = crf_d << 2;
|
|
|
|
crf_s = (ppc_cur_instruction >> 18) & 7;
|
|
|
|
crf_s = crf_d << 2;
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_state.ppc_cr = ~(ppc_state.ppc_cr & ((15 << (28 - crf_d)))) & (ppc_state.ppc_fpscr & (15 << (28 - crf_s)));
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//Floating Point Comparisons
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fcmpo() {
|
|
|
|
ppc_grab_regsfpsab(true);
|
|
|
|
|
2019-07-02 02:15:33 +00:00
|
|
|
crf_d = (ppc_cur_instruction >> 23) & 7;
|
|
|
|
crf_d = crf_d << 2;
|
|
|
|
|
|
|
|
double db_test_a = (double)ppc_result64_a;
|
|
|
|
double db_test_b = (double)ppc_result64_b;
|
|
|
|
|
|
|
|
ppc_state.ppc_fpscr &= 0xFFFF0FFF;
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
if (std::isnan(db_test_a) || std::isnan(db_test_b)) {
|
2019-07-02 02:15:33 +00:00
|
|
|
cmp_c |= 0x01;
|
|
|
|
}
|
2020-01-22 02:25:50 +00:00
|
|
|
else if (db_test_a < db_test_b) {
|
2019-07-02 02:15:33 +00:00
|
|
|
cmp_c |= 0x08;
|
|
|
|
}
|
2020-01-22 02:25:50 +00:00
|
|
|
else if (db_test_a > db_test_b) {
|
2019-07-02 02:15:33 +00:00
|
|
|
cmp_c |= 0x04;
|
|
|
|
}
|
2020-01-22 02:25:50 +00:00
|
|
|
else {
|
2019-07-02 02:15:33 +00:00
|
|
|
cmp_c |= 0x02;
|
|
|
|
}
|
|
|
|
|
|
|
|
ppc_state.ppc_fpscr |= (cmp_c << 12);
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_state.ppc_cr = ((ppc_state.ppc_cr & ~(0xf0000000 >> crf_d)) | ((cmp_c + xercon) >> crf_d));
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
if ((db_test_a == snan) || (db_test_b == snan)) {
|
2019-07-02 02:15:33 +00:00
|
|
|
ppc_state.ppc_fpscr |= 0x1000000;
|
2020-01-22 02:25:50 +00:00
|
|
|
if (ppc_state.ppc_fpscr & 0x80) {
|
2019-07-02 02:15:33 +00:00
|
|
|
ppc_state.ppc_fpscr |= 0x80000;
|
|
|
|
}
|
|
|
|
}
|
2020-01-22 02:25:50 +00:00
|
|
|
else if ((db_test_a == qnan) || (db_test_b == qnan)) {
|
2019-07-02 02:15:33 +00:00
|
|
|
ppc_state.ppc_fpscr |= 0x80000;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
void ppc_fcmpu() {
|
|
|
|
ppc_grab_regsfpsab(true);
|
|
|
|
|
2019-07-02 02:15:33 +00:00
|
|
|
crf_d = (ppc_cur_instruction >> 23) & 7;
|
|
|
|
crf_d = crf_d << 2;
|
|
|
|
|
|
|
|
double db_test_a = (double)ppc_result64_a;
|
|
|
|
double db_test_b = (double)ppc_result64_b;
|
|
|
|
|
|
|
|
ppc_state.ppc_fpscr &= 0xFFFF0FFF;
|
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
if (std::isnan(db_test_a) || std::isnan(db_test_b)) {
|
2019-07-02 02:15:33 +00:00
|
|
|
cmp_c |= 0x01;
|
|
|
|
}
|
2020-01-22 02:25:50 +00:00
|
|
|
else if (db_test_a < db_test_b) {
|
2019-07-02 02:15:33 +00:00
|
|
|
cmp_c |= 0x08;
|
|
|
|
}
|
2020-01-22 02:25:50 +00:00
|
|
|
else if (db_test_a > db_test_b) {
|
2019-07-02 02:15:33 +00:00
|
|
|
cmp_c |= 0x04;
|
|
|
|
}
|
2020-01-22 02:25:50 +00:00
|
|
|
else {
|
2019-07-02 02:15:33 +00:00
|
|
|
cmp_c |= 0x02;
|
|
|
|
}
|
|
|
|
|
|
|
|
ppc_state.ppc_fpscr |= (cmp_c << 12);
|
2020-01-22 02:25:50 +00:00
|
|
|
ppc_state.ppc_cr = ((ppc_state.ppc_cr & ~(0xf0000000 >> crf_d)) | ((cmp_c + xercon) >> crf_d));
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2020-01-22 02:25:50 +00:00
|
|
|
if ((db_test_a == snan) || (db_test_b == snan)) {
|
2019-07-02 02:15:33 +00:00
|
|
|
ppc_state.ppc_fpscr |= 0x1000000;
|
|
|
|
}
|
2020-02-03 15:03:24 +00:00
|
|
|
}
|