From 87acd53c8670c4583e393cc23e932f592ac6275a Mon Sep 17 00:00:00 2001 From: dingusdev <52434309+dingusdev@users.noreply.github.com> Date: Thu, 11 Jul 2019 22:27:14 -0700 Subject: [PATCH] Update for July 11, 2019 - Fixed the floating point operations dispatch table and filled in a lot of missing gaps - Started overhauling floating point emulation - Minor fixes for Grackle reading and writing, mostly writing - Handle integer division by zero cases --- main.cpp | 5 +- mpc106.cpp | 155 ++++++++++----- ppcemumain.h | 316 +++++++++++++++++++++++------- ppcfpopcodes.cpp | 499 +++++++++++++++++++++++++++++++++++++++++++++-- ppcmemory.cpp | 9 +- ppcopcodes.cpp | 97 +++++++++ 6 files changed, 942 insertions(+), 139 deletions(-) diff --git a/main.cpp b/main.cpp index ab01379..c04afbf 100644 --- a/main.cpp +++ b/main.cpp @@ -422,7 +422,7 @@ int main(int argc, char **argv) uint32_t opcode_entered = 0; //used for testing opcodes in playground - std::cout << "DingusPPC - Prototype 5bf3 (6/9/2019) " << endl; + std::cout << "DingusPPC - Prototype 5bf4 (7/14/2019) " << endl; std::cout << "Written by divingkatae, (c) 2019. " << endl; std::cout << "This is not intended for general use. " << endl; std::cout << "Use at your own discretion. " << endl; @@ -542,7 +542,8 @@ int main(int argc, char **argv) {"Spar", "20th Anniversay Mac, you lucky thing."}, //Spartacus {"Tanz", "Power Mac 4400"}, //Tanzania {"TNT ", "Power Mac 7xxxx/8xxx series"}, //Trinitrotoluene :-) - {"Zanz", "A complete engima."} //Zanzibar (mentioned in Sheepshaver's code, but no match to any known ROM) + {"Zanz", "A complete engima."}, //Zanzibar (mentioned in Sheepshaver's code, but no match to any known ROM) + {"????", "A clone, perhaps?"} //N/A (Placeholder ID) }; char configGrab = 0; diff --git a/mpc106.cpp b/mpc106.cpp index fea2ae6..2edd2a1 100644 --- a/mpc106.cpp +++ b/mpc106.cpp @@ -10,6 +10,7 @@ #include #include #include +#include "viacuda.h" #include "mpc106.h" #include "ppcemumain.h" #include "ppcmemory.h" @@ -32,47 +33,82 @@ void mpc106_init(){ mpc_config_dat = 0; //Initialize Vendor & Device IDs - machine_fexxxx_mem[0] = 0x57; - machine_fexxxx_mem[1] = 0x10; + machine_fexxxx_mem[0x00] = 0x57; + machine_fexxxx_mem[0x01] = 0x10; - machine_fexxxx_mem[2] = 0x02; + machine_fexxxx_mem[0x02] = 0x02; //PCI command + status - machine_fexxxx_mem[4] = 0x06; - machine_fexxxx_mem[6] = 0x80; + machine_fexxxx_mem[0x04] = 0x06; + machine_fexxxx_mem[0x06] = 0x80; - machine_fexxxx_mem[115] = 0xCD; + machine_fexxxx_mem[0x0B] = 0x06; + machine_fexxxx_mem[0x0C] = 0x08; - machine_fexxxx_mem[168] = 0x10; - machine_fexxxx_mem[169] = 0x00; - machine_fexxxx_mem[170] = 0x00; - machine_fexxxx_mem[171] = 0xFF; + machine_fexxxx_mem[0x73] = 0xCD; - machine_fexxxx_mem[172] = 0x0C; - machine_fexxxx_mem[173] = 0x06; - machine_fexxxx_mem[174] = 0x0C; - machine_fexxxx_mem[175] = 0x00; + machine_fexxxx_mem[0xA8] = 0x10; + machine_fexxxx_mem[0xA9] = 0x00; + machine_fexxxx_mem[0xAA] = 0x00; + machine_fexxxx_mem[0xAB] = 0xFF; + + machine_fexxxx_mem[0xAC] = 0x0C; + machine_fexxxx_mem[0xAD] = 0x06; + machine_fexxxx_mem[0xAE] = 0x0C; + machine_fexxxx_mem[0xAF] = 0x00; + + machine_fexxxx_mem[0xBA] = 0x04; + + machine_fexxxx_mem[0xAC] = 0x0C; + machine_fexxxx_mem[0xAD] = 0x06; + machine_fexxxx_mem[0xAE] = 0x0C; + machine_fexxxx_mem[0xAF] = 0x00; + + machine_fexxxx_mem[0xAC] = 0x0C; + machine_fexxxx_mem[0xAD] = 0x06; + machine_fexxxx_mem[0xAE] = 0x0C; + machine_fexxxx_mem[0xAF] = 0x00; + + machine_fexxxx_mem[0xAC] = 0x0C; + machine_fexxxx_mem[0xAD] = 0x06; + machine_fexxxx_mem[0xAE] = 0x0C; + machine_fexxxx_mem[0xAF] = 0x00; + + machine_fexxxx_mem[0xF0] = 0x00; + machine_fexxxx_mem[0xF1] = 0x00; + machine_fexxxx_mem[0xF2] = 0x02; + machine_fexxxx_mem[0xF3] = 0xFF; + + machine_fexxxx_mem[0xF4] = 0x03; + machine_fexxxx_mem[0xF5] = 0x00; + machine_fexxxx_mem[0xF6] = 0x00; + machine_fexxxx_mem[0xF7] = 0x00; + + machine_fexxxx_mem[0xFC] = 0x00; + machine_fexxxx_mem[0xFD] = 0x00; + machine_fexxxx_mem[0xFE] = 0x10; + machine_fexxxx_mem[0xFF] = 0x00; } uint32_t mpc106_write_device(uint32_t device_addr, uint32_t insert_to_device, uint8_t bit_length){ //Write to the specified device - Invoked when a write is made to 0xFEExxxxx. - //device_addr is what's stored in 0xFEC00CF8. + //device_addr is what's stored in 0xFEC00CF8 (The MPG106/Grackle's CONFIG_ADDR Register). uint32_t reg_num = (device_addr & 0x07FC) >> 2; uint32_t dev_num = (device_addr & 0xF800) >> 11; - uint32_t location = reg_num + (dev_num << 11) + 0x3000000; - switch (bit_length){ - case 1: - machine_iocontrolmem_mem[location] = (uint8_t)insert_to_device; - case 2: - machine_iocontrolmem_mem[location++] = (uint8_t)insert_to_device; - machine_iocontrolmem_mem[location] = (uint8_t)(insert_to_device >> 8); - case 4: - machine_iocontrolmem_mem[location++] = (uint8_t)insert_to_device; - machine_iocontrolmem_mem[location++] = (uint8_t)(insert_to_device >> 8); - machine_iocontrolmem_mem[location++] = (uint8_t)(insert_to_device >> 16); - machine_iocontrolmem_mem[location] = (uint8_t)(insert_to_device >> 24); + switch(dev_num){ + case 0: + //Device 0 is reserved to the grackle by default + mpc106_address = reg_num; + mpc106_write(insert_to_device); + break; + case 16: + case 17: + via_cuda_address = (reg_num << 9) + (dev_num << 12) + 0x3000000; + via_write_byte = (uint8_t)insert_to_device; + via_cuda_write(); + break; } return 0; @@ -80,25 +116,26 @@ uint32_t mpc106_write_device(uint32_t device_addr, uint32_t insert_to_device, ui uint32_t mpc106_read_device(uint32_t device_addr, uint8_t bit_length){ //Read to the specified device - Invoked when a read is made to 0xFEExxxxx. - //device_addr is what's stored in 0xFEC00CF8. + //device_addr is what's stored in 0xFEC00CF8 (The MPG106/Grackle's CONFIG_ADDR Register). uint32_t reg_num = (device_addr & 0x07FC) >> 2; uint32_t dev_num = (device_addr & 0xF800) >> 11; - uint32_t location = reg_num + (dev_num << 11) + 0x3000000; uint32_t grab_value = 0; - switch (bit_length){ - case 1: - grab_value |= ((uint32_t)(machine_iocontrolmem_mem[location++])); - case 2: - grab_value |= ((uint32_t)(machine_iocontrolmem_mem[location++])); - grab_value |= ((uint32_t)(machine_iocontrolmem_mem[location++])) << 8; - case 4: - grab_value |= ((uint32_t)(machine_iocontrolmem_mem[location++])); - grab_value |= ((uint32_t)(machine_iocontrolmem_mem[location++])) << 8; - grab_value |= ((uint32_t)(machine_iocontrolmem_mem[location++])) << 16; - grab_value |= ((uint32_t)(machine_iocontrolmem_mem[location])) << 24; + switch(dev_num){ + case 0: + //Device 0 is reserved to the grackle by default + mpc106_address = reg_num; + mpc106_read(); + grab_value = mpc106_read_word; + break; + case 16: + case 17: + via_cuda_address = (reg_num << 8) + (dev_num << 12) + 0x3000000; + via_cuda_read(); + grab_value = (uint32_t)via_read_byte; + break; } return grab_value; @@ -110,6 +147,17 @@ void mpc106_read(){ switch (mpc106_address){ case 0x8: + case 0x9: + case 0xA: + case 0xB: + case 0xC: + case 0xD: + case 0xE: + case 0xF: + case 0x3C: + case 0x3D: + case 0x3E: + case 0x3F: case 0x72: case 0x73: case 0xA0: @@ -136,6 +184,8 @@ void mpc106_read(){ case 0xF8: case 0xFC: read_length = 4; + default: //Avoid writing into reserved areas + read_length = 0; } switch(read_length){ @@ -161,15 +211,13 @@ void mpc106_write(uint32_t write_word){ uint8_t write_length = 4; switch (mpc106_address){ - case 0x8: case 0x70: case 0x72: case 0x73: case 0xA0: + case 0xA3: write_length = 1; break; - case 0x0: - case 0x2: case 0x4: case 0x6: write_length = 2; @@ -187,6 +235,8 @@ void mpc106_write(uint32_t write_word){ case 0xF8: case 0xFC: write_length = 4; + default: //Avoid writing into reserved areas + write_length = 0; } switch(write_length){ @@ -198,10 +248,19 @@ void mpc106_write(uint32_t write_word){ grab_macmem_ptr[mpc106_address] |= (uint8_t)((mpc106_read_word >> 8) & 0xFF); break; case 4: - grab_macmem_ptr[mpc106_address++] |= (uint8_t)((mpc106_read_word) & 0xFF); - grab_macmem_ptr[mpc106_address++] |= (uint8_t)((mpc106_read_word >> 8) & 0xFF); - grab_macmem_ptr[mpc106_address++] |= (uint8_t)((mpc106_read_word >> 16) & 0xFF); - grab_macmem_ptr[mpc106_address] |= (uint8_t)((mpc106_read_word >> 24) & 0xFF); - break; + if ((mpc106_address == 0x88) | (mpc106_address == 0x8C) | (mpc106_address == 0x98) | (mpc106_address == 0x9C)){ + grab_macmem_ptr[mpc106_address++] |= (uint8_t)((mpc106_read_word) & 0x03); + grab_macmem_ptr[mpc106_address++] |= (uint8_t)((mpc106_read_word >> 8) & 0x03); + grab_macmem_ptr[mpc106_address++] |= (uint8_t)((mpc106_read_word >> 16) & 0x03); + grab_macmem_ptr[mpc106_address] |= (uint8_t)((mpc106_read_word >> 24) & 0x03); + break; + } + else{ + grab_macmem_ptr[mpc106_address++] |= (uint8_t)((mpc106_read_word) & 0xFF); + grab_macmem_ptr[mpc106_address++] |= (uint8_t)((mpc106_read_word >> 8) & 0xFF); + grab_macmem_ptr[mpc106_address++] |= (uint8_t)((mpc106_read_word >> 16) & 0xFF); + grab_macmem_ptr[mpc106_address] |= (uint8_t)((mpc106_read_word >> 24) & 0xFF); + break; + } } } diff --git a/ppcemumain.h b/ppcemumain.h index 9240a3b..4dc0cf4 100644 --- a/ppcemumain.h +++ b/ppcemumain.h @@ -398,7 +398,9 @@ extern void ppc_mtfsb0dot(); extern void ppc_mtfsb1dot(); extern void ppc_fmr(); extern void ppc_mffs(); +extern void ppc_mffsdot(); extern void ppc_mtfsf(); +extern void ppc_mtfsfdot(); extern void ppc_addi(); extern void ppc_addic(); @@ -476,6 +478,7 @@ extern void ppc_fmsubs(); extern void ppc_fnmadds(); extern void ppc_fnmsubs(); extern void ppc_fabs(); +extern void ppc_fnabs(); extern void ppc_fneg(); extern void ppc_fsel(); extern void ppc_fres(); @@ -486,6 +489,35 @@ extern void ppc_frsp(); extern void ppc_fctiw(); extern void ppc_fctiwz(); +extern void ppc_fadddot(); +extern void ppc_fsubdot(); +extern void ppc_fmultdot(); +extern void ppc_fdivdot(); +extern void ppc_fmadddot(); +extern void ppc_fmsubdot(); +extern void ppc_fnmadddot(); +extern void ppc_fnmsubdot(); +extern void ppc_fabsdot(); +extern void ppc_fnabsdot(); +extern void ppc_fnegdot(); +extern void ppc_fseldot(); +extern void ppc_fsqrtdot(); +extern void ppc_frsqrtedot(); +extern void ppc_frspdot(); +extern void ppc_fctiwdot(); +extern void ppc_fctiwzdot(); + +extern void ppc_fresdot(); +extern void ppc_faddsdot(); +extern void ppc_fsubsdot(); +extern void ppc_fmultsdot(); +extern void ppc_fdivsdot(); +extern void ppc_fmaddsdot(); +extern void ppc_fmsubsdot(); +extern void ppc_fnmaddsdot(); +extern void ppc_fnmsubsdot(); +extern void ppc_fsqrtsdot(); + extern void ppc_fcmpo(); extern void ppc_fcmpu(); @@ -613,15 +645,18 @@ static std::map OpcodeGrabber = static std::map SubOpcode16Grabber= {{0, &ppc_bc}, {1, &ppc_bcl}, {2, &ppc_bca}, {3, &ppc_bcla} }; + static std::map SubOpcode18Grabber= {{0, &ppc_b}, {1, &ppc_bl}, {2, &ppc_ba}, {3, &ppc_bla} }; + static std::map SubOpcode19Grabber= {{32, &ppc_bclr}, {33, &ppc_bclrl}, {66, &ppc_crnor}, {100, &ppc_rfi}, {258, &ppc_crandc}, {300, &ppc_isync}, {386, &ppc_crxor}, {450, &ppc_crnand}, {514, &ppc_crand}, {578, &ppc_creqv}, {834, &ppc_crorc}, {898, &ppc_cror}, {1056, &ppc_bcctr}, {1057, &ppc_bcctrl} }; + static std::map SubOpcode31Grabber= {{0, &ppc_cmp}, {8, &ppc_tw}, {16, &ppc_subfc}, {17, &ppc_subfcdot}, {20, &ppc_addc}, {21, &ppc_addcdot}, {22, &ppc_mulhwu}, {23, &ppc_mulhwudot}, @@ -682,80 +717,215 @@ static std::map SubOpcode31Grabber= }; static std::map SubOpcode59Grabber= - {{36, &ppc_fdivs}, {40, &ppc_fsubs}, {42, &ppc_fadds}, {44, &ppc_fsqrts}, {48, &ppc_frsp}, - {50, &ppc_fmults}, {56, &ppc_fmsubs}, {58, &ppc_fmadds}, {60, &ppc_fnmsubs}, {62, &ppc_fnmadds}, - {114, &ppc_fmults}, {120, &ppc_fmsubs}, {122, &ppc_fmadds}, {124, &ppc_fnmsubs}, {126, &ppc_fnmadds}, - {178, &ppc_fmults}, {184, &ppc_fmsubs}, {186, &ppc_fmadds}, {188, &ppc_fnmsubs}, {190, &ppc_fnmadds}, - {242, &ppc_fmults}, {248, &ppc_fmsubs}, {250, &ppc_fmadds}, {252, &ppc_fnmsubs}, {254, &ppc_fnmadds}, - {306, &ppc_fmults}, {312, &ppc_fmsubs}, {314, &ppc_fmadds}, {316, &ppc_fnmsubs}, {318, &ppc_fnmadds}, - {370, &ppc_fmults}, {376, &ppc_fmsubs}, {378, &ppc_fmadds}, {380, &ppc_fnmsubs}, {382, &ppc_fnmadds}, - {434, &ppc_fmults}, {440, &ppc_fmsubs}, {442, &ppc_fmadds}, {444, &ppc_fnmsubs}, {446, &ppc_fnmadds}, - {498, &ppc_fmults}, {504, &ppc_fmsubs}, {506, &ppc_fmadds}, {508, &ppc_fnmsubs}, {510, &ppc_fnmadds}, - {562, &ppc_fmults}, {568, &ppc_fmsubs}, {570, &ppc_fmadds}, {572, &ppc_fnmsubs}, {574, &ppc_fnmadds}, - {626, &ppc_fmults}, {632, &ppc_fmsubs}, {634, &ppc_fmadds}, {636, &ppc_fnmsubs}, {638, &ppc_fnmadds}, - {690, &ppc_fmults}, {696, &ppc_fmsubs}, {698, &ppc_fmadds}, {700, &ppc_fnmsubs}, {702, &ppc_fnmadds}, - {754, &ppc_fmults}, {752, &ppc_fmsubs}, {754, &ppc_fmadds}, {764, &ppc_fnmsubs}, {766, &ppc_fnmadds}, - {818, &ppc_fmults}, {824, &ppc_fmsubs}, {826, &ppc_fmadds}, {828, &ppc_fnmsubs}, {830, &ppc_fnmadds}, - {882, &ppc_fmults}, {888, &ppc_fmsubs}, {890, &ppc_fmadds}, {892, &ppc_fnmsubs}, {894, &ppc_fnmadds}, - {946, &ppc_fmults}, {952, &ppc_fmsubs}, {954, &ppc_fmadds}, {956, &ppc_fnmsubs}, {958, &ppc_fnmadds}, - {1010, &ppc_fmults}, {1016, &ppc_fmsubs}, {1018, &ppc_fmadds}, {1020, &ppc_fnmsubs}, {1022, &ppc_fnmadds}, - {1074, &ppc_fmults}, {1080, &ppc_fmsubs}, {1082, &ppc_fmadds}, {1084, &ppc_fnmsubs}, {1086, &ppc_fnmadds}, - {1138, &ppc_fmults}, {1144, &ppc_fmsubs}, {1146, &ppc_fmadds}, {1148, &ppc_fnmsubs}, {1150, &ppc_fnmadds}, - {1202, &ppc_fmults}, {1208, &ppc_fmsubs}, {1210, &ppc_fmadds}, {1212, &ppc_fnmsubs}, {1214, &ppc_fnmadds}, - {1266, &ppc_fmults}, {1272, &ppc_fmsubs}, {1274, &ppc_fmadds}, {1276, &ppc_fnmsubs}, {1278, &ppc_fnmadds}, - {1330, &ppc_fmults}, {1336, &ppc_fmsubs}, {1338, &ppc_fmadds}, {1340, &ppc_fnmsubs}, {1342, &ppc_fnmadds}, - {1394, &ppc_fmults}, {1400, &ppc_fmsubs}, {1402, &ppc_fmadds}, {1404, &ppc_fnmsubs}, {1406, &ppc_fnmadds}, - {1458, &ppc_fmults}, {1464, &ppc_fmsubs}, {1466, &ppc_fmadds}, {1468, &ppc_fnmsubs}, {1470, &ppc_fnmadds}, - {1522, &ppc_fmults}, {1528, &ppc_fmsubs}, {1530, &ppc_fmadds}, {1532, &ppc_fnmsubs}, {1534, &ppc_fnmadds}, - {1586, &ppc_fmults}, {1592, &ppc_fmsubs}, {1594, &ppc_fmadds}, {1596, &ppc_fnmsubs}, {1598, &ppc_fnmadds}, - {1650, &ppc_fmults}, {1656, &ppc_fmsubs}, {1658, &ppc_fmadds}, {1660, &ppc_fnmsubs}, {1662, &ppc_fnmadds}, - {1714, &ppc_fmults}, {1720, &ppc_fmsubs}, {1722, &ppc_fmadds}, {1724, &ppc_fnmsubs}, {1726, &ppc_fnmadds}, - {1778, &ppc_fmults}, {1784, &ppc_fmsubs}, {1786, &ppc_fmadds}, {1788, &ppc_fnmsubs}, {1790, &ppc_fnmadds}, - {1842, &ppc_fmults}, {1848, &ppc_fmsubs}, {1850, &ppc_fmadds}, {1852, &ppc_fnmsubs}, {1854, &ppc_fnmadds}, - {1906, &ppc_fmults}, {1912, &ppc_fmsubs}, {1914, &ppc_fmadds}, {1916, &ppc_fnmsubs}, {1918, &ppc_fnmadds}, - {1970, &ppc_fmults}, {1976, &ppc_fmsubs}, {1978, &ppc_fmadds}, {1980, &ppc_fnmsubs}, {1982, &ppc_fnmadds}, - {2034, &ppc_fmults}, {2040, &ppc_fmsubs}, {2042, &ppc_fmadds}, {2044, &ppc_fnmsubs}, {2046, &ppc_fnmadds} - }; + {{36, &ppc_fdivs}, {37, &ppc_fdivsdot}, {40, &ppc_fsubs}, {41, &ppc_fsubsdot}, + {42, &ppc_fadds}, {43, &ppc_faddsdot}, {44, &ppc_fsqrts}, {45, &ppc_fsqrtsdot}, + {48, &ppc_fres}, {49, &ppc_fresdot}, + {50, &ppc_fmults}, {51, &ppc_fmultsdot}, {56, &ppc_fmsubs}, {57, &ppc_fmsubsdot}, + {58, &ppc_fmadds}, {59, &ppc_fmaddsdot}, {60, &ppc_fnmsubs},{61, &ppc_fnmsubsdot}, + {62, &ppc_fnmadds}, {63, &ppc_fnmaddsdot}, + {114, &ppc_fmults}, {115, &ppc_fmultsdot}, + {120, &ppc_fmsubs}, {121, &ppc_fmsubsdot}, {122, &ppc_fmadds}, {123, &ppc_fmadds}, + {124, &ppc_fnmsubs}, {125, &ppc_fnmsubsdot},{126, &ppc_fnmadds}, {127, &ppc_fnmaddsdot}, + {178, &ppc_fmults}, {179, &ppc_fmultsdot}, + {184, &ppc_fmsubs}, {185, &ppc_fmsubsdot}, {186, &ppc_fmadds}, {187, &ppc_fmaddsdot}, + {188, &ppc_fnmsubs},{189, &ppc_fnmsubsdot}, {190, &ppc_fnmadds},{191, &ppc_fnmaddsdot}, + {242, &ppc_fmults}, {243, &ppc_fmultsdot}, + {248, &ppc_fmsubs}, {249, &ppc_fmsubsdot}, {250, &ppc_fmadds}, {251, &ppc_fmaddsdot}, + {252, &ppc_fnmsubs},{253, &ppc_fnmsubsdot}, {254, &ppc_fnmadds},{255, &ppc_fnmaddsdot}, + {306, &ppc_fmults}, {307, &ppc_fmultsdot}, + {312, &ppc_fmsubs}, {313, &ppc_fmsubsdot}, {314, &ppc_fmadds}, {315, &ppc_fmaddsdot}, + {316, &ppc_fnmsubs},{317, &ppc_fnmsubsdot},{318, &ppc_fnmadds},{319, &ppc_fnmaddsdot}, + {370, &ppc_fmults}, {371, &ppc_fmultsdot}, + {376, &ppc_fmsubs}, {377, &ppc_fmsubsdot}, {378, &ppc_fmadds}, {379, &ppc_fmaddsdot}, + {380, &ppc_fnmsubs},{381, &ppc_fnmsubsdot},{382, &ppc_fnmadds},{383, &ppc_fnmaddsdot}, + {434, &ppc_fmults}, {435, &ppc_fmultsdot}, + {440, &ppc_fmsubs}, {441, &ppc_fmsubsdot}, {442, &ppc_fmadds}, {443, &ppc_fmaddsdot}, + {444, &ppc_fnmsubs},{445, &ppc_fnmsubsdot},{446, &ppc_fnmadds},{447, &ppc_fnmaddsdot}, + {498, &ppc_fmults}, {499, &ppc_fmultsdot}, + {504, &ppc_fmsubs}, {505, &ppc_fmsubsdot}, {506, &ppc_fmadds}, {507, &ppc_fmaddsdot}, + {508, &ppc_fnmsubs},{509, &ppc_fnmsubsdot},{510, &ppc_fnmadds},{511, &ppc_fnmaddsdot}, + {562, &ppc_fmults}, {563, &ppc_fmultsdot}, + {568, &ppc_fmsubs}, {569, &ppc_fmsubsdot}, {570, &ppc_fmadds}, {571, &ppc_fmaddsdot}, + {572, &ppc_fnmsubs},{573, &ppc_fnmsubsdot},{574, &ppc_fnmadds},{575, &ppc_fnmaddsdot}, + {626, &ppc_fmults}, {627, &ppc_fmultsdot}, + {632, &ppc_fmsubs}, {633, &ppc_fmsubsdot}, {634, &ppc_fmadds}, {635, &ppc_fmaddsdot}, + {636, &ppc_fnmsubs},{637, &ppc_fnmsubsdot},{638, &ppc_fnmadds},{639, &ppc_fnmaddsdot}, + {690, &ppc_fmults}, {691, &ppc_fmultsdot}, + {696, &ppc_fmsubs}, {697, &ppc_fmsubsdot}, {698, &ppc_fmadds}, {699, &ppc_fmaddsdot}, + {700, &ppc_fnmsubs},{701, &ppc_fnmsubsdot},{702, &ppc_fnmadds},{703, &ppc_fnmaddsdot}, + {754, &ppc_fmults}, {755, &ppc_fmultsdot}, + {760, &ppc_fmsubs}, {761, &ppc_fmsubsdot}, {762, &ppc_fmadds}, {763, &ppc_fmaddsdot}, + {764, &ppc_fnmsubs},{765, &ppc_fnmsubsdot},{766, &ppc_fnmadds},{767, &ppc_fnmaddsdot}, + {818, &ppc_fmults}, {819, &ppc_fmultsdot}, + {824, &ppc_fmsubs}, {825, &ppc_fmsubsdot}, {826, &ppc_fmadds}, {827, &ppc_fmaddsdot}, + {828, &ppc_fnmsubs},{829, &ppc_fnmsubsdot},{830, &ppc_fnmadds},{831, &ppc_fnmaddsdot}, + {882, &ppc_fmults}, {883, &ppc_fmultsdot}, + {888, &ppc_fmsubs}, {889, &ppc_fmsubsdot}, {890, &ppc_fmadds}, {891, &ppc_fmaddsdot}, + {892, &ppc_fnmsubs},{893, &ppc_fnmsubsdot},{894, &ppc_fnmadds},{895, &ppc_fnmaddsdot}, + {946, &ppc_fmults}, {947, &ppc_fmultsdot}, + {952, &ppc_fmsubs}, {953, &ppc_fmsubsdot}, {954, &ppc_fmadds}, {955, &ppc_fmaddsdot}, + {957, &ppc_fnmsubs},{958, &ppc_fnmsubsdot},{958, &ppc_fnmadds},{959, &ppc_fnmaddsdot}, + {1010, &ppc_fmults}, {1011, &ppc_fmultsdot}, + {1016, &ppc_fmsubs}, {1017, &ppc_fmsubsdot}, {1018, &ppc_fmadds}, {1019, &ppc_fmaddsdot}, + {1020, &ppc_fnmsubs},{1021, &ppc_fnmsubsdot},{1022, &ppc_fnmadds},{1023, &ppc_fnmaddsdot}, + {1074, &ppc_fmults}, {1075, &ppc_fmultsdot}, + {1080, &ppc_fmsubs}, {1081, &ppc_fmsubsdot}, {1082, &ppc_fmadds}, {1083, &ppc_fmaddsdot}, + {1084, &ppc_fnmsubs},{1085, &ppc_fnmsubsdot},{1086, &ppc_fnmadds},{1087, &ppc_fnmaddsdot}, + {1138, &ppc_fmults}, {1139, &ppc_fmultsdot}, + {1144, &ppc_fmsubs}, {1145, &ppc_fmsubsdot}, {1146, &ppc_fmadds}, {1147, &ppc_fmaddsdot}, + {1148, &ppc_fnmsubs},{1149, &ppc_fnmsubsdot},{1150, &ppc_fnmadds},{1151, &ppc_fnmaddsdot}, + {1202, &ppc_fmults}, {1203, &ppc_fmultsdot}, + {1208, &ppc_fmsubs}, {1209, &ppc_fmsubsdot}, {1210, &ppc_fmadds}, {1211, &ppc_fmaddsdot}, + {1212, &ppc_fnmsubs},{1213, &ppc_fnmsubsdot},{1214, &ppc_fnmadds},{1215, &ppc_fnmaddsdot}, + {1266, &ppc_fmults}, {1267, &ppc_fmultsdot}, + {1272, &ppc_fmsubs}, {1273, &ppc_fmsubsdot}, {1274, &ppc_fmadds}, {1275, &ppc_fmaddsdot}, + {1276, &ppc_fnmsubs},{1277, &ppc_fnmsubsdot},{1278, &ppc_fnmadds},{1279, &ppc_fnmaddsdot}, + {1330, &ppc_fmults}, {1331, &ppc_fmultsdot}, + {1336, &ppc_fmsubs}, {1337, &ppc_fmsubsdot}, {1338, &ppc_fmadds}, {1339, &ppc_fmaddsdot}, + {1340, &ppc_fnmsubs},{1341, &ppc_fnmsubsdot},{1342, &ppc_fnmadds},{1343, &ppc_fnmaddsdot}, + {1394, &ppc_fmults}, {1395, &ppc_fmultsdot}, + {1400, &ppc_fmsubs}, {1401, &ppc_fmsubsdot}, {1402, &ppc_fmadds}, {1403, &ppc_fmaddsdot}, + {1404, &ppc_fnmsubs},{1405, &ppc_fnmsubsdot},{1406, &ppc_fnmadds},{1407, &ppc_fnmaddsdot}, + {1458, &ppc_fmults}, {1459, &ppc_fmultsdot}, + {1464, &ppc_fmsubs}, {1465, &ppc_fmsubsdot}, {1466, &ppc_fmadds}, {1467, &ppc_fmaddsdot}, + {1468, &ppc_fnmsubs},{1469, &ppc_fnmsubsdot},{1470, &ppc_fnmadds},{1471, &ppc_fnmaddsdot}, + {1522, &ppc_fmults}, {1523, &ppc_fmultsdot}, + {1528, &ppc_fmsubs}, {1529, &ppc_fmsubsdot}, {1530, &ppc_fmadds}, {1531, &ppc_fmaddsdot}, + {1532, &ppc_fnmsubs},{1533, &ppc_fnmsubsdot},{1534, &ppc_fnmadds},{1535, &ppc_fnmaddsdot}, + {1586, &ppc_fmults}, {1587, &ppc_fmultsdot}, + {1592, &ppc_fmsubs}, {1593, &ppc_fmsubsdot}, {1594, &ppc_fmadds}, {1595, &ppc_fmaddsdot}, + {1596, &ppc_fnmsubs},{1597, &ppc_fnmsubsdot},{1598, &ppc_fnmadds},{1599, &ppc_fnmaddsdot}, + {1650, &ppc_fmults}, {1651, &ppc_fmultsdot}, + {1656, &ppc_fmsubs}, {1657, &ppc_fmsubsdot}, {1658, &ppc_fmadds}, {1659, &ppc_fmaddsdot}, + {1660, &ppc_fnmsubs},{1661, &ppc_fnmsubsdot},{1662, &ppc_fnmadds},{1663, &ppc_fnmaddsdot}, + {1714, &ppc_fmults}, {1715, &ppc_fmultsdot}, + {1720, &ppc_fmsubs}, {1721, &ppc_fmsubsdot}, {1722, &ppc_fmadds}, {1723, &ppc_fmaddsdot}, + {1724, &ppc_fnmsubs},{1725, &ppc_fnmsubsdot},{1726, &ppc_fnmadds},{1727, &ppc_fnmaddsdot}, + {1778, &ppc_fmults}, {1779, &ppc_fmultsdot}, + {1784, &ppc_fmsubs}, {1785, &ppc_fmsubsdot}, {1786, &ppc_fmadds}, {1787, &ppc_fmaddsdot}, + {1788, &ppc_fnmsubs},{1789, &ppc_fnmsubsdot},{1790, &ppc_fnmadds},{1791, &ppc_fnmaddsdot}, + {1842, &ppc_fmults}, {1843, &ppc_fmultsdot}, + {1848, &ppc_fmsubs}, {1849, &ppc_fmsubsdot}, {1850, &ppc_fmadds}, {1851, &ppc_fmaddsdot}, + {1852, &ppc_fnmsubs},{1853, &ppc_fnmsubsdot},{1854, &ppc_fnmadds},{1855, &ppc_fnmaddsdot}, + {1906, &ppc_fmults}, {1907, &ppc_fmultsdot}, + {1912, &ppc_fmsubs}, {1913, &ppc_fmsubsdot}, {1914, &ppc_fmadds}, {1915, &ppc_fmaddsdot}, + {1916, &ppc_fnmsubs},{1917, &ppc_fnmsubsdot},{1918, &ppc_fnmadds},{1919, &ppc_fnmaddsdot}, + {1970, &ppc_fmults}, {1971, &ppc_fmultsdot}, + {1976, &ppc_fmsubs}, {1977, &ppc_fmsubsdot}, {1978, &ppc_fmadds}, {1979, &ppc_fmaddsdot}, + {1980, &ppc_fnmsubs},{1981, &ppc_fnmsubsdot},{1982, &ppc_fnmadds},{1983, &ppc_fnmaddsdot}, + {2034, &ppc_fmults}, {2035, &ppc_fmultsdot}, + {2040, &ppc_fmsubs}, {2041, &ppc_fmsubsdot}, {2042, &ppc_fmadds}, {2043, &ppc_fmaddsdot}, + {2044, &ppc_fnmsubs},{2045, &ppc_fnmsubsdot},{2046, &ppc_fnmadds},{2047, &ppc_fnmaddsdot} + }; + static std::map SubOpcode63Grabber= - {{0, &ppc_fcmpu}, {24, &ppc_frsp}, {28, &ppc_fctiw}, {30, &ppc_fctiwz}, {36, &ppc_fdiv}, - {40, &ppc_fsub}, {42, &ppc_fadd}, {44, &ppc_fsqrt}, {50, &ppc_fmult}, - {52, &ppc_frsqrte}, {56, &ppc_fmsub}, {58, &ppc_fmadd}, {60, &ppc_fnmsub}, - {62, &ppc_fnmadd}, {64, &ppc_fcmpo}, {76, &ppc_mtfsb1}, {77, &ppc_mtfsb1dot}, {80, &ppc_fneg}, - {114, &ppc_fmult}, {120, &ppc_fmsub}, {122, &ppc_fmadd}, {124, &ppc_fnmsub}, {126, &ppc_fnmadd}, - {128, &ppc_mcrfs}, {140, &ppc_mtfsb0}, {141, &ppc_mtfsb0dot},{144, &ppc_fmr}, - {178, &ppc_fmult}, {184, &ppc_fmsub}, {186, &ppc_fmadd}, {188, &ppc_fnmsub}, {190, &ppc_fnmadd}, - {242, &ppc_fmult}, {248, &ppc_fmsub}, {250, &ppc_fmadd}, {252, &ppc_fnmsub}, {254, &ppc_fnmadd}, - {306, &ppc_fmult}, {312, &ppc_fmsub}, {314, &ppc_fmadd}, {316, &ppc_fnmsub}, {318, &ppc_fnmadd}, - {370, &ppc_fmult}, {376, &ppc_fmsub}, {378, &ppc_fmadd}, {380, &ppc_fnmsub}, {382, &ppc_fnmadd}, - {434, &ppc_fmult}, {440, &ppc_fmsub}, {442, &ppc_fmadd}, {444, &ppc_fnmsub}, {446, &ppc_fnmadd}, - {498, &ppc_fmult}, {504, &ppc_fmsub}, {506, &ppc_fmadd}, {508, &ppc_fnmsub}, {510, &ppc_fnmadd}, - {528, &ppc_fabs}, - {562, &ppc_fmult}, {568, &ppc_fmsub}, {570, &ppc_fmadd}, {572, &ppc_fnmsub}, {574, &ppc_fnmadd}, - {626, &ppc_fmult}, {632, &ppc_fmsub}, {634, &ppc_fmadd}, {636, &ppc_fnmsub}, {638, &ppc_fnmadd}, - {690, &ppc_fmult}, {696, &ppc_fmsub}, {698, &ppc_fmadd}, {700, &ppc_fnmsub}, {702, &ppc_fnmadd}, - {754, &ppc_fmult}, {752, &ppc_fmsub}, {754, &ppc_fmadd}, {764, &ppc_fnmsub}, {766, &ppc_fnmadd}, - {818, &ppc_fmult}, {824, &ppc_fmsub}, {826, &ppc_fmadd}, {828, &ppc_fnmsub}, {830, &ppc_fnmadd}, - {882, &ppc_fmult}, {888, &ppc_fmsub}, {890, &ppc_fmadd}, {892, &ppc_fnmsub}, {894, &ppc_fnmadd}, - {946, &ppc_fmult}, {952, &ppc_fmsub}, {954, &ppc_fmadd}, {956, &ppc_fnmsub}, {958, &ppc_fnmadd}, - {1010, &ppc_fmult}, {1016, &ppc_fmsub}, {1018, &ppc_fmadd}, {1020, &ppc_fnmsub}, {1022, &ppc_fnmadd}, - {1074, &ppc_fmult}, {1080, &ppc_fmsub}, {1082, &ppc_fmadd}, {1084, &ppc_fnmsub}, {1086, &ppc_fnmadd}, - {1138, &ppc_fmult}, {1144, &ppc_fmsub}, {1146, &ppc_fmadd}, {1148, &ppc_fnmsub}, {1150, &ppc_fnmadd}, - {1166, &ppc_mffs}, - {1202, &ppc_fmult}, {1208, &ppc_fmsub}, {1210, &ppc_fmadd}, {1212, &ppc_fnmsub}, {1214, &ppc_fnmadd}, - {1266, &ppc_fmult}, {1272, &ppc_fmsub}, {1274, &ppc_fmadd}, {1276, &ppc_fnmsub}, {1278, &ppc_fnmadd}, - {1330, &ppc_fmult}, {1336, &ppc_fmsub}, {1338, &ppc_fmadd}, {1340, &ppc_fnmsub}, {1342, &ppc_fnmadd}, - {1394, &ppc_fmult}, {1400, &ppc_fmsub}, {1402, &ppc_fmadd}, {1404, &ppc_fnmsub}, {1406, &ppc_fnmadd}, - {1422, &ppc_mtfsf}, - {1458, &ppc_fmult}, {1464, &ppc_fmsub}, {1466, &ppc_fmadd}, {1468, &ppc_fnmsub}, {1470, &ppc_fnmadd}, - {1522, &ppc_fmult}, {1528, &ppc_fmsub}, {1530, &ppc_fmadd}, {1532, &ppc_fnmsub}, {1534, &ppc_fnmadd}, - {1586, &ppc_fmult}, {1592, &ppc_fmsub}, {1594, &ppc_fmadd}, {1596, &ppc_fnmsub}, {1598, &ppc_fnmadd}, - {1650, &ppc_fmult}, {1656, &ppc_fmsub}, {1658, &ppc_fmadd}, {1660, &ppc_fnmsub}, {1662, &ppc_fnmadd}, - {1714, &ppc_fmult}, {1720, &ppc_fmsub}, {1722, &ppc_fmadd}, {1724, &ppc_fnmsub}, {1726, &ppc_fnmadd}, - {1778, &ppc_fmult}, {1784, &ppc_fmsub}, {1786, &ppc_fmadd}, {1788, &ppc_fnmsub}, {1790, &ppc_fnmadd}, - {1842, &ppc_fmult}, {1848, &ppc_fmsub}, {1850, &ppc_fmadd}, {1852, &ppc_fnmsub}, {1854, &ppc_fnmadd}, - {1906, &ppc_fmult}, {1912, &ppc_fmsub}, {1914, &ppc_fmadd}, {1916, &ppc_fnmsub}, {1918, &ppc_fnmadd}, - {1970, &ppc_fmult}, {1976, &ppc_fmsub}, {1978, &ppc_fmadd}, {1980, &ppc_fnmsub}, {1982, &ppc_fnmadd}, - {2034, &ppc_fmult}, {2040, &ppc_fmsub}, {2042, &ppc_fmadd}, {2044, &ppc_fnmsub}, {2046, &ppc_fnmadd} + {{0, &ppc_fcmpu}, {24, &ppc_frsp}, {25, &ppc_frspdot}, + {28, &ppc_fctiw}, {29, &ppc_fctiwdot}, {30, &ppc_fctiwz}, {31, &ppc_fctiwzdot}, + {36, &ppc_fdiv}, {37, &ppc_fdivdot}, {40, &ppc_fsub}, {41, &ppc_fsubdot}, + {42, &ppc_fadd}, {43, &ppc_fadddot}, {44, &ppc_fsqrt}, {45, &ppc_fsqrtdot}, + {46, &ppc_fsel}, {47, &ppc_fseldot}, {50, &ppc_fmult}, {51, &ppc_fmultdot}, + {52, &ppc_frsqrte}, {53, &ppc_frsqrtedot},{56, &ppc_fmsub}, {57, &ppc_fmsubdot}, + {58, &ppc_fmadd}, {59, &ppc_fmadddot}, {60, &ppc_fnmsub},{61, &ppc_fnmsubdot}, + {62, &ppc_fnmadd}, {63, &ppc_fnmadddot}, {64, &ppc_fcmpo}, {76, &ppc_mtfsb1}, + {77, &ppc_mtfsb1dot}, {80, &ppc_fneg}, {81, &ppc_fnegdot}, + {110, &ppc_fsel}, {111, &ppc_fseldot}, {114, &ppc_fmult}, {115, &ppc_fmultdot}, + {120, &ppc_fmsub}, {121, &ppc_fmsubdot}, {122, &ppc_fmadd}, {123, &ppc_fmadd}, + {124, &ppc_fnmsub}, {125, &ppc_fnmsubdot},{126, &ppc_fnmadd}, {127, &ppc_fnmadddot}, + {128, &ppc_mcrfs}, {140, &ppc_mtfsb0}, {141, &ppc_mtfsb0dot},{144, &ppc_fmr}, + {174, &ppc_fsel}, {175, &ppc_fseldot}, {178, &ppc_fmult}, {179, &ppc_fmultdot}, + {184, &ppc_fmsub}, {185, &ppc_fmsubdot}, {186, &ppc_fmadd}, {187, &ppc_fmadddot}, + {188, &ppc_fnmsub},{189, &ppc_fnmsubdot}, {190, &ppc_fnmadd},{191, &ppc_fnmadddot}, + {238, &ppc_fsel}, {239, &ppc_fseldot}, {242, &ppc_fmult}, {243, &ppc_fmultdot}, + {248, &ppc_fmsub}, {249, &ppc_fmsubdot}, {250, &ppc_fmadd}, {251, &ppc_fmadddot}, + {252, &ppc_fnmsub},{253, &ppc_fnmsubdot}, {254, &ppc_fnmadd},{255, &ppc_fnmadddot}, + {272, &ppc_fnabs}, {273, &ppc_fnabsdot}, + {302, &ppc_fsel}, {303, &ppc_fseldot}, {306, &ppc_fmult}, {307, &ppc_fmultdot}, + {312, &ppc_fmsub}, {313, &ppc_fmsubdot}, {314, &ppc_fmadd}, {315, &ppc_fmadddot}, + {316, &ppc_fnmsub},{317, &ppc_fnmsubdot},{318, &ppc_fnmadd},{319, &ppc_fnmadddot}, + {366, &ppc_fsel}, {367, &ppc_fseldot}, {370, &ppc_fmult}, {371, &ppc_fmultdot}, + {376, &ppc_fmsub}, {377, &ppc_fmsubdot}, {378, &ppc_fmadd}, {379, &ppc_fmadddot}, + {380, &ppc_fnmsub},{381, &ppc_fnmsubdot},{382, &ppc_fnmadd},{383, &ppc_fnmadddot}, + {430, &ppc_fsel}, {431, &ppc_fseldot}, {434, &ppc_fmult}, {435, &ppc_fmultdot}, + {440, &ppc_fmsub}, {441, &ppc_fmsubdot}, {442, &ppc_fmadd}, {443, &ppc_fmadddot}, + {444, &ppc_fnmsub},{445, &ppc_fnmsubdot},{446, &ppc_fnmadd},{447, &ppc_fnmadddot}, + {494, &ppc_fsel}, {495, &ppc_fseldot}, {498, &ppc_fmult}, {499, &ppc_fmultdot}, + {504, &ppc_fmsub}, {505, &ppc_fmsubdot}, {506, &ppc_fmadd}, {507, &ppc_fmadddot}, + {508, &ppc_fnmsub},{509, &ppc_fnmsubdot},{510, &ppc_fnmadd},{511, &ppc_fnmadddot}, + {528, &ppc_fabs}, {529, &ppc_fabsdot}, + {558, &ppc_fsel}, {559, &ppc_fseldot}, {562, &ppc_fmult}, {563, &ppc_fmultdot}, + {568, &ppc_fmsub}, {569, &ppc_fmsubdot}, {570, &ppc_fmadd}, {571, &ppc_fmadddot}, + {572, &ppc_fnmsub},{573, &ppc_fnmsubdot},{574, &ppc_fnmadd},{575, &ppc_fnmadddot}, + {622, &ppc_fsel}, {623, &ppc_fseldot}, {626, &ppc_fmult}, {627, &ppc_fmultdot}, + {632, &ppc_fmsub}, {633, &ppc_fmsubdot}, {634, &ppc_fmadd}, {635, &ppc_fmadddot}, + {636, &ppc_fnmsub},{637, &ppc_fnmsubdot},{638, &ppc_fnmadd},{639, &ppc_fnmadddot}, + {686, &ppc_fsel}, {687, &ppc_fseldot}, {690, &ppc_fmult}, {691, &ppc_fmultdot}, + {696, &ppc_fmsub}, {697, &ppc_fmsubdot}, {698, &ppc_fmadd}, {699, &ppc_fmadddot}, + {700, &ppc_fnmsub},{701, &ppc_fnmsubdot},{702, &ppc_fnmadd},{703, &ppc_fnmadddot}, + {750, &ppc_fsel}, {751, &ppc_fseldot}, {754, &ppc_fmult}, {755, &ppc_fmultdot}, + {760, &ppc_fmsub}, {761, &ppc_fmsubdot}, {762, &ppc_fmadd}, {763, &ppc_fmadddot}, + {764, &ppc_fnmsub},{765, &ppc_fnmsubdot},{766, &ppc_fnmadd},{767, &ppc_fnmadddot}, + {814, &ppc_fsel}, {815, &ppc_fseldot}, {818, &ppc_fmult}, {819, &ppc_fmultdot}, + {824, &ppc_fmsub}, {825, &ppc_fmsubdot}, {826, &ppc_fmadd}, {827, &ppc_fmadddot}, + {828, &ppc_fnmsub},{829, &ppc_fnmsubdot},{830, &ppc_fnmadd},{831, &ppc_fnmadddot}, + {878, &ppc_fsel}, {879, &ppc_fseldot}, {882, &ppc_fmult}, {883, &ppc_fmultdot}, + {888, &ppc_fmsub}, {889, &ppc_fmsubdot}, {890, &ppc_fmadd}, {891, &ppc_fmadddot}, + {892, &ppc_fnmsub},{893, &ppc_fnmsubdot},{894, &ppc_fnmadd},{895, &ppc_fnmadddot}, + {942, &ppc_fsel}, {943, &ppc_fseldot}, {946, &ppc_fmult}, {947, &ppc_fmultdot}, + {952, &ppc_fmsub}, {953, &ppc_fmsubdot}, {954, &ppc_fmadd}, {955, &ppc_fmadddot}, + {957, &ppc_fnmsub},{958, &ppc_fnmsubdot},{958, &ppc_fnmadd},{959, &ppc_fnmadddot}, + {1006, &ppc_fsel}, {1007, &ppc_fseldot}, {1010, &ppc_fmult}, {1011, &ppc_fmultdot}, + {1016, &ppc_fmsub}, {1017, &ppc_fmsubdot}, {1018, &ppc_fmadd}, {1019, &ppc_fmadddot}, + {1020, &ppc_fnmsub},{1021, &ppc_fnmsubdot},{1022, &ppc_fnmadd},{1023, &ppc_fnmadddot}, + {1070, &ppc_fsel}, {1071, &ppc_fseldot}, {1074, &ppc_fmult}, {1075, &ppc_fmultdot}, + {1080, &ppc_fmsub}, {1081, &ppc_fmsubdot}, {1082, &ppc_fmadd}, {1083, &ppc_fmadddot}, + {1084, &ppc_fnmsub},{1085, &ppc_fnmsubdot},{1086, &ppc_fnmadd},{1087, &ppc_fnmadddot}, + {1134, &ppc_fsel}, {1135, &ppc_fseldot}, {1138, &ppc_fmult}, {1139, &ppc_fmultdot}, + {1144, &ppc_fmsub}, {1145, &ppc_fmsubdot}, {1146, &ppc_fmadd}, {1147, &ppc_fmadddot}, + {1148, &ppc_fnmsub},{1149, &ppc_fnmsubdot},{1150, &ppc_fnmadd},{1151, &ppc_fnmadddot}, + {1166, &ppc_mffs}, {1167, &ppc_mffsdot}, + {1198, &ppc_fsel}, {1199, &ppc_fseldot}, {1202, &ppc_fmult}, {1203, &ppc_fmultdot}, + {1208, &ppc_fmsub}, {1209, &ppc_fmsubdot}, {1210, &ppc_fmadd}, {1211, &ppc_fmadddot}, + {1212, &ppc_fnmsub},{1213, &ppc_fnmsubdot},{1214, &ppc_fnmadd},{1215, &ppc_fnmadddot}, + {1262, &ppc_fsel}, {1263, &ppc_fseldot}, {1266, &ppc_fmult}, {1267, &ppc_fmultdot}, + {1272, &ppc_fmsub}, {1273, &ppc_fmsubdot}, {1274, &ppc_fmadd}, {1275, &ppc_fmadddot}, + {1276, &ppc_fnmsub},{1277, &ppc_fnmsubdot},{1278, &ppc_fnmadd},{1279, &ppc_fnmadddot}, + {1326, &ppc_fsel}, {1327, &ppc_fseldot}, {1330, &ppc_fmult}, {1331, &ppc_fmultdot}, + {1336, &ppc_fmsub}, {1337, &ppc_fmsubdot}, {1338, &ppc_fmadd}, {1339, &ppc_fmadddot}, + {1340, &ppc_fnmsub},{1341, &ppc_fnmsubdot},{1342, &ppc_fnmadd},{1343, &ppc_fnmadddot}, + {1390, &ppc_fsel}, {1391, &ppc_fseldot}, {1394, &ppc_fmult}, {1395, &ppc_fmultdot}, + {1400, &ppc_fmsub}, {1401, &ppc_fmsubdot}, {1402, &ppc_fmadd}, {1403, &ppc_fmadddot}, + {1404, &ppc_fnmsub},{1405, &ppc_fnmsubdot},{1406, &ppc_fnmadd},{1407, &ppc_fnmadddot}, + {1422, &ppc_mtfsf}, {1423, &ppc_mtfsfdot}, + {1454, &ppc_fsel}, {1455, &ppc_fseldot}, {1458, &ppc_fmult}, {1459, &ppc_fmultdot}, + {1464, &ppc_fmsub}, {1465, &ppc_fmsubdot}, {1466, &ppc_fmadd}, {1467, &ppc_fmadddot}, + {1468, &ppc_fnmsub},{1469, &ppc_fnmsubdot},{1470, &ppc_fnmadd},{1471, &ppc_fnmadddot}, + {1518, &ppc_fsel}, {1519, &ppc_fseldot}, {1522, &ppc_fmult}, {1523, &ppc_fmultdot}, + {1528, &ppc_fmsub}, {1529, &ppc_fmsubdot}, {1530, &ppc_fmadd}, {1531, &ppc_fmadddot}, + {1532, &ppc_fnmsub},{1533, &ppc_fnmsubdot},{1534, &ppc_fnmadd},{1535, &ppc_fnmadddot}, + {1582, &ppc_fsel}, {1583, &ppc_fseldot}, {1586, &ppc_fmult}, {1587, &ppc_fmultdot}, + {1592, &ppc_fmsub}, {1593, &ppc_fmsubdot}, {1594, &ppc_fmadd}, {1595, &ppc_fmadddot}, + {1596, &ppc_fnmsub},{1597, &ppc_fnmsubdot},{1598, &ppc_fnmadd},{1599, &ppc_fnmadddot}, + {1646, &ppc_fsel}, {1647, &ppc_fseldot}, {1650, &ppc_fmult}, {1651, &ppc_fmultdot}, + {1656, &ppc_fmsub}, {1657, &ppc_fmsubdot}, {1658, &ppc_fmadd}, {1659, &ppc_fmadddot}, + {1660, &ppc_fnmsub},{1661, &ppc_fnmsubdot},{1662, &ppc_fnmadd},{1663, &ppc_fnmadddot}, + {1710, &ppc_fsel}, {1711, &ppc_fseldot}, {1714, &ppc_fmult}, {1715, &ppc_fmultdot}, + {1720, &ppc_fmsub}, {1721, &ppc_fmsubdot}, {1722, &ppc_fmadd}, {1723, &ppc_fmadddot}, + {1724, &ppc_fnmsub},{1725, &ppc_fnmsubdot},{1726, &ppc_fnmadd},{1727, &ppc_fnmadddot}, + {1774, &ppc_fsel}, {1775, &ppc_fseldot}, {1778, &ppc_fmult}, {1779, &ppc_fmultdot}, + {1784, &ppc_fmsub}, {1785, &ppc_fmsubdot}, {1786, &ppc_fmadd}, {1787, &ppc_fmadddot}, + {1788, &ppc_fnmsub},{1789, &ppc_fnmsubdot},{1790, &ppc_fnmadd},{1791, &ppc_fnmadddot}, + {1838, &ppc_fsel}, {1839, &ppc_fseldot}, {1842, &ppc_fmult}, {1843, &ppc_fmultdot}, + {1848, &ppc_fmsub}, {1849, &ppc_fmsubdot}, {1850, &ppc_fmadd}, {1851, &ppc_fmadddot}, + {1852, &ppc_fnmsub},{1853, &ppc_fnmsubdot},{1854, &ppc_fnmadd},{1855, &ppc_fnmadddot}, + {1902, &ppc_fsel}, {1903, &ppc_fseldot}, {1906, &ppc_fmult}, {1907, &ppc_fmultdot}, + {1912, &ppc_fmsub}, {1913, &ppc_fmsubdot}, {1914, &ppc_fmadd}, {1915, &ppc_fmadddot}, + {1916, &ppc_fnmsub},{1917, &ppc_fnmsubdot},{1918, &ppc_fnmadd},{1919, &ppc_fnmadddot}, + {1966, &ppc_fsel}, {1967, &ppc_fseldot}, {1970, &ppc_fmult}, {1971, &ppc_fmultdot}, + {1976, &ppc_fmsub}, {1977, &ppc_fmsubdot}, {1978, &ppc_fmadd}, {1979, &ppc_fmadddot}, + {1980, &ppc_fnmsub},{1981, &ppc_fnmsubdot},{1982, &ppc_fnmadd},{1983, &ppc_fnmadddot}, + {2030, &ppc_fsel}, {2031, &ppc_fseldot}, {2034, &ppc_fmult}, {2035, &ppc_fmultdot}, + {2040, &ppc_fmsub}, {2041, &ppc_fmsubdot}, {2042, &ppc_fmadd}, {2043, &ppc_fmadddot}, + {2044, &ppc_fnmsub},{2045, &ppc_fnmsubdot},{2046, &ppc_fnmadd},{2047, &ppc_fnmadddot} }; diff --git a/ppcfpopcodes.cpp b/ppcfpopcodes.cpp index 7f8679f..026eb26 100644 --- a/ppcfpopcodes.cpp +++ b/ppcfpopcodes.cpp @@ -16,6 +16,7 @@ #include #include "ppcemumain.h" #include "ppcmemory.h" +#include #include #include @@ -109,6 +110,107 @@ void ppc_grab_regsfpdabc(){ ppc_result64_c = ppc_state.ppc_fpr[reg_c]; } +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){ + ppc_state.ppc_fpscr |= 0x200000; + } + + } + +} + +void 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; + } + else if ((input_a == 0) & (input_b == 0)){ + ppc_state.ppc_fpscr |= 0x80200000; + } + break; + case 40: + if ((exp_a == 0xff) & (exp_b == 0xff)){ + ppc_state.ppc_fpscr |= 0x80800000; + } + break; + case 50: + if (((exp_a == 0xff) & (input_b == 0)) | ((exp_b == 0xff) & (input_a == 0))){ + ppc_state.ppc_fpscr |= 0x80100000; + } + break; + } + } + 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; + } + else if ((input_a == 0) & (input_b == 0)){ + ppc_state.ppc_fpscr |= 0x80200000; + } + break; + case 40: + if ((exp_a == 0x7ff) & (exp_b == 0x7ff)){ + ppc_state.ppc_fpscr |= 0x80800000; + } + break; + case 50: + if (((exp_a == 0x7ff) & (input_b == 0)) | ((exp_b == 0x7ff) & (input_a == 0))){ + ppc_state.ppc_fpscr |= 0x80100000; + } + break; + } + } +} + +void ppc_fpresult_update(uint64_t set_result, bool confirm_arc){ + + bool confirm_ov = (bool)std::fetestexcept(FE_OVERFLOW); + + if (confirm_ov){ + ppc_state.ppc_fpscr |= 0x80001000; + } + + if (confirm_arc){ + ppc_state.ppc_fpscr |= 0x80010000; + ppc_state.ppc_fpscr &= 0xFFFF0FFF; + + if (set_result < 0){ + ppc_state.ppc_fpscr |= 0x8000; + } + else if (set_result > 0){ + ppc_state.ppc_fpscr |= 0x4000; + } + else if (set_result == 0){ + ppc_state.ppc_fpscr |= 0x2000; + } + else{ + ppc_state.ppc_fpscr |= 0x1000; + } + } +} + +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(); @@ -121,6 +223,18 @@ void ppc_fadd(){ ppc_store_dfpresult(); } +void ppc_fadddot(){ + ppc_grab_regsfpdab(); + double testd1 = (double)ppc_result64_a; + double testd2 = (double)ppc_result64_b; + + 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; @@ -132,15 +246,16 @@ void ppc_fsub(){ ppc_store_dfpresult(); } -void ppc_fmult(){ - ppc_grab_regsfpdac(); +void ppc_fsubdot(){ + ppc_grab_regsfpdab(); double testd1 = (double)ppc_result64_a; - double testd2 = (double)ppc_result64_c; + double testd2 = (double)ppc_result64_b; - double testd3 = testd1 * testd2; + double testd3 = testd1 - testd2; ppc_result64_d = (uint64_t)testd3; ppc_store_dfpresult(); + ppc_changecrf1(); } void ppc_fdiv(){ @@ -154,54 +269,153 @@ void ppc_fdiv(){ 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; + + ppc_result64_d = (uint64_t)testd3; + 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; + + ppc_result64_d = (uint64_t)testd3; + 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; + + ppc_result64_d = (uint64_t)testd3; + 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) + testd2; + double testd4 = (testd1 * testd3); + testd4 += testd2; ppc_result64_d = (uint64_t)testd4; 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; + + ppc_result64_d = (uint64_t)testd4; + 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) - testd2; + double testd4 = (testd1 * testd3); + testd4 -= testd2; ppc_result64_d = (uint64_t)testd4; 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; + + ppc_result64_d = (uint64_t)testd4; + 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) + testd2); + double testd4 = (testd1 * testd3); + testd4 += testd2; + testd4 = -testd4; ppc_result64_d = (uint64_t)testd4; 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; + + ppc_result64_d = (uint64_t)testd4; + 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) - testd2); + double testd4 = (testd1 * testd3); + testd4 -= testd2; + testd4 = -testd4; ppc_result64_d = (uint64_t)testd4; 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; + + ppc_result64_d = (uint64_t)testd4; + ppc_store_dfpresult(); + ppc_changecrf1(); +} + void ppc_fadds(){ ppc_grab_regsfpdab(); float testd1 = (float)ppc_result64_a; @@ -213,6 +427,18 @@ void ppc_fadds(){ ppc_store_dfpresult(); } +void ppc_faddsdot(){ + ppc_grab_regsfpdab(); + float testd1 = (float)ppc_result64_a; + float testd2 = (float)ppc_result64_b; + + float testd3 = testd1 + testd2; + + ppc_result64_d = (uint64_t)testd3; + ppc_store_dfpresult(); + ppc_changecrf1(); +} + void ppc_fsubs(){ ppc_grab_regsfpdab(); float testd1 = (float)ppc_result64_a; @@ -224,6 +450,18 @@ void ppc_fsubs(){ ppc_store_dfpresult(); } +void ppc_fsubsdot(){ + ppc_grab_regsfpdab(); + float testd1 = (float)ppc_result64_a; + float testd2 = (float)ppc_result64_b; + + float testd3 = testd1 - testd2; + + ppc_result64_d = (uint64_t)testd3; + ppc_store_dfpresult(); + ppc_changecrf1(); +} + void ppc_fmults(){ ppc_grab_regsfpdac(); float testf1 = (float)ppc_result64_a; @@ -235,6 +473,18 @@ void ppc_fmults(){ 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; + + ppc_result64_d = (uint64_t)testf3; + ppc_store_dfpresult(); + ppc_changecrf1(); +} + void ppc_fdivs(){ ppc_grab_regsfpdab(); float testf1 = (float)ppc_result64_a; @@ -246,6 +496,17 @@ void ppc_fdivs(){ 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; + + ppc_result64_d = (uint64_t)testf3; + ppc_store_dfpresult(); + ppc_changecrf1(); +} void ppc_fmadds(){ ppc_grab_regsfpdabc(); @@ -253,48 +514,112 @@ void ppc_fmadds(){ float testf2 = (float)ppc_result64_b; float testf3 = (float)ppc_result64_c; - float testf4 = (testf1 * testf3) + testf2; + float testf4 = (testf1 * testf3); + testf4 += testf2; ppc_result64_d = (uint64_t)testf4; 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; + + ppc_result64_d = (uint64_t)testf4; + 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) - testf2; + float testf4 = (testf1 * testf3); + testf4 -= testf2; ppc_result64_d = (uint64_t)testf4; 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; + + ppc_result64_d = (uint64_t)testf4; + 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) + testf2); + float testf4 = (testf1 * testf3); + testf4 += testf2; + testf4 = -testf4; ppc_result64_d = (uint64_t)testf4; 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; + + ppc_result64_d = (uint64_t)testf4; + 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) - testf2); + float testf4 = (testf1 * testf3); + testf4 -= testf2; + testf4 = -testf4; ppc_result64_d = (uint64_t)testf4; 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; + + ppc_result64_d = (uint64_t)testf4; + ppc_store_dfpresult(); + ppc_changecrf1(); +} + void ppc_fabs(){ ppc_grab_regsfpdb(); double testd1 = (double)ppc_result64_b; @@ -304,6 +629,35 @@ void ppc_fabs(){ 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; @@ -314,6 +668,17 @@ void ppc_fneg(){ 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; @@ -329,6 +694,22 @@ void ppc_fsel(){ 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; @@ -337,6 +718,15 @@ void ppc_fsqrt(){ ppc_store_dfpresult(); } +void ppc_fsqrtdot(){ + ppc_grab_regsfpdb(); + double test = (double)ppc_result64_b; + std::sqrt(test); + ppc_result64_d = (uint64_t)test; + ppc_store_dfpresult(); + ppc_changecrf1(); +} + void ppc_fsqrts(){ ppc_grab_regsfpdb(); uint32_t test = (uint32_t)ppc_result64_b; @@ -346,6 +736,16 @@ void ppc_fsqrts(){ ppc_store_dfpresult(); } +void ppc_fsqrtsdot(){ + ppc_grab_regsfpdb(); + uint32_t test = (uint32_t)ppc_result64_b; + test += 127 << 23; + test >>= 1; + ppc_result64_d = (uint64_t)test; + ppc_store_dfpresult(); + ppc_changecrf1(); +} + void ppc_frsqrte(){ ppc_grab_regsfpdb(); double testd2 = (double)ppc_result64_b; @@ -356,6 +756,17 @@ void ppc_frsqrte(){ ppc_store_dfpresult(); } +void ppc_frsqrtedot(){ + ppc_grab_regsfpdb(); + double testd2 = (double)ppc_result64_b; + for (int i = 0; i < 10; i++){ + testd2 = testd2 * (1.5 - (testd2 * .5) * testd2 * testd2); + } + ppc_result64_d = (uint64_t) testd2; + ppc_store_dfpresult(); + ppc_changecrf1(); +} + void ppc_frsp(){ ppc_grab_regsfpdb(); double testd2 = (double)ppc_result64_b; @@ -364,6 +775,15 @@ void ppc_frsp(){ ppc_store_dfpresult(); } +void ppc_frspdot(){ + ppc_grab_regsfpdb(); + double testd2 = (double)ppc_result64_b; + float testf2 = (float) testd2; + ppc_result64_d = (uint64_t) testf2; + ppc_store_dfpresult(); + ppc_changecrf1(); +} + void ppc_fres(){ ppc_grab_regsfpdb(); float testf2 = (float)ppc_result64_b; @@ -372,6 +792,15 @@ void ppc_fres(){ ppc_store_dfpresult(); } +void ppc_fresdot(){ + ppc_grab_regsfpdb(); + float testf2 = (float)ppc_result64_b; + testf2 = 1/testf2; + ppc_result64_d = (uint64_t) testf2; + ppc_store_dfpresult(); + ppc_changecrf1(); +} + void ppc_fctiw(){ //PLACEHOLDER! ppc_grab_regsfpdiab(); @@ -379,6 +808,17 @@ void ppc_fctiw(){ ppc_result_d = (uint32_t)(testd1); + ppc_store_result_regd(); + ppc_changecrf1(); +} + +void ppc_fctiwdot(){ + //PLACEHOLDER! + ppc_grab_regsfpdiab(); + double testd1 = (double)ppc_result64_b; + + ppc_result_d = (uint32_t)(testd1); + ppc_store_result_regd(); } @@ -389,6 +829,17 @@ void ppc_fctiwz(){ ppc_result_d = (uint32_t)(testd1); + ppc_store_result_regd(); + ppc_changecrf1(); +} + +void ppc_fctiwzdot(){ + //PLACEHOLDER! + ppc_grab_regsfpdiab(); + double testd1 = (double)ppc_result64_a; + + ppc_result_d = (uint32_t)(testd1); + ppc_store_result_regd(); } @@ -553,6 +1004,15 @@ void ppc_mffs(){ ppc_store_sfpresult(); } +void ppc_mffsdot(){ + ppc_grab_regsda(); + uint64_t fpstore1 = ppc_state.ppc_fpr[reg_d] & 0xFFFFFFFF00000000; + uint64_t fpstore2 = ppc_state.ppc_fpscr & 0x00000000FFFFFFFF; + fpstore1 |= fpstore2; + ppc_state.ppc_fpr[reg_d] = fpstore1; + ppc_store_sfpresult(); +} + void ppc_mtfsf(){ reg_b = (ppc_cur_instruction >> 11) & 31; uint32_t fm_mask = (ppc_cur_instruction >> 17) & 255; @@ -568,6 +1028,21 @@ void ppc_mtfsf(){ ppc_state.ppc_fpscr = (quickfprval & crm) | (quickfprval & ~(crm)); } +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 & 2) == 1)? 0x0F000000 : 0x00000000; + crm += ((fm_mask & 4) == 1)? 0x00F00000 : 0x00000000; + crm += ((fm_mask & 8) == 1)? 0x000F0000 : 0x00000000; + crm += ((fm_mask & 16) == 1)? 0x0000F000 : 0x00000000; + crm += ((fm_mask & 32) == 1)? 0x00000F00 : 0x00000000; + crm += ((fm_mask & 64) == 1)? 0x000000F0 : 0x00000000; + crm += ((fm_mask & 128) == 1)? 0x0000000F : 0x00000000; + uint32_t quickfprval = (uint32_t)ppc_state.ppc_fpr[reg_b]; + ppc_state.ppc_fpscr = (quickfprval & crm) | (quickfprval & ~(crm)); +} + void ppc_mtfsb0(){ crf_d = (ppc_cur_instruction >> 21) & 0x31; if ((crf_d == 0) || (crf_d > 2)){ diff --git a/ppcmemory.cpp b/ppcmemory.cpp index 2901830..953608f 100644 --- a/ppcmemory.cpp +++ b/ppcmemory.cpp @@ -501,9 +501,9 @@ void address_quickinsert_translate(uint32_t address_grab, uint32_t value_insert, grab_macmem_ptr = machine_fecxxx_mem; uint32_t reg_num = (value_insert & 0x07FC) >> 2; uint32_t dev_num = (value_insert & 0xF800) >> 11; - printf("ADDRESS SET FOR GRACKLE \n"); - printf("Device Number: %d ", dev_num); - printf("Register Number: %d \n", reg_num); + printf("ADDRESS SET FOR GRACKLE: "); + printf("Device Number: %d ", dev_num); + printf("Hex Register Number: %x \n", reg_num); mpc106_address = value_insert; } else{ @@ -605,7 +605,7 @@ void address_quickinsert_translate(uint32_t address_grab, uint32_t value_insert, uint32_t dev_num = (value_insert & 0xF800) >> 11; printf("ADDRESS SET FOR GRACKLE \n"); printf("Device Number: %d ", dev_num); - printf("Register Number: %d \n", reg_num); + printf("Hex Register Number: %x \n", reg_num); mpc_config_addr = value_insert; } else if (address_grab < 0xFF000000){ @@ -825,6 +825,7 @@ void address_quickgrab_translate(uint32_t address_grab, uint32_t value_extract, } else if (address_grab < 0xFF000000){ return_value = mpc106_read_device(mpc_config_addr, bit_num); + return_value = rev_endian32(return_value); return; } else if (address_grab < 0xFF800000){ diff --git a/ppcopcodes.cpp b/ppcopcodes.cpp index 2b041da..f8eed30 100644 --- a/ppcopcodes.cpp +++ b/ppcopcodes.cpp @@ -1029,8 +1029,22 @@ void ppc_mulli(){ ppc_store_result_regd(); } + void ppc_divw(){ ppc_grab_regsdab(); + + //handle division by zero cases + if (ppc_result_b == 0){ + ppc_result_d = 0; + ppc_store_result_regd(); + return; + } + else if ((ppc_result_a == 0x80000000) & (ppc_result_b == 0xFFFFFFFF)){ + ppc_result_d = 0; + ppc_store_result_regd(); + return; + } + sidiv_result = (int32_t) ppc_result_a / (int32_t) ppc_result_b; ppc_result_d = (uint32_t) sidiv_result; ppc_store_result_regd(); @@ -1038,6 +1052,21 @@ void ppc_divw(){ void ppc_divwdot(){ ppc_grab_regsdab(); + + //handle division by zero cases + if (ppc_result_b == 0){ + ppc_result_d = 0; + ppc_store_result_regd(); + ppc_state.ppc_cr &= 0x1FFFFFFF; + return; + } + else if ((ppc_result_a == 0x80000000) & (ppc_result_b == 0xFFFFFFFF)){ + ppc_result_d = 0; + ppc_store_result_regd(); + ppc_state.ppc_cr &= 0x1FFFFFFF; + return; + } + sidiv_result = (int32_t) ppc_result_a / (int32_t) ppc_result_b; ppc_result_d = (uint32_t) sidiv_result; ppc_changecrf0(ppc_result_d); @@ -1046,6 +1075,21 @@ void ppc_divwdot(){ void ppc_divwo(){ ppc_grab_regsdab(); + + //handle division by zero cases + if (ppc_result_b == 0){ + ppc_result_d = 0; + ppc_state.ppc_cr |= 0x10000000; + ppc_store_result_regd(); + return; + } + else if ((ppc_result_a == 0x80000000) & (ppc_result_b == 0xFFFFFFFF)){ + ppc_result_d = 0; + ppc_state.ppc_cr |= 0x10000000; + ppc_store_result_regd(); + return; + } + ppc_setsoov(ppc_result_a, ppc_result_b); sidiv_result = (int32_t) ppc_result_a / (int32_t) ppc_result_b; ppc_result_d = (uint32_t) sidiv_result; @@ -1054,6 +1098,23 @@ void ppc_divwo(){ void ppc_divwodot(){ ppc_grab_regsdab(); + + //handle division by zero cases + if (ppc_result_b == 0){ + ppc_result_d = 0; + ppc_store_result_regd(); + ppc_state.ppc_cr &= 0x1FFFFFFF; + ppc_state.ppc_cr |= 0x10000000; + return; + } + else if ((ppc_result_a == 0x80000000) & (ppc_result_b == 0xFFFFFFFF)){ + ppc_result_d = 0; + ppc_store_result_regd(); + ppc_state.ppc_cr &= 0x1FFFFFFF; + ppc_state.ppc_cr |= 0x10000000; + return; + } + ppc_setsoov(ppc_result_a, ppc_result_b); sidiv_result = (int32_t) ppc_result_a / (int32_t) ppc_result_b; ppc_result_d = (uint32_t) sidiv_result; @@ -1063,6 +1124,14 @@ void ppc_divwodot(){ void ppc_divwu(){ ppc_grab_regsdab(); + + //handle division by zero cases + if (ppc_result_b == 0){ + ppc_result_d = 0; + ppc_store_result_regd(); + return; + } + uidiv_result = ppc_result_a / ppc_result_b; ppc_result_d = uidiv_result; ppc_store_result_regd(); @@ -1070,6 +1139,15 @@ void ppc_divwu(){ void ppc_divwudot(){ ppc_grab_regsdab(); + + //handle division by zero cases + if (ppc_result_b == 0){ + ppc_result_d = 0; + ppc_store_result_regd(); + ppc_state.ppc_cr &= 0x1FFFFFFF; + return; + } + uidiv_result = ppc_result_a / ppc_result_b; ppc_result_d = uidiv_result; ppc_changecrf0(ppc_result_d); @@ -1078,6 +1156,15 @@ void ppc_divwudot(){ void ppc_divwuo(){ ppc_grab_regsdab(); + + //handle division by zero cases + if (ppc_result_b == 0){ + ppc_result_d = 0; + ppc_state.ppc_cr |= 0x10000000; + ppc_store_result_regd(); + return; + } + ppc_setsoov(ppc_result_a, ppc_result_b); uidiv_result = ppc_result_a / ppc_result_b; ppc_result_d = uidiv_result; @@ -1086,6 +1173,16 @@ void ppc_divwuo(){ void ppc_divwuodot(){ ppc_grab_regsdab(); + + //handle division by zero cases + if (ppc_result_b == 0){ + ppc_result_d = 0; + ppc_store_result_regd(); + ppc_state.ppc_cr &= 0x1FFFFFFF; + ppc_state.ppc_cr |= 0x10000000; + return; + } + ppc_setsoov(ppc_result_a, ppc_result_b); uidiv_result = ppc_result_a / ppc_result_b; ppc_result_d = uidiv_result;