2020-02-28 16:04:28 +00:00
|
|
|
/*
|
|
|
|
DingusPPC - The Experimental PowerPC Macintosh emulator
|
2024-03-26 23:14:31 +00:00
|
|
|
Copyright (C) 2018-24 divingkatae and maximum
|
2020-02-28 16:04:28 +00:00
|
|
|
(theweirdo) spatium
|
|
|
|
|
|
|
|
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2019-07-02 02:15:33 +00:00
|
|
|
|
|
|
|
// The Power-specific opcodes for the processor - ppcopcodes.cpp
|
|
|
|
// Any shared opcodes are in ppcopcodes.cpp
|
|
|
|
|
2019-12-27 19:10:36 +00:00
|
|
|
#include "ppcemu.h"
|
2024-03-22 15:01:29 +00:00
|
|
|
#include "ppcmacros.h"
|
2019-12-27 19:00:53 +00:00
|
|
|
#include "ppcmmu.h"
|
2023-11-03 07:21:33 +00:00
|
|
|
#include <stdint.h>
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2021-10-23 19:00:31 +00:00
|
|
|
/** mask generator for rotate and shift instructions (§ 4.2.1.4 PowerpC PEM) */
|
2021-10-02 05:37:28 +00:00
|
|
|
static inline uint32_t power_rot_mask(unsigned rot_mb, unsigned rot_me) {
|
2024-04-09 09:50:39 +00:00
|
|
|
uint32_t m1 = 0xFFFFFFFFU >> rot_mb;
|
|
|
|
uint32_t m2 = 0xFFFFFFFFU << (31 - rot_me);
|
2021-10-02 05:37:28 +00:00
|
|
|
return ((rot_mb <= rot_me) ? m2 & m1 : m1 | m2);
|
|
|
|
}
|
|
|
|
|
2024-03-26 08:14:23 +00:00
|
|
|
template <field_rc rec, field_ov ov>
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_abs() {
|
2024-03-22 15:01:29 +00:00
|
|
|
uint32_t ppc_result_d;
|
|
|
|
ppc_grab_regsda(ppc_cur_instruction);
|
2020-01-26 02:30:55 +00:00
|
|
|
if (ppc_result_a == 0x80000000) {
|
2019-07-02 02:15:33 +00:00
|
|
|
ppc_result_d = ppc_result_a;
|
2024-03-24 19:21:19 +00:00
|
|
|
if (ov)
|
2024-03-26 22:57:37 +00:00
|
|
|
ppc_state.spr[SPR::XER] |= XER::SO | XER::OV;
|
2020-05-12 18:55:45 +00:00
|
|
|
} else {
|
2024-04-09 08:07:48 +00:00
|
|
|
ppc_result_d = (int32_t(ppc_result_a) < 0) ? -ppc_result_a : ppc_result_a;
|
|
|
|
if (ov)
|
|
|
|
ppc_state.spr[SPR::XER] &= ~XER::OV;
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
if (rec)
|
2020-10-17 21:30:37 +00:00
|
|
|
ppc_changecrf0(ppc_result_d);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_d, ppc_result_d);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
template void dppc_interpreter::power_abs<RC0, OV0>();
|
|
|
|
template void dppc_interpreter::power_abs<RC0, OV1>();
|
|
|
|
template void dppc_interpreter::power_abs<RC1, OV0>();
|
|
|
|
template void dppc_interpreter::power_abs<RC1, OV1>();
|
|
|
|
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_clcs() {
|
2024-03-22 15:01:29 +00:00
|
|
|
uint32_t ppc_result_d;
|
|
|
|
ppc_grab_regsda(ppc_cur_instruction);
|
2020-01-26 02:30:55 +00:00
|
|
|
switch (reg_a) {
|
2021-10-02 05:37:28 +00:00
|
|
|
case 12: //instruction cache line size
|
|
|
|
case 13: //data cache line size
|
|
|
|
case 14: //minimum line size
|
|
|
|
case 15: //maximum line size
|
2024-04-09 08:12:41 +00:00
|
|
|
default: ppc_result_d = is_601 ? 64 : 32; break;
|
|
|
|
case 7:
|
|
|
|
case 23: ppc_result_d = is_601 ? 64 : 0; break;
|
|
|
|
case 8:
|
|
|
|
case 9:
|
|
|
|
case 24:
|
|
|
|
case 25: ppc_result_d = is_601 ? 64 : 4; break;
|
|
|
|
case 10:
|
|
|
|
case 11:
|
|
|
|
case 26:
|
|
|
|
case 27: ppc_result_d = is_601 ? 64 : 0x4000; break;
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_d, ppc_result_d);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-26 08:14:23 +00:00
|
|
|
template <field_rc rec, field_ov ov>
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_div() {
|
2024-03-22 15:01:29 +00:00
|
|
|
uint32_t ppc_result_d;
|
|
|
|
ppc_grab_regsdab(ppc_cur_instruction);
|
2023-12-01 19:38:29 +00:00
|
|
|
|
2024-04-09 08:25:23 +00:00
|
|
|
int64_t dividend = (uint64_t(ppc_result_a) << 32) | ppc_state.spr[SPR::MQ];
|
|
|
|
int32_t divisor = ppc_result_b;
|
|
|
|
int64_t quotient;
|
|
|
|
int32_t remainder;
|
|
|
|
|
|
|
|
if (dividend == -0x80000000 && divisor == -1) {
|
|
|
|
remainder = 0;
|
|
|
|
ppc_result_d = 0x80000000U; // -2^31 aka INT32_MIN
|
|
|
|
if (ov)
|
|
|
|
ppc_state.spr[SPR::XER] |= XER::SO | XER::OV;
|
|
|
|
} else if (!divisor) {
|
|
|
|
remainder = 0;
|
|
|
|
ppc_result_d = 0x80000000U; // -2^31 aka INT32_MIN
|
|
|
|
if (ov)
|
|
|
|
ppc_state.spr[SPR::XER] |= XER::SO | XER::OV;
|
2023-12-01 19:38:29 +00:00
|
|
|
} else {
|
2024-04-09 08:25:23 +00:00
|
|
|
quotient = dividend / divisor;
|
|
|
|
remainder = dividend % divisor;
|
|
|
|
ppc_result_d = uint32_t(quotient);
|
|
|
|
if (ov) {
|
|
|
|
if (((quotient >> 31) + 1) & ~1) {
|
|
|
|
ppc_state.spr[SPR::XER] |= XER::SO | XER::OV;
|
|
|
|
} else {
|
|
|
|
ppc_state.spr[SPR::XER] &= ~XER::OV;
|
|
|
|
}
|
|
|
|
}
|
2023-12-01 19:38:29 +00:00
|
|
|
}
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
if (rec)
|
2024-04-09 08:25:23 +00:00
|
|
|
ppc_changecrf0(remainder);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_d, ppc_result_d);
|
2024-04-09 08:25:23 +00:00
|
|
|
ppc_state.spr[SPR::MQ] = remainder;
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
template void dppc_interpreter::power_div<RC0, OV0>();
|
|
|
|
template void dppc_interpreter::power_div<RC0, OV1>();
|
|
|
|
template void dppc_interpreter::power_div<RC1, OV0>();
|
|
|
|
template void dppc_interpreter::power_div<RC1, OV1>();
|
|
|
|
|
2024-03-26 08:14:23 +00:00
|
|
|
template <field_rc rec, field_ov ov>
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_divs() {
|
2024-04-09 08:31:09 +00:00
|
|
|
uint32_t ppc_result_d;
|
|
|
|
int32_t remainder;
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_grab_regsdab(ppc_cur_instruction);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-04-09 08:31:09 +00:00
|
|
|
if (!ppc_result_b) { // handle the "anything / 0" case
|
|
|
|
ppc_result_d = -1;
|
|
|
|
remainder = ppc_result_a;
|
|
|
|
if (ov)
|
|
|
|
ppc_state.spr[SPR::XER] |= XER::SO | XER::OV;
|
|
|
|
} else if (ppc_result_a == 0x80000000U && ppc_result_b == 0xFFFFFFFFU) {
|
|
|
|
ppc_result_d = 0x80000000U;
|
|
|
|
remainder = 0;
|
|
|
|
if (ov)
|
|
|
|
ppc_state.spr[SPR::XER] |= XER::SO | XER::OV;
|
|
|
|
} else { // normal signed devision
|
|
|
|
ppc_result_d = int32_t(ppc_result_a) / int32_t(ppc_result_b);
|
|
|
|
remainder = (int32_t(ppc_result_a) % int32_t(ppc_result_b));
|
|
|
|
if (ov)
|
|
|
|
ppc_state.spr[SPR::XER] &= ~XER::OV;
|
|
|
|
}
|
2024-03-24 19:21:19 +00:00
|
|
|
if (rec)
|
2024-04-09 08:31:09 +00:00
|
|
|
ppc_changecrf0(remainder);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_d, ppc_result_d);
|
2024-04-09 08:31:09 +00:00
|
|
|
ppc_state.spr[SPR::MQ] = remainder;
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
template void dppc_interpreter::power_divs<RC0, OV0>();
|
|
|
|
template void dppc_interpreter::power_divs<RC0, OV1>();
|
|
|
|
template void dppc_interpreter::power_divs<RC1, OV0>();
|
|
|
|
template void dppc_interpreter::power_divs<RC1, OV1>();
|
|
|
|
|
2024-03-26 08:14:23 +00:00
|
|
|
template <field_rc rec, field_ov ov>
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_doz() {
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_grab_regsdab(ppc_cur_instruction);
|
2024-04-09 08:37:20 +00:00
|
|
|
uint32_t ppc_result_d = (int32_t(ppc_result_a) < int32_t(ppc_result_b)) ?
|
|
|
|
ppc_result_b - ppc_result_a : 0;
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-04-09 08:37:20 +00:00
|
|
|
if (ov) {
|
|
|
|
if (int32_t(ppc_result_d) < 0) {
|
|
|
|
ppc_state.spr[SPR::XER] |= XER::SO | XER::OV;
|
|
|
|
} else {
|
|
|
|
ppc_state.spr[SPR::XER] &= ~XER::OV;
|
|
|
|
}
|
|
|
|
}
|
2024-03-24 19:21:19 +00:00
|
|
|
if (rec)
|
2020-10-17 21:30:37 +00:00
|
|
|
ppc_changecrf0(ppc_result_d);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_d, ppc_result_d);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
template void dppc_interpreter::power_doz<RC0, OV0>();
|
|
|
|
template void dppc_interpreter::power_doz<RC0, OV1>();
|
|
|
|
template void dppc_interpreter::power_doz<RC1, OV0>();
|
|
|
|
template void dppc_interpreter::power_doz<RC1, OV1>();
|
|
|
|
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_dozi() {
|
2024-03-22 15:01:29 +00:00
|
|
|
uint32_t ppc_result_d;
|
|
|
|
ppc_grab_regsdasimm(ppc_cur_instruction);
|
2020-01-26 02:30:55 +00:00
|
|
|
if (((int32_t)ppc_result_a) > simm) {
|
2019-07-02 02:15:33 +00:00
|
|
|
ppc_result_d = 0;
|
2020-05-12 18:55:45 +00:00
|
|
|
} else {
|
2021-10-02 05:37:28 +00:00
|
|
|
ppc_result_d = simm - ppc_result_a;
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_d, ppc_result_d);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-26 08:14:23 +00:00
|
|
|
template <field_rc rec>
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_lscbx() {
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_grab_regsdab(ppc_cur_instruction);
|
2024-02-25 03:44:46 +00:00
|
|
|
ppc_effective_address = ppc_result_b + (reg_a ? ppc_result_a : 0);
|
2021-10-02 05:37:28 +00:00
|
|
|
|
2024-02-24 21:44:45 +00:00
|
|
|
uint32_t bytes_to_load = (ppc_state.spr[SPR::XER] & 0x7F);
|
2024-04-09 08:54:28 +00:00
|
|
|
uint32_t bytes_remaining = bytes_to_load;
|
2024-02-24 21:44:45 +00:00
|
|
|
uint8_t matching_byte = (uint8_t)(ppc_state.spr[SPR::XER] >> 8);
|
2024-04-09 08:54:28 +00:00
|
|
|
uint32_t ppc_result_d = 0;
|
|
|
|
bool is_match = false;
|
2021-10-02 05:37:28 +00:00
|
|
|
|
2022-11-13 03:17:04 +00:00
|
|
|
// for storing each byte
|
2024-02-24 21:44:45 +00:00
|
|
|
uint8_t shift_amount = 24;
|
2021-10-02 05:37:28 +00:00
|
|
|
|
2024-04-09 08:54:28 +00:00
|
|
|
while (bytes_remaining > 0) {
|
|
|
|
uint8_t return_value = mmu_read_vmem<uint8_t>(ppc_effective_address);
|
2024-02-24 21:44:45 +00:00
|
|
|
|
2024-04-09 08:54:28 +00:00
|
|
|
ppc_result_d |= return_value << shift_amount;
|
2024-02-24 21:44:45 +00:00
|
|
|
if (!shift_amount) {
|
|
|
|
if (reg_d != reg_a && reg_d != reg_b)
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_d, ppc_result_d);
|
2024-03-26 23:14:31 +00:00
|
|
|
reg_d = (reg_d + 1) & 0x1F;
|
2024-04-09 08:54:28 +00:00
|
|
|
ppc_result_d = 0;
|
2022-11-15 14:40:37 +00:00
|
|
|
shift_amount = 24;
|
2024-02-24 21:44:45 +00:00
|
|
|
} else {
|
2022-11-15 14:40:37 +00:00
|
|
|
shift_amount -= 8;
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
2021-10-02 05:37:28 +00:00
|
|
|
|
|
|
|
ppc_effective_address++;
|
2024-04-09 08:54:28 +00:00
|
|
|
bytes_remaining--;
|
2022-11-15 15:01:57 +00:00
|
|
|
|
2024-04-09 08:54:28 +00:00
|
|
|
if (return_value == matching_byte) {
|
|
|
|
is_match = true;
|
2022-11-15 15:01:57 +00:00
|
|
|
break;
|
2024-04-09 08:54:28 +00:00
|
|
|
}
|
2021-10-02 05:37:28 +00:00
|
|
|
}
|
|
|
|
|
2024-04-09 08:54:28 +00:00
|
|
|
// store partially loaded register if any
|
2024-02-24 21:44:45 +00:00
|
|
|
if (shift_amount != 24 && reg_d != reg_a && reg_d != reg_b)
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_d, ppc_result_d);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-04-09 08:54:28 +00:00
|
|
|
ppc_state.spr[SPR::XER] = (ppc_state.spr[SPR::XER] & ~0x7F) | (bytes_to_load - bytes_remaining);
|
2020-10-17 21:30:37 +00:00
|
|
|
|
2024-04-09 08:54:28 +00:00
|
|
|
if (rec) {
|
|
|
|
ppc_state.cr =
|
|
|
|
(ppc_state.cr & 0x0FFFFFFFUL) |
|
|
|
|
(is_match ? CRx_bit::CR_EQ : 0) |
|
|
|
|
((ppc_state.spr[SPR::XER] & XER::SO) >> 3);
|
|
|
|
}
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
template void dppc_interpreter::power_lscbx<RC0>();
|
|
|
|
template void dppc_interpreter::power_lscbx<RC1>();
|
|
|
|
|
2024-03-26 08:14:23 +00:00
|
|
|
template <field_rc rec>
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_maskg() {
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_grab_regssab(ppc_cur_instruction);
|
2024-03-26 23:14:31 +00:00
|
|
|
uint32_t mask_start = ppc_result_d & 0x1F;
|
|
|
|
uint32_t mask_end = ppc_result_b & 0x1F;
|
2019-07-02 02:15:33 +00:00
|
|
|
uint32_t insert_mask = 0;
|
|
|
|
|
2020-01-26 02:30:55 +00:00
|
|
|
if (mask_start < (mask_end + 1)) {
|
2021-10-02 05:37:28 +00:00
|
|
|
insert_mask = power_rot_mask(mask_start, mask_end);
|
2021-10-23 19:00:31 +00:00
|
|
|
}
|
2021-10-02 05:37:28 +00:00
|
|
|
else if (mask_start == (mask_end + 1)) {
|
2019-07-02 02:15:33 +00:00
|
|
|
insert_mask = 0xFFFFFFFF;
|
2021-10-23 19:00:31 +00:00
|
|
|
}
|
2021-10-02 05:37:28 +00:00
|
|
|
else {
|
|
|
|
insert_mask = ~(power_rot_mask(mask_end + 1, mask_start - 1));
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ppc_result_a = insert_mask;
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
if (rec)
|
2024-04-09 08:58:55 +00:00
|
|
|
ppc_changecrf0(ppc_result_a);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
template void dppc_interpreter::power_maskg<RC0>();
|
2024-03-26 08:14:23 +00:00
|
|
|
template void dppc_interpreter::power_maskg<RC1>();
|
2024-03-24 19:21:19 +00:00
|
|
|
|
2024-03-26 08:14:23 +00:00
|
|
|
template <field_rc rec>
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_maskir() {
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_grab_regssab(ppc_cur_instruction);
|
2023-12-01 19:38:29 +00:00
|
|
|
ppc_result_a = (ppc_result_a & ~ppc_result_b) | (ppc_result_d & ppc_result_b);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
if (rec)
|
2020-10-17 21:30:37 +00:00
|
|
|
ppc_changecrf0(ppc_result_a);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
template void dppc_interpreter::power_maskir<RC0>();
|
2024-03-26 08:14:23 +00:00
|
|
|
template void dppc_interpreter::power_maskir<RC1>();
|
2024-03-24 19:21:19 +00:00
|
|
|
|
2024-03-26 08:14:23 +00:00
|
|
|
template <field_rc rec, field_ov ov>
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_mul() {
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_grab_regsdab(ppc_cur_instruction);
|
2024-04-09 09:03:48 +00:00
|
|
|
int64_t product = int64_t(int32_t(ppc_result_a)) * int32_t(ppc_result_b);
|
|
|
|
uint32_t ppc_result_d = uint32_t(uint64_t(product) >> 32);
|
|
|
|
ppc_state.spr[SPR::MQ] = uint32_t(product);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-04-09 09:03:48 +00:00
|
|
|
if (ov) {
|
|
|
|
if (uint64_t(product >> 31) + 1 & ~1) {
|
|
|
|
ppc_state.spr[SPR::XER] |= XER::SO | XER::OV;
|
|
|
|
} else {
|
|
|
|
ppc_state.spr[SPR::XER] &= ~XER::OV;
|
|
|
|
}
|
|
|
|
}
|
2024-03-24 19:21:19 +00:00
|
|
|
if (rec)
|
2024-04-09 09:03:48 +00:00
|
|
|
ppc_changecrf0(uint32_t(product));
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_d, ppc_result_d);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
template void dppc_interpreter::power_mul<RC0, OV0>();
|
|
|
|
template void dppc_interpreter::power_mul<RC0, OV1>();
|
|
|
|
template void dppc_interpreter::power_mul<RC1, OV0>();
|
|
|
|
template void dppc_interpreter::power_mul<RC1, OV1>();
|
|
|
|
|
2024-03-26 08:14:23 +00:00
|
|
|
template <field_rc rec, field_ov ov>
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_nabs() {
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_grab_regsda(ppc_cur_instruction);
|
2024-04-09 04:50:27 +00:00
|
|
|
uint32_t ppc_result_d = (int32_t(ppc_result_a) < 0) ? ppc_result_a : -ppc_result_a;
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
if (ov)
|
2024-03-26 22:57:37 +00:00
|
|
|
ppc_state.spr[SPR::XER] &= ~XER::OV;
|
2024-04-09 09:04:32 +00:00
|
|
|
if (rec)
|
|
|
|
ppc_changecrf0(ppc_result_d);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_d, ppc_result_d);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
template void dppc_interpreter::power_nabs<RC0, OV0>();
|
|
|
|
template void dppc_interpreter::power_nabs<RC0, OV1>();
|
|
|
|
template void dppc_interpreter::power_nabs<RC1, OV0>();
|
|
|
|
template void dppc_interpreter::power_nabs<RC1, OV1>();
|
|
|
|
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_rlmi() {
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_grab_regssab(ppc_cur_instruction);
|
2024-03-26 23:14:31 +00:00
|
|
|
unsigned rot_mb = (ppc_cur_instruction >> 6) & 0x1F;
|
|
|
|
unsigned rot_me = (ppc_cur_instruction >> 1) & 0x1F;
|
|
|
|
unsigned rot_sh = ppc_result_b & 0x1F;
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2021-10-02 05:37:28 +00:00
|
|
|
uint32_t r = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh)));
|
|
|
|
uint32_t mask = power_rot_mask(rot_mb, rot_me);
|
|
|
|
|
|
|
|
ppc_result_a = ((r & mask) | (ppc_result_a & ~mask));
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
if ((ppc_cur_instruction & 0x01) == 1)
|
2021-10-02 05:37:28 +00:00
|
|
|
ppc_changecrf0(ppc_result_a);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-26 08:14:23 +00:00
|
|
|
template <field_rc rec>
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_rrib() {
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_grab_regssab(ppc_cur_instruction);
|
2024-04-09 09:17:03 +00:00
|
|
|
unsigned rot_sh = ppc_result_b & 0x1F;
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-04-09 04:50:27 +00:00
|
|
|
if (int32_t(ppc_result_d) < 0) {
|
2024-04-09 09:17:03 +00:00
|
|
|
ppc_result_a |= (0x80000000U >> rot_sh);
|
2020-05-12 18:55:45 +00:00
|
|
|
} else {
|
2024-04-09 09:17:03 +00:00
|
|
|
ppc_result_a &= ~(0x80000000U >> rot_sh);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
2020-10-17 21:30:37 +00:00
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
if (rec)
|
2020-10-17 21:30:37 +00:00
|
|
|
ppc_changecrf0(ppc_result_a);
|
|
|
|
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
template void dppc_interpreter::power_rrib<RC0>();
|
|
|
|
template void dppc_interpreter::power_rrib<RC1>();
|
|
|
|
|
2024-03-26 08:14:23 +00:00
|
|
|
template <field_rc rec>
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_sle() {
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_grab_regssab(ppc_cur_instruction);
|
2024-03-26 23:14:31 +00:00
|
|
|
unsigned rot_sh = ppc_result_b & 0x1F;
|
2021-10-02 05:37:28 +00:00
|
|
|
|
|
|
|
ppc_result_a = ppc_result_d << rot_sh;
|
|
|
|
ppc_state.spr[SPR::MQ] = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh)));
|
|
|
|
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
if (rec)
|
2020-10-17 21:30:37 +00:00
|
|
|
ppc_changecrf0(ppc_result_a);
|
|
|
|
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
template void dppc_interpreter::power_sle<RC0>();
|
|
|
|
template void dppc_interpreter::power_sle<RC1>();
|
|
|
|
|
2024-03-26 08:14:23 +00:00
|
|
|
template <field_rc rec>
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_sleq() {
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_grab_regssab(ppc_cur_instruction);
|
2024-03-26 23:14:31 +00:00
|
|
|
unsigned rot_sh = ppc_result_b & 0x1F;
|
2021-10-02 05:37:28 +00:00
|
|
|
uint32_t r = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh)));
|
|
|
|
uint32_t mask = power_rot_mask(0, 31 - rot_sh);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2021-10-02 05:37:28 +00:00
|
|
|
ppc_result_a = ((r & mask) | (ppc_state.spr[SPR::MQ] & ~mask));
|
|
|
|
ppc_state.spr[SPR::MQ] = r;
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
if (rec)
|
2020-10-17 21:30:37 +00:00
|
|
|
ppc_changecrf0(ppc_result_a);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
template void dppc_interpreter::power_sleq<RC0>();
|
|
|
|
template void dppc_interpreter::power_sleq<RC1>();
|
|
|
|
|
2024-03-26 08:14:23 +00:00
|
|
|
template <field_rc rec>
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_sliq() {
|
2024-04-09 04:26:14 +00:00
|
|
|
ppc_grab_regssash(ppc_cur_instruction);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2021-10-02 05:37:28 +00:00
|
|
|
ppc_result_a = ppc_result_d << rot_sh;
|
|
|
|
ppc_state.spr[SPR::MQ] = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh)));
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
if (rec)
|
2020-10-17 21:30:37 +00:00
|
|
|
ppc_changecrf0(ppc_result_a);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
template void dppc_interpreter::power_sliq<RC0>();
|
|
|
|
template void dppc_interpreter::power_sliq<RC1>();
|
|
|
|
|
2024-03-26 08:14:23 +00:00
|
|
|
template <field_rc rec>
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_slliq() {
|
2024-04-09 04:26:14 +00:00
|
|
|
ppc_grab_regssash(ppc_cur_instruction);
|
2024-03-26 23:14:31 +00:00
|
|
|
uint32_t r = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh)));
|
|
|
|
uint32_t mask = power_rot_mask(0, 31 - rot_sh);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2021-10-02 05:37:28 +00:00
|
|
|
ppc_result_a = ((r & mask) | (ppc_state.spr[SPR::MQ] & ~mask));
|
|
|
|
ppc_state.spr[SPR::MQ] = r;
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
if (rec)
|
2020-10-17 21:30:37 +00:00
|
|
|
ppc_changecrf0(ppc_result_a);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
template void dppc_interpreter::power_slliq<RC0>();
|
|
|
|
template void dppc_interpreter::power_slliq<RC1>();
|
|
|
|
|
2024-03-26 08:14:23 +00:00
|
|
|
template <field_rc rec>
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_sllq() {
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_grab_regssab(ppc_cur_instruction);
|
2024-03-26 23:14:31 +00:00
|
|
|
unsigned rot_sh = ppc_result_b & 0x1F;
|
2021-10-02 05:37:28 +00:00
|
|
|
|
2024-04-09 09:21:39 +00:00
|
|
|
if (ppc_result_b & 0x20) {
|
|
|
|
ppc_result_a = ppc_state.spr[SPR::MQ] & (-1U << rot_sh);
|
|
|
|
} else {
|
|
|
|
ppc_result_a = ((ppc_result_d << rot_sh) | (ppc_state.spr[SPR::MQ] & ((1 << rot_sh) - 1)));
|
2021-10-02 05:37:28 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
if (rec)
|
2021-10-02 05:37:28 +00:00
|
|
|
ppc_changecrf0(ppc_result_a);
|
|
|
|
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
template void dppc_interpreter::power_sllq<RC0>();
|
|
|
|
template void dppc_interpreter::power_sllq<RC1>();
|
|
|
|
|
2024-03-26 08:14:23 +00:00
|
|
|
template <field_rc rec>
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_slq() {
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_grab_regssab(ppc_cur_instruction);
|
2024-03-26 23:14:31 +00:00
|
|
|
unsigned rot_sh = ppc_result_b & 0x1F;
|
2021-10-02 05:37:28 +00:00
|
|
|
|
2024-04-09 09:25:53 +00:00
|
|
|
if (ppc_result_b & 0x20) {
|
2021-10-02 05:37:28 +00:00
|
|
|
ppc_result_a = 0;
|
2024-04-09 09:25:53 +00:00
|
|
|
} else {
|
|
|
|
ppc_result_a = ppc_result_d << rot_sh;
|
2021-10-02 05:37:28 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
if (rec)
|
2021-10-02 05:37:28 +00:00
|
|
|
ppc_changecrf0(ppc_result_a);
|
|
|
|
|
|
|
|
ppc_state.spr[SPR::MQ] = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh)));
|
2024-04-09 09:25:53 +00:00
|
|
|
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
template void dppc_interpreter::power_slq<RC0>();
|
|
|
|
template void dppc_interpreter::power_slq<RC1>();
|
|
|
|
|
2024-03-26 08:14:23 +00:00
|
|
|
template <field_rc rec>
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_sraiq() {
|
2024-04-09 04:26:14 +00:00
|
|
|
ppc_grab_regssash(ppc_cur_instruction);
|
2021-10-02 05:37:28 +00:00
|
|
|
uint32_t mask = (1 << rot_sh) - 1;
|
|
|
|
ppc_result_a = (int32_t)ppc_result_d >> rot_sh;
|
2024-02-21 01:15:08 +00:00
|
|
|
ppc_state.spr[SPR::MQ] = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh));
|
2021-10-02 05:37:28 +00:00
|
|
|
|
2024-04-09 04:50:27 +00:00
|
|
|
if ((int32_t(ppc_result_d) < 0) && (ppc_result_d & mask)) {
|
2024-03-26 22:57:37 +00:00
|
|
|
ppc_state.spr[SPR::XER] |= XER::CA;
|
2021-10-02 05:37:28 +00:00
|
|
|
} else {
|
2024-03-26 22:57:37 +00:00
|
|
|
ppc_state.spr[SPR::XER] &= ~XER::CA;
|
2021-10-02 05:37:28 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
if (rec)
|
2021-10-02 05:37:28 +00:00
|
|
|
ppc_changecrf0(ppc_result_a);
|
|
|
|
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
template void dppc_interpreter::power_sraiq<RC0>();
|
|
|
|
template void dppc_interpreter::power_sraiq<RC1>();
|
|
|
|
|
2024-03-26 08:14:23 +00:00
|
|
|
template <field_rc rec>
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_sraq() {
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_grab_regssab(ppc_cur_instruction);
|
2021-10-02 05:37:28 +00:00
|
|
|
unsigned rot_sh = ppc_result_b & 0x1F;
|
2024-04-09 09:29:13 +00:00
|
|
|
uint32_t mask = (ppc_result_b & 0x20) ? -1 : (1 << rot_sh) - 1;
|
|
|
|
ppc_result_a = (int32_t)ppc_result_d >> ((ppc_result_b & 0x20) ? 31 : rot_sh);
|
2021-10-02 05:37:28 +00:00
|
|
|
ppc_state.spr[SPR::MQ] = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh)));
|
|
|
|
|
2024-04-09 04:50:27 +00:00
|
|
|
if ((int32_t(ppc_result_d) < 0) && (ppc_result_d & mask)) {
|
2024-03-26 22:57:37 +00:00
|
|
|
ppc_state.spr[SPR::XER] |= XER::CA;
|
2021-10-02 05:37:28 +00:00
|
|
|
} else {
|
2024-03-26 22:57:37 +00:00
|
|
|
ppc_state.spr[SPR::XER] &= ~XER::CA;
|
2021-10-02 05:37:28 +00:00
|
|
|
}
|
|
|
|
|
2024-02-21 01:15:08 +00:00
|
|
|
ppc_state.spr[SPR::MQ] = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh));
|
2021-10-02 05:37:28 +00:00
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
if (rec)
|
2021-10-02 05:37:28 +00:00
|
|
|
ppc_changecrf0(ppc_result_a);
|
|
|
|
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
template void dppc_interpreter::power_sraq<RC0>();
|
|
|
|
template void dppc_interpreter::power_sraq<RC1>();
|
|
|
|
|
2024-03-26 08:14:23 +00:00
|
|
|
template <field_rc rec>
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_sre() {
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_grab_regssab(ppc_cur_instruction);
|
2021-10-02 05:37:28 +00:00
|
|
|
|
2024-03-26 23:14:31 +00:00
|
|
|
unsigned rot_sh = ppc_result_b & 0x1F;
|
|
|
|
ppc_result_a = ppc_result_d >> rot_sh;
|
2021-10-02 05:37:28 +00:00
|
|
|
|
2024-02-21 01:15:08 +00:00
|
|
|
ppc_state.spr[SPR::MQ] = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh));
|
2021-10-02 05:37:28 +00:00
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
if (rec)
|
2020-10-17 21:30:37 +00:00
|
|
|
ppc_changecrf0(ppc_result_a);
|
2021-10-02 05:37:28 +00:00
|
|
|
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
template void dppc_interpreter::power_sre<RC0>();
|
|
|
|
template void dppc_interpreter::power_sre<RC1>();
|
|
|
|
|
2024-03-26 08:14:23 +00:00
|
|
|
template <field_rc rec>
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_srea() {
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_grab_regssab(ppc_cur_instruction);
|
2021-10-02 05:37:28 +00:00
|
|
|
unsigned rot_sh = ppc_result_b & 0x1F;
|
|
|
|
ppc_result_a = (int32_t)ppc_result_d >> rot_sh;
|
2024-04-09 09:41:33 +00:00
|
|
|
uint32_t r = ((ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh)));
|
|
|
|
uint32_t mask = -1U >> rot_sh;
|
2021-10-02 05:37:28 +00:00
|
|
|
|
2024-04-09 09:41:33 +00:00
|
|
|
if ((int32_t(ppc_result_d) < 0) && (r & ~mask)) {
|
2024-03-26 22:57:37 +00:00
|
|
|
ppc_state.spr[SPR::XER] |= XER::CA;
|
2021-10-02 05:37:28 +00:00
|
|
|
} else {
|
2024-03-26 22:57:37 +00:00
|
|
|
ppc_state.spr[SPR::XER] &= ~XER::CA;
|
2021-10-02 05:37:28 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
if (rec)
|
2021-10-02 05:37:28 +00:00
|
|
|
ppc_changecrf0(ppc_result_a);
|
|
|
|
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
2024-04-09 09:41:33 +00:00
|
|
|
ppc_state.spr[SPR::MQ] = r;
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
template void dppc_interpreter::power_srea<RC0>();
|
|
|
|
template void dppc_interpreter::power_srea<RC1>();
|
|
|
|
|
2024-03-26 08:14:23 +00:00
|
|
|
template <field_rc rec>
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_sreq() {
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_grab_regssab(ppc_cur_instruction);
|
2024-03-26 23:14:31 +00:00
|
|
|
unsigned rot_sh = ppc_result_b & 0x1F;
|
2024-04-09 09:45:11 +00:00
|
|
|
uint32_t mask = -1U >> rot_sh;
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-04-09 09:45:11 +00:00
|
|
|
ppc_result_a = (ppc_result_d >> rot_sh) | (ppc_state.spr[SPR::MQ] & ~mask);
|
|
|
|
ppc_state.spr[SPR::MQ] = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh));
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
if (rec)
|
2020-10-17 21:30:37 +00:00
|
|
|
ppc_changecrf0(ppc_result_a);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
template void dppc_interpreter::power_sreq<RC0>();
|
|
|
|
template void dppc_interpreter::power_sreq<RC1>();
|
|
|
|
|
2024-03-26 08:14:23 +00:00
|
|
|
template <field_rc rec>
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_sriq() {
|
2024-04-09 04:26:14 +00:00
|
|
|
ppc_grab_regssash(ppc_cur_instruction);
|
2021-10-02 05:37:28 +00:00
|
|
|
ppc_result_a = ppc_result_d >> rot_sh;
|
2024-02-18 11:47:21 +00:00
|
|
|
ppc_state.spr[SPR::MQ] = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh));
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
if (rec)
|
2020-10-17 21:30:37 +00:00
|
|
|
ppc_changecrf0(ppc_result_a);
|
2019-07-02 02:15:33 +00:00
|
|
|
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
template void dppc_interpreter::power_sriq<RC0>();
|
|
|
|
template void dppc_interpreter::power_sriq<RC1>();
|
|
|
|
|
2024-03-26 08:14:23 +00:00
|
|
|
template <field_rc rec>
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_srliq() {
|
2024-04-09 04:26:14 +00:00
|
|
|
ppc_grab_regssash(ppc_cur_instruction);
|
2024-03-26 23:14:31 +00:00
|
|
|
uint32_t r = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh));
|
|
|
|
unsigned mask = power_rot_mask(rot_sh, 31);
|
2021-10-02 05:37:28 +00:00
|
|
|
|
|
|
|
ppc_result_a = ((r & mask) | (ppc_state.spr[SPR::MQ] & ~mask));
|
|
|
|
ppc_state.spr[SPR::MQ] = r;
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
if (rec)
|
2021-10-02 05:37:28 +00:00
|
|
|
ppc_changecrf0(ppc_result_a);
|
|
|
|
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
template void dppc_interpreter::power_srliq<RC0>();
|
|
|
|
template void dppc_interpreter::power_srliq<RC1>();
|
|
|
|
|
2024-03-26 08:14:23 +00:00
|
|
|
template <field_rc rec>
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_srlq() {
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_grab_regssab(ppc_cur_instruction);
|
2024-03-26 23:14:31 +00:00
|
|
|
unsigned rot_sh = ppc_result_b & 0x1F;
|
2024-02-21 01:15:08 +00:00
|
|
|
uint32_t r = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh));
|
2021-10-02 05:37:28 +00:00
|
|
|
unsigned mask = power_rot_mask(rot_sh, 31);
|
|
|
|
|
2024-04-09 09:47:03 +00:00
|
|
|
if (ppc_result_b & 0x20) {
|
2021-10-02 05:37:28 +00:00
|
|
|
ppc_result_a = (ppc_state.spr[SPR::MQ] & mask);
|
2024-04-09 09:47:03 +00:00
|
|
|
} else {
|
2021-10-02 05:37:28 +00:00
|
|
|
ppc_result_a = ((r & mask) | (ppc_state.spr[SPR::MQ] & ~mask));
|
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
if (rec)
|
2021-10-02 05:37:28 +00:00
|
|
|
ppc_changecrf0(ppc_result_a);
|
|
|
|
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
2019-07-02 02:15:33 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
template void dppc_interpreter::power_srlq<RC0>();
|
|
|
|
template void dppc_interpreter::power_srlq<RC1>();
|
|
|
|
|
2024-03-26 08:14:23 +00:00
|
|
|
template <field_rc rec>
|
2020-10-18 04:46:38 +00:00
|
|
|
void dppc_interpreter::power_srq() {
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_grab_regssab(ppc_cur_instruction);
|
2024-03-26 23:14:31 +00:00
|
|
|
unsigned rot_sh = ppc_result_b & 0x1F;
|
2021-10-02 05:37:28 +00:00
|
|
|
|
2024-04-09 09:47:29 +00:00
|
|
|
if (ppc_result_b & 0x20) {
|
2021-10-02 05:37:28 +00:00
|
|
|
ppc_result_a = 0;
|
|
|
|
} else {
|
|
|
|
ppc_result_a = ppc_result_d >> rot_sh;
|
|
|
|
}
|
|
|
|
|
2024-02-21 01:15:08 +00:00
|
|
|
ppc_state.spr[SPR::MQ] = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh));
|
2021-10-02 05:37:28 +00:00
|
|
|
|
2024-03-24 19:21:19 +00:00
|
|
|
if (rec)
|
2021-10-02 05:37:28 +00:00
|
|
|
ppc_changecrf0(ppc_result_a);
|
|
|
|
|
2024-03-22 15:01:29 +00:00
|
|
|
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
2021-08-03 14:01:32 +00:00
|
|
|
}
|
2024-03-24 19:21:19 +00:00
|
|
|
|
|
|
|
template void dppc_interpreter::power_srq<RC0>();
|
2024-03-26 08:14:23 +00:00
|
|
|
template void dppc_interpreter::power_srq<RC1>();
|