mirror of
https://github.com/dingusdev/dingusppc.git
synced 2025-01-11 05:29:43 +00:00
Started a massive FP fix-up
This commit is contained in:
parent
29d0ce362c
commit
6a083869e1
@ -28,6 +28,11 @@ enum endian_switch {big_end = 0, little_end = 1};
|
||||
|
||||
typedef void (*PPCOpcode)(void);
|
||||
|
||||
typedef union FPR_storage {
|
||||
double dbl64_r = 0.0; // double floating-point representation
|
||||
uint64_t int64_r; // double integer representation
|
||||
};
|
||||
|
||||
/**
|
||||
Except for the floating-point registers, all registers require
|
||||
32 bits for representation. Floating-point registers need 64 bits.
|
||||
@ -43,7 +48,7 @@ fpscr = FP Status and Condition Register
|
||||
**/
|
||||
|
||||
typedef struct struct_ppc_state {
|
||||
uint64_t ppc_fpr [32];
|
||||
FPR_storage ppc_fpr [32];
|
||||
uint32_t ppc_pc; //Referred as the CIA in the PPC manual
|
||||
uint32_t ppc_gpr [32];
|
||||
uint32_t ppc_cr;
|
||||
@ -59,7 +64,7 @@ extern SetPRS ppc_state;
|
||||
|
||||
/**
|
||||
typedef struct struct_ppc64_state {
|
||||
uint64_t ppc_fpr [32];
|
||||
FPR_storage ppc_fpr [32];
|
||||
uint64_t ppc_pc; //Referred as the CIA in the PPC manual
|
||||
uint64_t ppc_gpr [32];
|
||||
uint32_t ppc_cr;
|
||||
@ -138,7 +143,6 @@ extern uint32_t uimm;
|
||||
extern uint32_t not_this;
|
||||
extern uint32_t grab_sr;
|
||||
extern uint32_t grab_inb; //This is for grabbing the number of immediate bytes for loading and storing
|
||||
extern uint32_t grab_d; //This is for grabbing d from Store and Load instructions
|
||||
extern uint32_t ppc_to;
|
||||
extern int32_t simm;
|
||||
extern int32_t adr_li;
|
||||
@ -224,6 +228,10 @@ void ppc_opcode31();
|
||||
void ppc_opcode59();
|
||||
void ppc_opcode63();
|
||||
|
||||
extern bool ppc_confirm_inf_nan(uint64_t input_a, uint64_t input_b, bool is_single, uint32_t op);
|
||||
extern double fp_return_double(uint32_t reg);
|
||||
extern uint64_t fp_return_uint64(uint32_t reg);
|
||||
|
||||
extern void ppc_grab_regsda();
|
||||
extern void ppc_grab_regsdb();
|
||||
|
||||
@ -238,17 +246,17 @@ extern void ppc_grab_regsdauimm();
|
||||
extern void ppc_grab_regsasimm();
|
||||
extern void ppc_grab_regssauimm();
|
||||
|
||||
extern void ppc_grab_regsfpdb();
|
||||
extern void ppc_grab_regsfpdab();
|
||||
extern void ppc_grab_regsfpdia();
|
||||
extern void ppc_grab_regsfpdiab();
|
||||
extern void ppc_grab_regsfpsia();
|
||||
extern void ppc_grab_regsfpsiab();
|
||||
extern void ppc_grab_regsfpdb(bool int_rep);
|
||||
extern void ppc_grab_regsfpdab(bool int_rep);
|
||||
extern void ppc_grab_regsfpdia(bool int_rep);
|
||||
extern void ppc_grab_regsfpdiab(bool int_rep);
|
||||
extern void ppc_grab_regsfpsia(bool int_rep);
|
||||
extern void ppc_grab_regsfpsiab(bool int_rep);
|
||||
|
||||
extern void ppc_store_result_regd();
|
||||
extern void ppc_store_result_rega();
|
||||
extern void ppc_store_sfpresult();
|
||||
extern void ppc_store_dfpresult();
|
||||
extern void ppc_store_sfpresult(bool int_rep);
|
||||
extern void ppc_store_dfpresult(bool int_rep);
|
||||
|
||||
void ppc_carry(uint32_t a, uint32_t b);
|
||||
void ppc_setsoov(uint32_t a, uint32_t b);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -32,7 +32,6 @@
|
||||
uint32_t not_this;
|
||||
uint32_t grab_sr;
|
||||
uint32_t grab_inb; //This is for grabbing the number of immediate bytes for loading and storing
|
||||
uint32_t grab_d; //This is for grabbing d from Store and Load instructions
|
||||
uint32_t ppc_to;
|
||||
int32_t simm;
|
||||
int32_t adr_li;
|
||||
@ -1867,58 +1866,59 @@ void ppc_dcbz(){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Integer Load and Store Functions
|
||||
|
||||
void ppc_stb(){
|
||||
void ppc_stb() {
|
||||
ppc_grab_regssa();
|
||||
grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)));
|
||||
ppc_effective_address = (reg_a == 0)?grab_d:(ppc_result_a + grab_d);
|
||||
ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF));
|
||||
ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0;
|
||||
address_quickinsert_translate(ppc_result_d, ppc_effective_address, 1);
|
||||
}
|
||||
|
||||
void ppc_stbx(){
|
||||
void ppc_stbx() {
|
||||
ppc_grab_regssab();
|
||||
ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b);
|
||||
ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b);
|
||||
address_quickinsert_translate(ppc_result_d, ppc_effective_address, 1);
|
||||
}
|
||||
|
||||
void ppc_stbu(){
|
||||
void ppc_stbu() {
|
||||
ppc_grab_regssa();
|
||||
if (reg_a != 0){
|
||||
grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)));
|
||||
ppc_effective_address = ppc_result_a + grab_d;
|
||||
if (reg_a != 0) {
|
||||
ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF));
|
||||
ppc_effective_address += ppc_result_a;
|
||||
address_quickinsert_translate(ppc_result_d, ppc_effective_address, 1);
|
||||
ppc_state.ppc_gpr[reg_a] = ppc_effective_address;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x20000);
|
||||
}
|
||||
}
|
||||
|
||||
void ppc_stbux(){
|
||||
void ppc_stbux() {
|
||||
ppc_grab_regssab();
|
||||
if (reg_a != 0){
|
||||
if (reg_a != 0) {
|
||||
ppc_effective_address = ppc_result_a + ppc_result_b;
|
||||
address_quickinsert_translate(ppc_result_d, ppc_effective_address, 1);
|
||||
ppc_state.ppc_gpr[reg_a] = ppc_effective_address;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x20000);
|
||||
}
|
||||
}
|
||||
|
||||
void ppc_sth(){
|
||||
void ppc_sth() {
|
||||
ppc_grab_regssa();
|
||||
grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)));
|
||||
ppc_effective_address = (reg_a == 0)?grab_d:(ppc_result_a + grab_d);
|
||||
ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF));
|
||||
ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0;
|
||||
address_quickinsert_translate(ppc_result_d, ppc_effective_address, 2);
|
||||
}
|
||||
|
||||
void ppc_sthu(){
|
||||
void ppc_sthu() {
|
||||
ppc_grab_regssa();
|
||||
if (reg_a != 0) {
|
||||
grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)));
|
||||
ppc_effective_address = ppc_result_a + grab_d;
|
||||
ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF));
|
||||
ppc_effective_address += ppc_result_a;
|
||||
address_quickinsert_translate(ppc_result_d, ppc_effective_address, 2);
|
||||
ppc_state.ppc_gpr[reg_a] = ppc_effective_address;
|
||||
}
|
||||
@ -1927,7 +1927,7 @@ void ppc_sthu(){
|
||||
}
|
||||
}
|
||||
|
||||
void ppc_sthux(){
|
||||
void ppc_sthux() {
|
||||
ppc_grab_regssab();
|
||||
if (reg_a != 0) {
|
||||
ppc_effective_address = ppc_result_a + ppc_result_b;
|
||||
@ -1939,51 +1939,51 @@ void ppc_sthux(){
|
||||
}
|
||||
}
|
||||
|
||||
void ppc_sthx(){
|
||||
void ppc_sthx() {
|
||||
ppc_grab_regssab();
|
||||
ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b);
|
||||
address_quickinsert_translate(ppc_result_d, ppc_effective_address, 2);
|
||||
}
|
||||
|
||||
void ppc_sthbrx(){
|
||||
void ppc_sthbrx() {
|
||||
ppc_grab_regssab();
|
||||
ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b);
|
||||
ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b);
|
||||
ppc_result_d = (uint32_t)(BYTESWAP_16((uint16_t)ppc_result_d));
|
||||
address_quickinsert_translate(ppc_result_d, ppc_effective_address, 2);
|
||||
}
|
||||
|
||||
void ppc_stw(){
|
||||
}
|
||||
void ppc_stw() {
|
||||
ppc_grab_regssa();
|
||||
grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)));
|
||||
ppc_effective_address = (reg_a == 0)?grab_d:(ppc_result_a + grab_d);
|
||||
ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF));
|
||||
ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0;
|
||||
address_quickinsert_translate(ppc_result_d, ppc_effective_address, 4);
|
||||
}
|
||||
|
||||
void ppc_stwx(){
|
||||
void ppc_stwx() {
|
||||
ppc_grab_regssab();
|
||||
ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b);
|
||||
ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b);
|
||||
address_quickinsert_translate(ppc_result_d, ppc_effective_address, 4);
|
||||
}
|
||||
|
||||
void ppc_stwcx(){
|
||||
void ppc_stwcx() {
|
||||
//PLACEHOLDER CODE FOR STWCX - We need to check for reserve memory
|
||||
ppc_grab_regssab();
|
||||
ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b);
|
||||
if (ppc_state.ppc_reserve){
|
||||
ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b);
|
||||
if (ppc_state.ppc_reserve) {
|
||||
address_quickinsert_translate(ppc_result_d, ppc_effective_address, 4);
|
||||
ppc_state.ppc_cr |= (ppc_state.ppc_spr[1] & 0x80000000) ? 0x30000000 : 0x20000000;
|
||||
ppc_state.ppc_reserve = false;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
ppc_state.ppc_cr |= (ppc_state.ppc_spr[1] & 0x80000000) ? 0x10000000 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
void ppc_stwu(){
|
||||
void ppc_stwu() {
|
||||
ppc_grab_regssa();
|
||||
if (reg_a != 0) {
|
||||
grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)));
|
||||
ppc_effective_address = ppc_result_a + grab_d;
|
||||
ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF));
|
||||
ppc_effective_address += ppc_result_a;
|
||||
address_quickinsert_translate(ppc_result_d, ppc_effective_address, 4);
|
||||
ppc_state.ppc_gpr[reg_a] = ppc_effective_address;
|
||||
}
|
||||
@ -1992,7 +1992,7 @@ void ppc_stwu(){
|
||||
}
|
||||
}
|
||||
|
||||
void ppc_stwux(){
|
||||
void ppc_stwux() {
|
||||
ppc_grab_regssab();
|
||||
if (reg_a != 0) {
|
||||
ppc_effective_address = ppc_result_a + ppc_result_b;
|
||||
@ -2004,148 +2004,181 @@ void ppc_stwux(){
|
||||
}
|
||||
}
|
||||
|
||||
void ppc_stwbrx(){
|
||||
void ppc_stwbrx() {
|
||||
ppc_grab_regssab();
|
||||
ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b);
|
||||
ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b);
|
||||
ppc_result_d = BYTESWAP_32(ppc_result_d);
|
||||
address_quickinsert_translate(ppc_result_d, ppc_effective_address, 4);
|
||||
}
|
||||
|
||||
void ppc_stmw(){
|
||||
void ppc_stmw() {
|
||||
ppc_grab_regssa();
|
||||
grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)));
|
||||
ppc_effective_address = (reg_a == 0)?grab_d:(ppc_result_a + grab_d);
|
||||
ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF));
|
||||
ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0;
|
||||
//How many words to store in memory - using a do-while for this
|
||||
do{
|
||||
do {
|
||||
address_quickinsert_translate(ppc_result_d, ppc_effective_address, 4);
|
||||
ppc_effective_address +=4;
|
||||
ppc_effective_address += 4;
|
||||
reg_d++;
|
||||
}while (reg_d < 32);
|
||||
} while (reg_d < 32);
|
||||
}
|
||||
|
||||
void ppc_lbz(){
|
||||
void ppc_lbz() {
|
||||
ppc_grab_regsda();
|
||||
grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)));
|
||||
ppc_effective_address = (reg_a == 0)?grab_d:(ppc_result_a + grab_d);
|
||||
ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF));
|
||||
ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0;
|
||||
address_quickgrab_translate(ppc_effective_address, 1);
|
||||
ppc_result_d = return_value;
|
||||
return_value = 0;
|
||||
ppc_store_result_regd();
|
||||
}
|
||||
|
||||
void ppc_lbzu(){
|
||||
void ppc_lbzu() {
|
||||
ppc_grab_regsda();
|
||||
grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)));
|
||||
if ((reg_a != reg_d) || reg_a != 0){
|
||||
ppc_effective_address = ppc_result_a + grab_d;
|
||||
ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF));
|
||||
if ((reg_a != reg_d) || reg_a != 0) {
|
||||
ppc_effective_address += ppc_result_a;
|
||||
address_quickgrab_translate(ppc_effective_address, 1);
|
||||
ppc_result_d = return_value;
|
||||
return_value = 0;
|
||||
ppc_result_a = ppc_effective_address;
|
||||
ppc_store_result_regd();
|
||||
ppc_store_result_rega();
|
||||
}
|
||||
else{
|
||||
else {
|
||||
ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x20000);
|
||||
}
|
||||
address_quickgrab_translate(ppc_effective_address, 1);
|
||||
ppc_result_d = return_value;
|
||||
return_value = 0;
|
||||
ppc_result_a = ppc_effective_address;
|
||||
ppc_store_result_regd();
|
||||
ppc_store_result_rega();
|
||||
}
|
||||
|
||||
void ppc_lbzx(){
|
||||
void ppc_lbzx() {
|
||||
ppc_grab_regsdab();
|
||||
ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b);
|
||||
ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b);
|
||||
address_quickgrab_translate(ppc_effective_address, 1);
|
||||
ppc_result_d = return_value;
|
||||
return_value = 0;
|
||||
ppc_store_result_regd();
|
||||
}
|
||||
|
||||
void ppc_lbzux(){
|
||||
void ppc_lbzux() {
|
||||
ppc_grab_regsdab();
|
||||
if ((reg_a != reg_d) || reg_a != 0){
|
||||
if ((reg_a != reg_d) || reg_a != 0) {
|
||||
ppc_effective_address = ppc_result_a + ppc_result_b;
|
||||
address_quickgrab_translate(ppc_effective_address, 1);
|
||||
ppc_result_d = return_value;
|
||||
return_value = 0;
|
||||
ppc_result_a = ppc_effective_address;
|
||||
ppc_store_result_regd();
|
||||
ppc_store_result_rega();
|
||||
}
|
||||
else{
|
||||
else {
|
||||
ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x20000);
|
||||
}
|
||||
address_quickgrab_translate(ppc_effective_address, 1);
|
||||
ppc_result_d = return_value;
|
||||
return_value = 0;
|
||||
ppc_result_a = ppc_effective_address;
|
||||
ppc_store_result_regd();
|
||||
ppc_store_result_rega();
|
||||
}
|
||||
|
||||
|
||||
void ppc_lhz(){
|
||||
void ppc_lhz() {
|
||||
ppc_grab_regsda();
|
||||
grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)));
|
||||
ppc_effective_address = (reg_a == 0)?grab_d:(ppc_result_a + grab_d);
|
||||
ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF));
|
||||
ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0;
|
||||
address_quickgrab_translate(ppc_effective_address, 2);
|
||||
ppc_result_d = return_value;
|
||||
return_value = 0;
|
||||
ppc_store_result_regd();
|
||||
}
|
||||
|
||||
void ppc_lhzu(){
|
||||
void ppc_lhzu() {
|
||||
ppc_grab_regsda();
|
||||
grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)));
|
||||
ppc_effective_address = ppc_result_a + grab_d;
|
||||
address_quickgrab_translate(ppc_effective_address, 2);
|
||||
ppc_result_d = return_value;
|
||||
return_value = 0;
|
||||
ppc_result_a = ppc_effective_address;
|
||||
ppc_store_result_regd();
|
||||
ppc_store_result_rega();
|
||||
if ((reg_a != reg_d) || reg_a != 0) {
|
||||
ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF));
|
||||
ppc_effective_address += ppc_result_a;
|
||||
address_quickgrab_translate(ppc_effective_address, 2);
|
||||
ppc_result_d = return_value;
|
||||
return_value = 0;
|
||||
ppc_result_a = ppc_effective_address;
|
||||
ppc_store_result_regd();
|
||||
ppc_store_result_rega();
|
||||
}
|
||||
else {
|
||||
ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x20000);
|
||||
}
|
||||
}
|
||||
|
||||
void ppc_lhzx(){
|
||||
void ppc_lhzx() {
|
||||
ppc_grab_regsdab();
|
||||
ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b);
|
||||
ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b);
|
||||
address_quickgrab_translate(ppc_effective_address, 2);
|
||||
ppc_result_d = return_value;
|
||||
return_value = 0;
|
||||
ppc_store_result_regd();
|
||||
}
|
||||
|
||||
void ppc_lhzux(){
|
||||
void ppc_lhzux() {
|
||||
ppc_grab_regsdab();
|
||||
ppc_effective_address = ppc_result_a + ppc_result_b;
|
||||
address_quickgrab_translate(ppc_effective_address, 2);
|
||||
ppc_result_d = return_value;
|
||||
return_value = 0;
|
||||
ppc_result_a = ppc_effective_address;
|
||||
ppc_store_result_regd();
|
||||
ppc_store_result_rega();
|
||||
if ((reg_a != reg_d) || reg_a != 0) {
|
||||
ppc_effective_address = ppc_result_a + ppc_result_b;
|
||||
address_quickgrab_translate(ppc_effective_address, 2);
|
||||
ppc_result_d = return_value;
|
||||
return_value = 0;
|
||||
ppc_result_a = ppc_effective_address;
|
||||
ppc_store_result_regd();
|
||||
ppc_store_result_rega();
|
||||
}
|
||||
else {
|
||||
ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x20000);
|
||||
}
|
||||
}
|
||||
|
||||
void ppc_lha(){
|
||||
void ppc_lha() {
|
||||
ppc_grab_regsda();
|
||||
grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)));
|
||||
ppc_effective_address = (reg_a == 0)?grab_d:(uint32_t)(ppc_result_a + grab_d);
|
||||
ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF));
|
||||
ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0;
|
||||
address_quickgrab_translate(ppc_effective_address, 2);
|
||||
uint16_t go_this = (uint16_t)return_value;
|
||||
if (go_this & 0x8000){
|
||||
if (go_this & 0x8000) {
|
||||
ppc_result_d = 0xFFFF0000UL | (uint32_t)return_value;
|
||||
ppc_store_result_regd();
|
||||
}
|
||||
else{
|
||||
else {
|
||||
ppc_result_d = (uint32_t)return_value;
|
||||
ppc_store_result_regd();
|
||||
}
|
||||
return_value = 0;
|
||||
}
|
||||
|
||||
void ppc_lhau(){
|
||||
void ppc_lhau() {
|
||||
ppc_grab_regsda();
|
||||
grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)));
|
||||
ppc_effective_address = (reg_a == 0)?grab_d:(uint32_t)(ppc_result_a + grab_d);
|
||||
if ((reg_a != reg_d) || reg_a != 0) {
|
||||
ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF));
|
||||
ppc_effective_address += ppc_result_a;
|
||||
address_quickgrab_translate(ppc_effective_address, 2);
|
||||
uint16_t go_this = (uint16_t)return_value;
|
||||
if (go_this & 0x8000) {
|
||||
ppc_result_d = 0xFFFF0000UL | (uint32_t)return_value;
|
||||
ppc_store_result_regd();
|
||||
}
|
||||
else {
|
||||
ppc_result_d = (uint32_t)return_value;
|
||||
ppc_store_result_regd();
|
||||
}
|
||||
return_value = 0;
|
||||
ppc_result_a = ppc_effective_address;
|
||||
ppc_store_result_rega();
|
||||
}
|
||||
else {
|
||||
ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x20000);
|
||||
}
|
||||
}
|
||||
|
||||
void ppc_lhaux() {
|
||||
ppc_grab_regsdab();
|
||||
ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b);
|
||||
address_quickgrab_translate(ppc_effective_address, 2);
|
||||
uint16_t go_this = (uint16_t)return_value;
|
||||
if (go_this & 0x8000){
|
||||
if (go_this & 0x8000) {
|
||||
ppc_result_d = 0xFFFF0000UL | (uint32_t)return_value;
|
||||
ppc_store_result_regd();
|
||||
}
|
||||
else{
|
||||
else {
|
||||
ppc_result_d = (uint32_t)return_value;
|
||||
ppc_store_result_regd();
|
||||
}
|
||||
@ -2154,100 +2187,82 @@ void ppc_lhau(){
|
||||
ppc_store_result_rega();
|
||||
}
|
||||
|
||||
void ppc_lhaux(){
|
||||
void ppc_lhax() {
|
||||
ppc_grab_regsdab();
|
||||
ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b);
|
||||
ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b);
|
||||
address_quickgrab_translate(ppc_effective_address, 2);
|
||||
uint16_t go_this = (uint16_t)return_value;
|
||||
if (go_this & 0x8000){
|
||||
if (go_this & 0x8000) {
|
||||
ppc_result_d = 0xFFFF0000UL | (uint32_t)return_value;
|
||||
ppc_store_result_regd();
|
||||
}
|
||||
else{
|
||||
ppc_result_d = (uint32_t)return_value;
|
||||
ppc_store_result_regd();
|
||||
}
|
||||
return_value = 0;
|
||||
ppc_result_a = ppc_effective_address;
|
||||
ppc_store_result_rega();
|
||||
}
|
||||
|
||||
void ppc_lhax(){
|
||||
ppc_grab_regsdab();
|
||||
ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b);
|
||||
address_quickgrab_translate(ppc_effective_address, 2);
|
||||
uint16_t go_this = (uint16_t)return_value;
|
||||
if (go_this & 0x8000){
|
||||
ppc_result_d = 0xFFFF0000UL | (uint32_t)return_value;
|
||||
ppc_store_result_regd();
|
||||
}
|
||||
else{
|
||||
else {
|
||||
ppc_result_d = (uint32_t)return_value;
|
||||
ppc_store_result_regd();
|
||||
}
|
||||
return_value = 0;
|
||||
}
|
||||
|
||||
void ppc_lhbrx(){
|
||||
void ppc_lhbrx() {
|
||||
ppc_grab_regsdab();
|
||||
ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b);
|
||||
ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b);
|
||||
address_quickgrab_translate(ppc_effective_address, 2);
|
||||
ppc_result_d = (uint32_t)(BYTESWAP_16((uint16_t)ppc_result_d));
|
||||
return_value = 0;
|
||||
ppc_store_result_regd();
|
||||
}
|
||||
|
||||
void ppc_lwz(){
|
||||
void ppc_lwz() {
|
||||
ppc_grab_regsda();
|
||||
grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)));
|
||||
ppc_effective_address = (reg_a == 0)?grab_d:(ppc_result_a + grab_d);
|
||||
ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF));
|
||||
ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0;
|
||||
address_quickgrab_translate(ppc_effective_address, 4);
|
||||
ppc_result_d = return_value;
|
||||
return_value = 0;
|
||||
ppc_store_result_regd();
|
||||
}
|
||||
|
||||
void ppc_lwbrx(){
|
||||
void ppc_lwbrx() {
|
||||
ppc_grab_regsdab();
|
||||
ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b);
|
||||
ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b);
|
||||
address_quickgrab_translate(ppc_effective_address, 4);
|
||||
ppc_result_d = BYTESWAP_32(return_value);
|
||||
return_value = 0;
|
||||
ppc_store_result_regd();
|
||||
}
|
||||
|
||||
void ppc_lwzu(){
|
||||
void ppc_lwzu() {
|
||||
ppc_grab_regsda();
|
||||
grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)));
|
||||
if ((reg_a != reg_d) || reg_a != 0){
|
||||
ppc_effective_address = ppc_result_a + grab_d;
|
||||
ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF));
|
||||
if ((reg_a != reg_d) || reg_a != 0) {
|
||||
ppc_effective_address += ppc_result_a;
|
||||
address_quickgrab_translate(ppc_effective_address, 4);
|
||||
ppc_result_d = return_value;
|
||||
return_value = 0;
|
||||
ppc_store_result_regd();
|
||||
ppc_result_a = ppc_effective_address;
|
||||
ppc_store_result_rega();
|
||||
}
|
||||
else{
|
||||
else {
|
||||
ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x20000);
|
||||
}
|
||||
address_quickgrab_translate(ppc_effective_address, 4);
|
||||
ppc_result_d = return_value;
|
||||
return_value = 0;
|
||||
ppc_store_result_regd();
|
||||
ppc_result_a = ppc_effective_address;
|
||||
ppc_store_result_rega();
|
||||
}
|
||||
|
||||
void ppc_lwzx(){
|
||||
void ppc_lwzx() {
|
||||
ppc_grab_regsdab();
|
||||
ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b);
|
||||
ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b);
|
||||
address_quickgrab_translate(ppc_effective_address, 4);
|
||||
ppc_result_d = return_value;
|
||||
return_value = 0;
|
||||
ppc_store_result_regd();
|
||||
}
|
||||
|
||||
void ppc_lwzux(){
|
||||
void ppc_lwzux() {
|
||||
ppc_grab_regsdab();
|
||||
if ((reg_a != reg_d) || reg_a != 0){
|
||||
if ((reg_a != reg_d) || reg_a != 0) {
|
||||
ppc_effective_address = ppc_result_a + ppc_result_b;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x20000);
|
||||
}
|
||||
address_quickgrab_translate(ppc_effective_address, 4);
|
||||
@ -2258,10 +2273,10 @@ void ppc_lwzux(){
|
||||
ppc_store_result_rega();
|
||||
}
|
||||
|
||||
void ppc_lwarx(){
|
||||
void ppc_lwarx() {
|
||||
//Placeholder - Get the reservation of memory implemented!
|
||||
ppc_grab_regsdab();
|
||||
ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b);
|
||||
ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b);
|
||||
ppc_state.ppc_reserve = true;
|
||||
address_quickgrab_translate(ppc_effective_address, 4);
|
||||
ppc_result_d = return_value;
|
||||
@ -2269,21 +2284,21 @@ void ppc_lwarx(){
|
||||
ppc_store_result_regd();
|
||||
}
|
||||
|
||||
void ppc_lmw(){
|
||||
void ppc_lmw() {
|
||||
ppc_grab_regsda();
|
||||
grab_d = (uint32_t)((int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF)));
|
||||
ppc_effective_address = (reg_a == 0)?grab_d:(ppc_result_a + grab_d);
|
||||
ppc_effective_address = (int32_t)((int16_t)(ppc_cur_instruction & 0xFFFF));
|
||||
ppc_effective_address += (reg_a > 0) ? ppc_result_a : 0;
|
||||
//How many words to load in memory - using a do-while for this
|
||||
do{
|
||||
do {
|
||||
address_quickgrab_translate(ppc_effective_address, 4);
|
||||
ppc_state.ppc_gpr[reg_d] = return_value;
|
||||
return_value = 0;
|
||||
ppc_effective_address +=4;
|
||||
ppc_effective_address += 4;
|
||||
reg_d++;
|
||||
}while (reg_d < 32);
|
||||
} while (reg_d < 32);
|
||||
}
|
||||
|
||||
void ppc_lswi(){
|
||||
void ppc_lswi() {
|
||||
ppc_grab_regsda();
|
||||
ppc_effective_address = ppc_result_a;
|
||||
grab_inb = (ppc_cur_instruction >> 11) & 31;
|
||||
@ -2291,8 +2306,8 @@ void ppc_lswi(){
|
||||
|
||||
uint32_t shift_times = 0;
|
||||
|
||||
while (grab_inb > 0){
|
||||
switch(shift_times){
|
||||
while (grab_inb > 0) {
|
||||
switch (shift_times) {
|
||||
case 0:
|
||||
address_quickgrab_translate(ppc_effective_address, 1);
|
||||
ppc_state.ppc_gpr[reg_d] = (ppc_result_d & 0x00FFFFFFUL) | (return_value << 24);
|
||||
@ -2320,11 +2335,11 @@ void ppc_lswi(){
|
||||
default:
|
||||
printf("Something really horrible happened with lswi.");
|
||||
}
|
||||
if (shift_times == 3){
|
||||
if (shift_times == 3) {
|
||||
shift_times = 0;
|
||||
reg_d = (reg_d + 1) & 0x1F;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
shift_times++;
|
||||
}
|
||||
return_value = 0;
|
||||
@ -2333,20 +2348,20 @@ void ppc_lswi(){
|
||||
}
|
||||
}
|
||||
|
||||
void ppc_lswx(){
|
||||
void ppc_lswx() {
|
||||
ppc_grab_regsdab();
|
||||
//Invalid instruction forms
|
||||
if ((ppc_result_d == 0) && (ppc_result_a == 0)){
|
||||
if ((ppc_result_d == 0) && (ppc_result_a == 0)) {
|
||||
ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x100000);
|
||||
}
|
||||
if ((ppc_result_d == ppc_result_a) || (ppc_result_a == ppc_result_b)){
|
||||
if ((ppc_result_d == ppc_result_a) || (ppc_result_a == ppc_result_b)) {
|
||||
ppc_exception_handler(Except_Type::EXC_PROGRAM, 0x100000);
|
||||
}
|
||||
ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b);
|
||||
ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b);
|
||||
grab_inb = ppc_state.ppc_spr[1] & 127;
|
||||
uint32_t shift_times = 0;
|
||||
while (grab_inb > 0){
|
||||
switch(shift_times){
|
||||
while (grab_inb > 0) {
|
||||
switch (shift_times) {
|
||||
case 0:
|
||||
address_quickgrab_translate(ppc_effective_address, 1);
|
||||
ppc_result_d = (ppc_result_d & 0x00FFFFFFUL) | (return_value << 24);
|
||||
@ -2374,11 +2389,11 @@ void ppc_lswx(){
|
||||
default:
|
||||
printf("Something really horrible happened with lswx.");
|
||||
}
|
||||
if (shift_times == 3){
|
||||
if (shift_times == 3) {
|
||||
shift_times = 0;
|
||||
reg_d = (reg_d + 1) & 0x1F;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
shift_times++;
|
||||
}
|
||||
return_value = 0;
|
||||
@ -2388,14 +2403,14 @@ void ppc_lswx(){
|
||||
|
||||
}
|
||||
|
||||
void ppc_stswi(){
|
||||
void ppc_stswi() {
|
||||
ppc_grab_regssa();
|
||||
ppc_effective_address = (reg_a == 0)?0:ppc_result_a;
|
||||
ppc_effective_address = (reg_a == 0) ? 0 : ppc_result_a;
|
||||
grab_inb = (ppc_cur_instruction >> 11) & 31;
|
||||
grab_inb = (grab_inb & 32) == 0 ? 32 : grab_inb;
|
||||
uint32_t shift_times = 0;
|
||||
while (grab_inb > 0){
|
||||
switch(shift_times){
|
||||
while (grab_inb > 0) {
|
||||
switch (shift_times) {
|
||||
case 0:
|
||||
strwrd_replace_value = (ppc_result_d >> 24);
|
||||
address_quickinsert_translate(strwrd_replace_value, ppc_effective_address, 1);
|
||||
@ -2415,11 +2430,11 @@ void ppc_stswi(){
|
||||
default:
|
||||
printf("Something really horrible happened with stswi.");
|
||||
}
|
||||
if (shift_times == 3){
|
||||
if (shift_times == 3) {
|
||||
shift_times = 0;
|
||||
reg_s = (reg_s + 1) & 0x1F;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
shift_times++;
|
||||
}
|
||||
return_value = 0;
|
||||
@ -2428,13 +2443,13 @@ void ppc_stswi(){
|
||||
}
|
||||
}
|
||||
|
||||
void ppc_stswx(){
|
||||
void ppc_stswx() {
|
||||
ppc_grab_regssab();
|
||||
ppc_effective_address = (reg_a == 0)?ppc_result_b:(ppc_result_a + ppc_result_b);
|
||||
ppc_effective_address = (reg_a == 0) ? ppc_result_b : (ppc_result_a + ppc_result_b);
|
||||
grab_inb = ppc_state.ppc_spr[1] & 127;
|
||||
uint32_t shift_times = 0;
|
||||
while (grab_inb > 0){
|
||||
switch(shift_times){
|
||||
while (grab_inb > 0) {
|
||||
switch (shift_times) {
|
||||
case 0:
|
||||
strwrd_replace_value = (ppc_result_d >> 24);
|
||||
address_quickinsert_translate(strwrd_replace_value, ppc_effective_address, 1);
|
||||
@ -2454,17 +2469,17 @@ void ppc_stswx(){
|
||||
default:
|
||||
printf("Something really horrible happened with stswx.");
|
||||
}
|
||||
if (shift_times == 3){
|
||||
if (shift_times == 3) {
|
||||
shift_times = 0;
|
||||
reg_s = (reg_s + 1) & 0x1F;
|
||||
}
|
||||
else{
|
||||
}
|
||||
else {
|
||||
shift_times++;
|
||||
}
|
||||
return_value = 0;
|
||||
ppc_effective_address++;
|
||||
grab_inb--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TLB Instructions
|
||||
|
3
main.cpp
3
main.cpp
@ -100,7 +100,8 @@ uint8_t write_char;
|
||||
//Initialize the PPC's registers.
|
||||
void reg_init(){
|
||||
for (uint32_t i = 0; i < 32; i++){
|
||||
ppc_state.ppc_fpr[i] = 0;
|
||||
ppc_state.ppc_fpr[i].dbl64_r = 0.0;
|
||||
ppc_state.ppc_fpr[i].int64_r = 0;
|
||||
}
|
||||
ppc_state.ppc_pc = 0;
|
||||
for (uint32_t i = 0; i < 32; i++){
|
||||
|
Loading…
x
Reference in New Issue
Block a user