diff options
| author | 2015-07-26 05:39:54 -0400 | |
|---|---|---|
| committer | 2015-07-26 13:18:32 -0400 | |
| commit | 0ecc6e2f0421aef95f0dd30466e4c69e15020e83 (patch) | |
| tree | fe4f331b08d95df3cae818347b3b94079686e222 /src/core/arm/dyncom | |
| parent | Merge pull request #990 from lioncash/arm (diff) | |
| download | yuzu-0ecc6e2f0421aef95f0dd30466e4c69e15020e83.tar.gz yuzu-0ecc6e2f0421aef95f0dd30466e4c69e15020e83.tar.xz yuzu-0ecc6e2f0421aef95f0dd30466e4c69e15020e83.zip | |
dyncom: Use ARMul_State as an object
Gets rid of C-like parameter passing.
Diffstat (limited to 'src/core/arm/dyncom')
| -rw-r--r-- | src/core/arm/dyncom/arm_dyncom.cpp | 11 | ||||
| -rw-r--r-- | src/core/arm/dyncom/arm_dyncom_interpreter.cpp | 365 | ||||
| -rw-r--r-- | src/core/arm/dyncom/arm_dyncom_run.cpp | 93 | ||||
| -rw-r--r-- | src/core/arm/dyncom/arm_dyncom_run.h | 21 |
4 files changed, 189 insertions, 301 deletions
diff --git a/src/core/arm/dyncom/arm_dyncom.cpp b/src/core/arm/dyncom/arm_dyncom.cpp index a51a3acf8..9228a49ab 100644 --- a/src/core/arm/dyncom/arm_dyncom.cpp +++ b/src/core/arm/dyncom/arm_dyncom.cpp | |||
| @@ -18,16 +18,7 @@ | |||
| 18 | #include "core/core_timing.h" | 18 | #include "core/core_timing.h" |
| 19 | 19 | ||
| 20 | ARM_DynCom::ARM_DynCom(PrivilegeMode initial_mode) { | 20 | ARM_DynCom::ARM_DynCom(PrivilegeMode initial_mode) { |
| 21 | state = Common::make_unique<ARMul_State>(); | 21 | state = Common::make_unique<ARMul_State>(initial_mode); |
| 22 | |||
| 23 | // Reset the core to initial state | ||
| 24 | ARMul_Reset(state.get()); | ||
| 25 | |||
| 26 | // Switch to the desired privilege mode. | ||
| 27 | switch_mode(state.get(), initial_mode); | ||
| 28 | |||
| 29 | state->Reg[13] = 0x10000000; // Set stack pointer to the top of the stack | ||
| 30 | state->Reg[15] = 0x00000000; | ||
| 31 | } | 22 | } |
| 32 | 23 | ||
| 33 | ARM_DynCom::~ARM_DynCom() { | 24 | ARM_DynCom::~ARM_DynCom() { |
diff --git a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp index fd5e13295..cf09acb4e 100644 --- a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp +++ b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp | |||
| @@ -17,7 +17,6 @@ | |||
| 17 | #include "core/arm/dyncom/arm_dyncom_interpreter.h" | 17 | #include "core/arm/dyncom/arm_dyncom_interpreter.h" |
| 18 | #include "core/arm/dyncom/arm_dyncom_thumb.h" | 18 | #include "core/arm/dyncom/arm_dyncom_thumb.h" |
| 19 | #include "core/arm/dyncom/arm_dyncom_run.h" | 19 | #include "core/arm/dyncom/arm_dyncom_run.h" |
| 20 | #include "core/arm/skyeye_common/armmmu.h" | ||
| 21 | #include "core/arm/skyeye_common/armstate.h" | 20 | #include "core/arm/skyeye_common/armstate.h" |
| 22 | #include "core/arm/skyeye_common/armsupp.h" | 21 | #include "core/arm/skyeye_common/armsupp.h" |
| 23 | #include "core/arm/skyeye_common/vfp/vfp.h" | 22 | #include "core/arm/skyeye_common/vfp/vfp.h" |
| @@ -3964,7 +3963,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 3964 | if (inst_cream->S && (inst_cream->Rd == 15)) { | 3963 | if (inst_cream->S && (inst_cream->Rd == 15)) { |
| 3965 | if (CurrentModeHasSPSR) { | 3964 | if (CurrentModeHasSPSR) { |
| 3966 | cpu->Cpsr = cpu->Spsr_copy; | 3965 | cpu->Cpsr = cpu->Spsr_copy; |
| 3967 | switch_mode(cpu, cpu->Spsr_copy & 0x1f); | 3966 | cpu->ChangePrivilegeMode(cpu->Spsr_copy & 0x1F); |
| 3968 | LOAD_NZCVT; | 3967 | LOAD_NZCVT; |
| 3969 | } | 3968 | } |
| 3970 | } else if (inst_cream->S) { | 3969 | } else if (inst_cream->S) { |
| @@ -3978,7 +3977,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 3978 | goto DISPATCH; | 3977 | goto DISPATCH; |
| 3979 | } | 3978 | } |
| 3980 | } | 3979 | } |
| 3981 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 3980 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 3982 | INC_PC(sizeof(adc_inst)); | 3981 | INC_PC(sizeof(adc_inst)); |
| 3983 | FETCH_INST; | 3982 | FETCH_INST; |
| 3984 | GOTO_NEXT_INST; | 3983 | GOTO_NEXT_INST; |
| @@ -3990,7 +3989,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 3990 | 3989 | ||
| 3991 | u32 rn_val = RN; | 3990 | u32 rn_val = RN; |
| 3992 | if (inst_cream->Rn == 15) | 3991 | if (inst_cream->Rn == 15) |
| 3993 | rn_val += 2 * GET_INST_SIZE(cpu); | 3992 | rn_val += 2 * cpu->GetInstructionSize(); |
| 3994 | 3993 | ||
| 3995 | bool carry; | 3994 | bool carry; |
| 3996 | bool overflow; | 3995 | bool overflow; |
| @@ -3999,7 +3998,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 3999 | if (inst_cream->S && (inst_cream->Rd == 15)) { | 3998 | if (inst_cream->S && (inst_cream->Rd == 15)) { |
| 4000 | if (CurrentModeHasSPSR) { | 3999 | if (CurrentModeHasSPSR) { |
| 4001 | cpu->Cpsr = cpu->Spsr_copy; | 4000 | cpu->Cpsr = cpu->Spsr_copy; |
| 4002 | switch_mode(cpu, cpu->Cpsr & 0x1f); | 4001 | cpu->ChangePrivilegeMode(cpu->Cpsr & 0x1F); |
| 4003 | LOAD_NZCVT; | 4002 | LOAD_NZCVT; |
| 4004 | } | 4003 | } |
| 4005 | } else if (inst_cream->S) { | 4004 | } else if (inst_cream->S) { |
| @@ -4013,7 +4012,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4013 | goto DISPATCH; | 4012 | goto DISPATCH; |
| 4014 | } | 4013 | } |
| 4015 | } | 4014 | } |
| 4016 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4015 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4017 | INC_PC(sizeof(add_inst)); | 4016 | INC_PC(sizeof(add_inst)); |
| 4018 | FETCH_INST; | 4017 | FETCH_INST; |
| 4019 | GOTO_NEXT_INST; | 4018 | GOTO_NEXT_INST; |
| @@ -4028,7 +4027,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4028 | if (inst_cream->S && (inst_cream->Rd == 15)) { | 4027 | if (inst_cream->S && (inst_cream->Rd == 15)) { |
| 4029 | if (CurrentModeHasSPSR) { | 4028 | if (CurrentModeHasSPSR) { |
| 4030 | cpu->Cpsr = cpu->Spsr_copy; | 4029 | cpu->Cpsr = cpu->Spsr_copy; |
| 4031 | switch_mode(cpu, cpu->Cpsr & 0x1f); | 4030 | cpu->ChangePrivilegeMode(cpu->Cpsr & 0x1F); |
| 4032 | LOAD_NZCVT; | 4031 | LOAD_NZCVT; |
| 4033 | } | 4032 | } |
| 4034 | } else if (inst_cream->S) { | 4033 | } else if (inst_cream->S) { |
| @@ -4041,7 +4040,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4041 | goto DISPATCH; | 4040 | goto DISPATCH; |
| 4042 | } | 4041 | } |
| 4043 | } | 4042 | } |
| 4044 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4043 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4045 | INC_PC(sizeof(and_inst)); | 4044 | INC_PC(sizeof(and_inst)); |
| 4046 | FETCH_INST; | 4045 | FETCH_INST; |
| 4047 | GOTO_NEXT_INST; | 4046 | GOTO_NEXT_INST; |
| @@ -4057,7 +4056,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4057 | INC_PC(sizeof(bbl_inst)); | 4056 | INC_PC(sizeof(bbl_inst)); |
| 4058 | goto DISPATCH; | 4057 | goto DISPATCH; |
| 4059 | } | 4058 | } |
| 4060 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4059 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4061 | INC_PC(sizeof(bbl_inst)); | 4060 | INC_PC(sizeof(bbl_inst)); |
| 4062 | goto DISPATCH; | 4061 | goto DISPATCH; |
| 4063 | } | 4062 | } |
| @@ -4067,14 +4066,14 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4067 | if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) { | 4066 | if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) { |
| 4068 | u32 lop = RN; | 4067 | u32 lop = RN; |
| 4069 | if (inst_cream->Rn == 15) { | 4068 | if (inst_cream->Rn == 15) { |
| 4070 | lop += 2 * GET_INST_SIZE(cpu); | 4069 | lop += 2 * cpu->GetInstructionSize(); |
| 4071 | } | 4070 | } |
| 4072 | u32 rop = SHIFTER_OPERAND; | 4071 | u32 rop = SHIFTER_OPERAND; |
| 4073 | RD = lop & (~rop); | 4072 | RD = lop & (~rop); |
| 4074 | if ((inst_cream->S) && (inst_cream->Rd == 15)) { | 4073 | if ((inst_cream->S) && (inst_cream->Rd == 15)) { |
| 4075 | if (CurrentModeHasSPSR) { | 4074 | if (CurrentModeHasSPSR) { |
| 4076 | cpu->Cpsr = cpu->Spsr_copy; | 4075 | cpu->Cpsr = cpu->Spsr_copy; |
| 4077 | switch_mode(cpu, cpu->Spsr_copy & 0x1f); | 4076 | cpu->ChangePrivilegeMode(cpu->Spsr_copy & 0x1F); |
| 4078 | LOAD_NZCVT; | 4077 | LOAD_NZCVT; |
| 4079 | } | 4078 | } |
| 4080 | } else if (inst_cream->S) { | 4079 | } else if (inst_cream->S) { |
| @@ -4087,7 +4086,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4087 | goto DISPATCH; | 4086 | goto DISPATCH; |
| 4088 | } | 4087 | } |
| 4089 | } | 4088 | } |
| 4090 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4089 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4091 | INC_PC(sizeof(bic_inst)); | 4090 | INC_PC(sizeof(bic_inst)); |
| 4092 | FETCH_INST; | 4091 | FETCH_INST; |
| 4093 | GOTO_NEXT_INST; | 4092 | GOTO_NEXT_INST; |
| @@ -4098,7 +4097,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4098 | bkpt_inst* const inst_cream = (bkpt_inst*)inst_base->component; | 4097 | bkpt_inst* const inst_cream = (bkpt_inst*)inst_base->component; |
| 4099 | LOG_DEBUG(Core_ARM11, "Breakpoint instruction hit. Immediate: 0x%08X", inst_cream->imm); | 4098 | LOG_DEBUG(Core_ARM11, "Breakpoint instruction hit. Immediate: 0x%08X", inst_cream->imm); |
| 4100 | } | 4099 | } |
| 4101 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4100 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4102 | INC_PC(sizeof(bkpt_inst)); | 4101 | INC_PC(sizeof(bkpt_inst)); |
| 4103 | FETCH_INST; | 4102 | FETCH_INST; |
| 4104 | GOTO_NEXT_INST; | 4103 | GOTO_NEXT_INST; |
| @@ -4109,13 +4108,13 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4109 | if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) { | 4108 | if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) { |
| 4110 | unsigned int inst = inst_cream->inst; | 4109 | unsigned int inst = inst_cream->inst; |
| 4111 | if (BITS(inst, 20, 27) == 0x12 && BITS(inst, 4, 7) == 0x3) { | 4110 | if (BITS(inst, 20, 27) == 0x12 && BITS(inst, 4, 7) == 0x3) { |
| 4112 | cpu->Reg[14] = (cpu->Reg[15] + GET_INST_SIZE(cpu)); | 4111 | cpu->Reg[14] = (cpu->Reg[15] + cpu->GetInstructionSize()); |
| 4113 | if(cpu->TFlag) | 4112 | if(cpu->TFlag) |
| 4114 | cpu->Reg[14] |= 0x1; | 4113 | cpu->Reg[14] |= 0x1; |
| 4115 | cpu->Reg[15] = cpu->Reg[inst_cream->val.Rm] & 0xfffffffe; | 4114 | cpu->Reg[15] = cpu->Reg[inst_cream->val.Rm] & 0xfffffffe; |
| 4116 | cpu->TFlag = cpu->Reg[inst_cream->val.Rm] & 0x1; | 4115 | cpu->TFlag = cpu->Reg[inst_cream->val.Rm] & 0x1; |
| 4117 | } else { | 4116 | } else { |
| 4118 | cpu->Reg[14] = (cpu->Reg[15] + GET_INST_SIZE(cpu)); | 4117 | cpu->Reg[14] = (cpu->Reg[15] + cpu->GetInstructionSize()); |
| 4119 | cpu->TFlag = 0x1; | 4118 | cpu->TFlag = 0x1; |
| 4120 | int signed_int = inst_cream->val.signed_immed_24; | 4119 | int signed_int = inst_cream->val.signed_immed_24; |
| 4121 | signed_int = (signed_int & 0x800000) ? (0x3F000000 | signed_int) : signed_int; | 4120 | signed_int = (signed_int & 0x800000) ? (0x3F000000 | signed_int) : signed_int; |
| @@ -4125,7 +4124,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4125 | INC_PC(sizeof(blx_inst)); | 4124 | INC_PC(sizeof(blx_inst)); |
| 4126 | goto DISPATCH; | 4125 | goto DISPATCH; |
| 4127 | } | 4126 | } |
| 4128 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4127 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4129 | INC_PC(sizeof(blx_inst)); | 4128 | INC_PC(sizeof(blx_inst)); |
| 4130 | goto DISPATCH; | 4129 | goto DISPATCH; |
| 4131 | } | 4130 | } |
| @@ -4147,7 +4146,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4147 | u32 address = RM; | 4146 | u32 address = RM; |
| 4148 | 4147 | ||
| 4149 | if (inst_cream->Rm == 15) | 4148 | if (inst_cream->Rm == 15) |
| 4150 | address += 2 * GET_INST_SIZE(cpu); | 4149 | address += 2 * cpu->GetInstructionSize(); |
| 4151 | 4150 | ||
| 4152 | cpu->TFlag = address & 1; | 4151 | cpu->TFlag = address & 1; |
| 4153 | cpu->Reg[15] = address & 0xfffffffe; | 4152 | cpu->Reg[15] = address & 0xfffffffe; |
| @@ -4155,7 +4154,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4155 | goto DISPATCH; | 4154 | goto DISPATCH; |
| 4156 | } | 4155 | } |
| 4157 | 4156 | ||
| 4158 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4157 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4159 | INC_PC(sizeof(bx_inst)); | 4158 | INC_PC(sizeof(bx_inst)); |
| 4160 | goto DISPATCH; | 4159 | goto DISPATCH; |
| 4161 | } | 4160 | } |
| @@ -4167,7 +4166,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4167 | cpu->NumInstrsToExecute = 0; | 4166 | cpu->NumInstrsToExecute = 0; |
| 4168 | return num_instrs; | 4167 | return num_instrs; |
| 4169 | } | 4168 | } |
| 4170 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4169 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4171 | INC_PC(sizeof(cdp_inst)); | 4170 | INC_PC(sizeof(cdp_inst)); |
| 4172 | FETCH_INST; | 4171 | FETCH_INST; |
| 4173 | GOTO_NEXT_INST; | 4172 | GOTO_NEXT_INST; |
| @@ -4178,7 +4177,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4178 | remove_exclusive(cpu, 0); | 4177 | remove_exclusive(cpu, 0); |
| 4179 | cpu->exclusive_state = 0; | 4178 | cpu->exclusive_state = 0; |
| 4180 | 4179 | ||
| 4181 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4180 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4182 | INC_PC(sizeof(clrex_inst)); | 4181 | INC_PC(sizeof(clrex_inst)); |
| 4183 | FETCH_INST; | 4182 | FETCH_INST; |
| 4184 | GOTO_NEXT_INST; | 4183 | GOTO_NEXT_INST; |
| @@ -4189,7 +4188,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4189 | clz_inst* inst_cream = (clz_inst*)inst_base->component; | 4188 | clz_inst* inst_cream = (clz_inst*)inst_base->component; |
| 4190 | RD = clz(RM); | 4189 | RD = clz(RM); |
| 4191 | } | 4190 | } |
| 4192 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4191 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4193 | INC_PC(sizeof(clz_inst)); | 4192 | INC_PC(sizeof(clz_inst)); |
| 4194 | FETCH_INST; | 4193 | FETCH_INST; |
| 4195 | GOTO_NEXT_INST; | 4194 | GOTO_NEXT_INST; |
| @@ -4208,7 +4207,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4208 | cpu->CFlag = carry; | 4207 | cpu->CFlag = carry; |
| 4209 | cpu->VFlag = overflow; | 4208 | cpu->VFlag = overflow; |
| 4210 | } | 4209 | } |
| 4211 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4210 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4212 | INC_PC(sizeof(cmn_inst)); | 4211 | INC_PC(sizeof(cmn_inst)); |
| 4213 | FETCH_INST; | 4212 | FETCH_INST; |
| 4214 | GOTO_NEXT_INST; | 4213 | GOTO_NEXT_INST; |
| @@ -4220,7 +4219,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4220 | 4219 | ||
| 4221 | u32 rn_val = RN; | 4220 | u32 rn_val = RN; |
| 4222 | if (inst_cream->Rn == 15) | 4221 | if (inst_cream->Rn == 15) |
| 4223 | rn_val += 2 * GET_INST_SIZE(cpu); | 4222 | rn_val += 2 * cpu->GetInstructionSize(); |
| 4224 | 4223 | ||
| 4225 | bool carry; | 4224 | bool carry; |
| 4226 | bool overflow; | 4225 | bool overflow; |
| @@ -4231,7 +4230,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4231 | cpu->CFlag = carry; | 4230 | cpu->CFlag = carry; |
| 4232 | cpu->VFlag = overflow; | 4231 | cpu->VFlag = overflow; |
| 4233 | } | 4232 | } |
| 4234 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4233 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4235 | INC_PC(sizeof(cmp_inst)); | 4234 | INC_PC(sizeof(cmp_inst)); |
| 4236 | FETCH_INST; | 4235 | FETCH_INST; |
| 4237 | GOTO_NEXT_INST; | 4236 | GOTO_NEXT_INST; |
| @@ -4241,7 +4240,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4241 | cps_inst *inst_cream = (cps_inst *)inst_base->component; | 4240 | cps_inst *inst_cream = (cps_inst *)inst_base->component; |
| 4242 | uint32_t aif_val = 0; | 4241 | uint32_t aif_val = 0; |
| 4243 | uint32_t aif_mask = 0; | 4242 | uint32_t aif_mask = 0; |
| 4244 | if (InAPrivilegedMode(cpu)) { | 4243 | if (cpu->InAPrivilegedMode()) { |
| 4245 | if (inst_cream->imod1) { | 4244 | if (inst_cream->imod1) { |
| 4246 | if (inst_cream->A) { | 4245 | if (inst_cream->A) { |
| 4247 | aif_val |= (inst_cream->imod0 << 8); | 4246 | aif_val |= (inst_cream->imod0 << 8); |
| @@ -4260,10 +4259,10 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4260 | } | 4259 | } |
| 4261 | if (inst_cream->mmod) { | 4260 | if (inst_cream->mmod) { |
| 4262 | cpu->Cpsr = (cpu->Cpsr & 0xffffffe0) | inst_cream->mode; | 4261 | cpu->Cpsr = (cpu->Cpsr & 0xffffffe0) | inst_cream->mode; |
| 4263 | switch_mode(cpu, inst_cream->mode); | 4262 | cpu->ChangePrivilegeMode(inst_cream->mode); |
| 4264 | } | 4263 | } |
| 4265 | } | 4264 | } |
| 4266 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4265 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4267 | INC_PC(sizeof(cps_inst)); | 4266 | INC_PC(sizeof(cps_inst)); |
| 4268 | FETCH_INST; | 4267 | FETCH_INST; |
| 4269 | GOTO_NEXT_INST; | 4268 | GOTO_NEXT_INST; |
| @@ -4279,7 +4278,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4279 | goto DISPATCH; | 4278 | goto DISPATCH; |
| 4280 | } | 4279 | } |
| 4281 | } | 4280 | } |
| 4282 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4281 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4283 | INC_PC(sizeof(mov_inst)); | 4282 | INC_PC(sizeof(mov_inst)); |
| 4284 | FETCH_INST; | 4283 | FETCH_INST; |
| 4285 | GOTO_NEXT_INST; | 4284 | GOTO_NEXT_INST; |
| @@ -4291,14 +4290,14 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4291 | 4290 | ||
| 4292 | u32 lop = RN; | 4291 | u32 lop = RN; |
| 4293 | if (inst_cream->Rn == 15) { | 4292 | if (inst_cream->Rn == 15) { |
| 4294 | lop += 2 * GET_INST_SIZE(cpu); | 4293 | lop += 2 * cpu->GetInstructionSize(); |
| 4295 | } | 4294 | } |
| 4296 | u32 rop = SHIFTER_OPERAND; | 4295 | u32 rop = SHIFTER_OPERAND; |
| 4297 | RD = lop ^ rop; | 4296 | RD = lop ^ rop; |
| 4298 | if (inst_cream->S && (inst_cream->Rd == 15)) { | 4297 | if (inst_cream->S && (inst_cream->Rd == 15)) { |
| 4299 | if (CurrentModeHasSPSR) { | 4298 | if (CurrentModeHasSPSR) { |
| 4300 | cpu->Cpsr = cpu->Spsr_copy; | 4299 | cpu->Cpsr = cpu->Spsr_copy; |
| 4301 | switch_mode(cpu, cpu->Spsr_copy & 0x1f); | 4300 | cpu->ChangePrivilegeMode(cpu->Spsr_copy & 0x1F); |
| 4302 | LOAD_NZCVT; | 4301 | LOAD_NZCVT; |
| 4303 | } | 4302 | } |
| 4304 | } else if (inst_cream->S) { | 4303 | } else if (inst_cream->S) { |
| @@ -4311,7 +4310,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4311 | goto DISPATCH; | 4310 | goto DISPATCH; |
| 4312 | } | 4311 | } |
| 4313 | } | 4312 | } |
| 4314 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4313 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4315 | INC_PC(sizeof(eor_inst)); | 4314 | INC_PC(sizeof(eor_inst)); |
| 4316 | FETCH_INST; | 4315 | FETCH_INST; |
| 4317 | GOTO_NEXT_INST; | 4316 | GOTO_NEXT_INST; |
| @@ -4320,7 +4319,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4320 | { | 4319 | { |
| 4321 | // Instruction not implemented | 4320 | // Instruction not implemented |
| 4322 | //LOG_CRITICAL(Core_ARM11, "unimplemented instruction"); | 4321 | //LOG_CRITICAL(Core_ARM11, "unimplemented instruction"); |
| 4323 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4322 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4324 | INC_PC(sizeof(ldc_inst)); | 4323 | INC_PC(sizeof(ldc_inst)); |
| 4325 | FETCH_INST; | 4324 | FETCH_INST; |
| 4326 | GOTO_NEXT_INST; | 4325 | GOTO_NEXT_INST; |
| @@ -4335,30 +4334,30 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4335 | if (BIT(inst, 22) && !BIT(inst, 15)) { | 4334 | if (BIT(inst, 22) && !BIT(inst, 15)) { |
| 4336 | for (int i = 0; i < 13; i++) { | 4335 | for (int i = 0; i < 13; i++) { |
| 4337 | if(BIT(inst, i)) { | 4336 | if(BIT(inst, i)) { |
| 4338 | cpu->Reg[i] = ReadMemory32(cpu, addr); | 4337 | cpu->Reg[i] = cpu->ReadMemory32(addr); |
| 4339 | addr += 4; | 4338 | addr += 4; |
| 4340 | } | 4339 | } |
| 4341 | } | 4340 | } |
| 4342 | if (BIT(inst, 13)) { | 4341 | if (BIT(inst, 13)) { |
| 4343 | if (cpu->Mode == USER32MODE) | 4342 | if (cpu->Mode == USER32MODE) |
| 4344 | cpu->Reg[13] = ReadMemory32(cpu, addr); | 4343 | cpu->Reg[13] = cpu->ReadMemory32(addr); |
| 4345 | else | 4344 | else |
| 4346 | cpu->Reg_usr[0] = ReadMemory32(cpu, addr); | 4345 | cpu->Reg_usr[0] = cpu->ReadMemory32(addr); |
| 4347 | 4346 | ||
| 4348 | addr += 4; | 4347 | addr += 4; |
| 4349 | } | 4348 | } |
| 4350 | if (BIT(inst, 14)) { | 4349 | if (BIT(inst, 14)) { |
| 4351 | if (cpu->Mode == USER32MODE) | 4350 | if (cpu->Mode == USER32MODE) |
| 4352 | cpu->Reg[14] = ReadMemory32(cpu, addr); | 4351 | cpu->Reg[14] = cpu->ReadMemory32(addr); |
| 4353 | else | 4352 | else |
| 4354 | cpu->Reg_usr[1] = ReadMemory32(cpu, addr); | 4353 | cpu->Reg_usr[1] = cpu->ReadMemory32(addr); |
| 4355 | 4354 | ||
| 4356 | addr += 4; | 4355 | addr += 4; |
| 4357 | } | 4356 | } |
| 4358 | } else if (!BIT(inst, 22)) { | 4357 | } else if (!BIT(inst, 22)) { |
| 4359 | for(int i = 0; i < 16; i++ ){ | 4358 | for(int i = 0; i < 16; i++ ){ |
| 4360 | if(BIT(inst, i)){ | 4359 | if(BIT(inst, i)){ |
| 4361 | unsigned int ret = ReadMemory32(cpu, addr); | 4360 | unsigned int ret = cpu->ReadMemory32(addr); |
| 4362 | 4361 | ||
| 4363 | // For armv5t, should enter thumb when bits[0] is non-zero. | 4362 | // For armv5t, should enter thumb when bits[0] is non-zero. |
| 4364 | if(i == 15){ | 4363 | if(i == 15){ |
| @@ -4373,18 +4372,18 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4373 | } else if (BIT(inst, 22) && BIT(inst, 15)) { | 4372 | } else if (BIT(inst, 22) && BIT(inst, 15)) { |
| 4374 | for(int i = 0; i < 15; i++ ){ | 4373 | for(int i = 0; i < 15; i++ ){ |
| 4375 | if(BIT(inst, i)){ | 4374 | if(BIT(inst, i)){ |
| 4376 | cpu->Reg[i] = ReadMemory32(cpu, addr); | 4375 | cpu->Reg[i] = cpu->ReadMemory32(addr); |
| 4377 | addr += 4; | 4376 | addr += 4; |
| 4378 | } | 4377 | } |
| 4379 | } | 4378 | } |
| 4380 | 4379 | ||
| 4381 | if (CurrentModeHasSPSR) { | 4380 | if (CurrentModeHasSPSR) { |
| 4382 | cpu->Cpsr = cpu->Spsr_copy; | 4381 | cpu->Cpsr = cpu->Spsr_copy; |
| 4383 | switch_mode(cpu, cpu->Cpsr & 0x1f); | 4382 | cpu->ChangePrivilegeMode(cpu->Cpsr & 0x1F); |
| 4384 | LOAD_NZCVT; | 4383 | LOAD_NZCVT; |
| 4385 | } | 4384 | } |
| 4386 | 4385 | ||
| 4387 | cpu->Reg[15] = ReadMemory32(cpu, addr); | 4386 | cpu->Reg[15] = cpu->ReadMemory32(addr); |
| 4388 | } | 4387 | } |
| 4389 | 4388 | ||
| 4390 | if (BIT(inst, 15)) { | 4389 | if (BIT(inst, 15)) { |
| @@ -4392,7 +4391,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4392 | goto DISPATCH; | 4391 | goto DISPATCH; |
| 4393 | } | 4392 | } |
| 4394 | } | 4393 | } |
| 4395 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4394 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4396 | INC_PC(sizeof(ldst_inst)); | 4395 | INC_PC(sizeof(ldst_inst)); |
| 4397 | FETCH_INST; | 4396 | FETCH_INST; |
| 4398 | GOTO_NEXT_INST; | 4397 | GOTO_NEXT_INST; |
| @@ -4410,7 +4409,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4410 | } | 4409 | } |
| 4411 | RD = operand2; | 4410 | RD = operand2; |
| 4412 | } | 4411 | } |
| 4413 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4412 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4414 | INC_PC(sizeof(sxth_inst)); | 4413 | INC_PC(sizeof(sxth_inst)); |
| 4415 | FETCH_INST; | 4414 | FETCH_INST; |
| 4416 | GOTO_NEXT_INST; | 4415 | GOTO_NEXT_INST; |
| @@ -4420,7 +4419,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4420 | ldst_inst *inst_cream = (ldst_inst *)inst_base->component; | 4419 | ldst_inst *inst_cream = (ldst_inst *)inst_base->component; |
| 4421 | inst_cream->get_addr(cpu, inst_cream->inst, addr); | 4420 | inst_cream->get_addr(cpu, inst_cream->inst, addr); |
| 4422 | 4421 | ||
| 4423 | unsigned int value = ReadMemory32(cpu, addr); | 4422 | unsigned int value = cpu->ReadMemory32(addr); |
| 4424 | cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value; | 4423 | cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value; |
| 4425 | 4424 | ||
| 4426 | if (BITS(inst_cream->inst, 12, 15) == 15) { | 4425 | if (BITS(inst_cream->inst, 12, 15) == 15) { |
| @@ -4431,7 +4430,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4431 | goto DISPATCH; | 4430 | goto DISPATCH; |
| 4432 | } | 4431 | } |
| 4433 | 4432 | ||
| 4434 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4433 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4435 | INC_PC(sizeof(ldst_inst)); | 4434 | INC_PC(sizeof(ldst_inst)); |
| 4436 | FETCH_INST; | 4435 | FETCH_INST; |
| 4437 | GOTO_NEXT_INST; | 4436 | GOTO_NEXT_INST; |
| @@ -4442,7 +4441,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4442 | ldst_inst *inst_cream = (ldst_inst *)inst_base->component; | 4441 | ldst_inst *inst_cream = (ldst_inst *)inst_base->component; |
| 4443 | inst_cream->get_addr(cpu, inst_cream->inst, addr); | 4442 | inst_cream->get_addr(cpu, inst_cream->inst, addr); |
| 4444 | 4443 | ||
| 4445 | unsigned int value = ReadMemory32(cpu, addr); | 4444 | unsigned int value = cpu->ReadMemory32(addr); |
| 4446 | cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value; | 4445 | cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value; |
| 4447 | 4446 | ||
| 4448 | if (BITS(inst_cream->inst, 12, 15) == 15) { | 4447 | if (BITS(inst_cream->inst, 12, 15) == 15) { |
| @@ -4453,7 +4452,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4453 | goto DISPATCH; | 4452 | goto DISPATCH; |
| 4454 | } | 4453 | } |
| 4455 | } | 4454 | } |
| 4456 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4455 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4457 | INC_PC(sizeof(ldst_inst)); | 4456 | INC_PC(sizeof(ldst_inst)); |
| 4458 | FETCH_INST; | 4457 | FETCH_INST; |
| 4459 | GOTO_NEXT_INST; | 4458 | GOTO_NEXT_INST; |
| @@ -4464,7 +4463,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4464 | uxth_inst* inst_cream = (uxth_inst*)inst_base->component; | 4463 | uxth_inst* inst_cream = (uxth_inst*)inst_base->component; |
| 4465 | RD = ROTATE_RIGHT_32(RM, 8 * inst_cream->rotate) & 0xffff; | 4464 | RD = ROTATE_RIGHT_32(RM, 8 * inst_cream->rotate) & 0xffff; |
| 4466 | } | 4465 | } |
| 4467 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4466 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4468 | INC_PC(sizeof(uxth_inst)); | 4467 | INC_PC(sizeof(uxth_inst)); |
| 4469 | FETCH_INST; | 4468 | FETCH_INST; |
| 4470 | GOTO_NEXT_INST; | 4469 | GOTO_NEXT_INST; |
| @@ -4477,7 +4476,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4477 | 4476 | ||
| 4478 | RD = RN + operand2; | 4477 | RD = RN + operand2; |
| 4479 | } | 4478 | } |
| 4480 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4479 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4481 | INC_PC(sizeof(uxtah_inst)); | 4480 | INC_PC(sizeof(uxtah_inst)); |
| 4482 | FETCH_INST; | 4481 | FETCH_INST; |
| 4483 | GOTO_NEXT_INST; | 4482 | GOTO_NEXT_INST; |
| @@ -4495,7 +4494,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4495 | goto DISPATCH; | 4494 | goto DISPATCH; |
| 4496 | } | 4495 | } |
| 4497 | } | 4496 | } |
| 4498 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4497 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4499 | INC_PC(sizeof(ldst_inst)); | 4498 | INC_PC(sizeof(ldst_inst)); |
| 4500 | FETCH_INST; | 4499 | FETCH_INST; |
| 4501 | GOTO_NEXT_INST; | 4500 | GOTO_NEXT_INST; |
| @@ -4513,7 +4512,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4513 | goto DISPATCH; | 4512 | goto DISPATCH; |
| 4514 | } | 4513 | } |
| 4515 | } | 4514 | } |
| 4516 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4515 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4517 | INC_PC(sizeof(ldst_inst)); | 4516 | INC_PC(sizeof(ldst_inst)); |
| 4518 | FETCH_INST; | 4517 | FETCH_INST; |
| 4519 | GOTO_NEXT_INST; | 4518 | GOTO_NEXT_INST; |
| @@ -4527,8 +4526,8 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4527 | 4526 | ||
| 4528 | // The 3DS doesn't have LPAE (Large Physical Access Extension), so it | 4527 | // The 3DS doesn't have LPAE (Large Physical Access Extension), so it |
| 4529 | // wouldn't do this as a single read. | 4528 | // wouldn't do this as a single read. |
| 4530 | cpu->Reg[BITS(inst_cream->inst, 12, 15) + 0] = ReadMemory32(cpu, addr); | 4529 | cpu->Reg[BITS(inst_cream->inst, 12, 15) + 0] = cpu->ReadMemory32(addr); |
| 4531 | cpu->Reg[BITS(inst_cream->inst, 12, 15) + 1] = ReadMemory32(cpu, addr + 4); | 4530 | cpu->Reg[BITS(inst_cream->inst, 12, 15) + 1] = cpu->ReadMemory32(addr + 4); |
| 4532 | 4531 | ||
| 4533 | // No dispatch since this operation should not modify R15 | 4532 | // No dispatch since this operation should not modify R15 |
| 4534 | } | 4533 | } |
| @@ -4547,13 +4546,13 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4547 | add_exclusive_addr(cpu, read_addr); | 4546 | add_exclusive_addr(cpu, read_addr); |
| 4548 | cpu->exclusive_state = 1; | 4547 | cpu->exclusive_state = 1; |
| 4549 | 4548 | ||
| 4550 | RD = ReadMemory32(cpu, read_addr); | 4549 | RD = cpu->ReadMemory32(read_addr); |
| 4551 | if (inst_cream->Rd == 15) { | 4550 | if (inst_cream->Rd == 15) { |
| 4552 | INC_PC(sizeof(generic_arm_inst)); | 4551 | INC_PC(sizeof(generic_arm_inst)); |
| 4553 | goto DISPATCH; | 4552 | goto DISPATCH; |
| 4554 | } | 4553 | } |
| 4555 | } | 4554 | } |
| 4556 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4555 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4557 | INC_PC(sizeof(generic_arm_inst)); | 4556 | INC_PC(sizeof(generic_arm_inst)); |
| 4558 | FETCH_INST; | 4557 | FETCH_INST; |
| 4559 | GOTO_NEXT_INST; | 4558 | GOTO_NEXT_INST; |
| @@ -4573,7 +4572,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4573 | goto DISPATCH; | 4572 | goto DISPATCH; |
| 4574 | } | 4573 | } |
| 4575 | } | 4574 | } |
| 4576 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4575 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4577 | INC_PC(sizeof(generic_arm_inst)); | 4576 | INC_PC(sizeof(generic_arm_inst)); |
| 4578 | FETCH_INST; | 4577 | FETCH_INST; |
| 4579 | GOTO_NEXT_INST; | 4578 | GOTO_NEXT_INST; |
| @@ -4587,13 +4586,13 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4587 | add_exclusive_addr(cpu, read_addr); | 4586 | add_exclusive_addr(cpu, read_addr); |
| 4588 | cpu->exclusive_state = 1; | 4587 | cpu->exclusive_state = 1; |
| 4589 | 4588 | ||
| 4590 | RD = ReadMemory16(cpu, read_addr); | 4589 | RD = cpu->ReadMemory16(read_addr); |
| 4591 | if (inst_cream->Rd == 15) { | 4590 | if (inst_cream->Rd == 15) { |
| 4592 | INC_PC(sizeof(generic_arm_inst)); | 4591 | INC_PC(sizeof(generic_arm_inst)); |
| 4593 | goto DISPATCH; | 4592 | goto DISPATCH; |
| 4594 | } | 4593 | } |
| 4595 | } | 4594 | } |
| 4596 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4595 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4597 | INC_PC(sizeof(generic_arm_inst)); | 4596 | INC_PC(sizeof(generic_arm_inst)); |
| 4598 | FETCH_INST; | 4597 | FETCH_INST; |
| 4599 | GOTO_NEXT_INST; | 4598 | GOTO_NEXT_INST; |
| @@ -4607,15 +4606,15 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4607 | add_exclusive_addr(cpu, read_addr); | 4606 | add_exclusive_addr(cpu, read_addr); |
| 4608 | cpu->exclusive_state = 1; | 4607 | cpu->exclusive_state = 1; |
| 4609 | 4608 | ||
| 4610 | RD = ReadMemory32(cpu, read_addr); | 4609 | RD = cpu->ReadMemory32(read_addr); |
| 4611 | RD2 = ReadMemory32(cpu, read_addr + 4); | 4610 | RD2 = cpu->ReadMemory32(read_addr + 4); |
| 4612 | 4611 | ||
| 4613 | if (inst_cream->Rd == 15) { | 4612 | if (inst_cream->Rd == 15) { |
| 4614 | INC_PC(sizeof(generic_arm_inst)); | 4613 | INC_PC(sizeof(generic_arm_inst)); |
| 4615 | goto DISPATCH; | 4614 | goto DISPATCH; |
| 4616 | } | 4615 | } |
| 4617 | } | 4616 | } |
| 4618 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4617 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4619 | INC_PC(sizeof(generic_arm_inst)); | 4618 | INC_PC(sizeof(generic_arm_inst)); |
| 4620 | FETCH_INST; | 4619 | FETCH_INST; |
| 4621 | GOTO_NEXT_INST; | 4620 | GOTO_NEXT_INST; |
| @@ -4626,13 +4625,13 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4626 | ldst_inst* inst_cream = (ldst_inst*)inst_base->component; | 4625 | ldst_inst* inst_cream = (ldst_inst*)inst_base->component; |
| 4627 | inst_cream->get_addr(cpu, inst_cream->inst, addr); | 4626 | inst_cream->get_addr(cpu, inst_cream->inst, addr); |
| 4628 | 4627 | ||
| 4629 | cpu->Reg[BITS(inst_cream->inst, 12, 15)] = ReadMemory16(cpu, addr); | 4628 | cpu->Reg[BITS(inst_cream->inst, 12, 15)] = cpu->ReadMemory16(addr); |
| 4630 | if (BITS(inst_cream->inst, 12, 15) == 15) { | 4629 | if (BITS(inst_cream->inst, 12, 15) == 15) { |
| 4631 | INC_PC(sizeof(ldst_inst)); | 4630 | INC_PC(sizeof(ldst_inst)); |
| 4632 | goto DISPATCH; | 4631 | goto DISPATCH; |
| 4633 | } | 4632 | } |
| 4634 | } | 4633 | } |
| 4635 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4634 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4636 | INC_PC(sizeof(ldst_inst)); | 4635 | INC_PC(sizeof(ldst_inst)); |
| 4637 | FETCH_INST; | 4636 | FETCH_INST; |
| 4638 | GOTO_NEXT_INST; | 4637 | GOTO_NEXT_INST; |
| @@ -4652,7 +4651,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4652 | goto DISPATCH; | 4651 | goto DISPATCH; |
| 4653 | } | 4652 | } |
| 4654 | } | 4653 | } |
| 4655 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4654 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4656 | INC_PC(sizeof(ldst_inst)); | 4655 | INC_PC(sizeof(ldst_inst)); |
| 4657 | FETCH_INST; | 4656 | FETCH_INST; |
| 4658 | GOTO_NEXT_INST; | 4657 | GOTO_NEXT_INST; |
| @@ -4663,7 +4662,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4663 | ldst_inst* inst_cream = (ldst_inst*)inst_base->component; | 4662 | ldst_inst* inst_cream = (ldst_inst*)inst_base->component; |
| 4664 | inst_cream->get_addr(cpu, inst_cream->inst, addr); | 4663 | inst_cream->get_addr(cpu, inst_cream->inst, addr); |
| 4665 | 4664 | ||
| 4666 | unsigned int value = ReadMemory16(cpu, addr); | 4665 | unsigned int value = cpu->ReadMemory16(addr); |
| 4667 | if (BIT(value, 15)) { | 4666 | if (BIT(value, 15)) { |
| 4668 | value |= 0xffff0000; | 4667 | value |= 0xffff0000; |
| 4669 | } | 4668 | } |
| @@ -4673,7 +4672,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4673 | goto DISPATCH; | 4672 | goto DISPATCH; |
| 4674 | } | 4673 | } |
| 4675 | } | 4674 | } |
| 4676 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4675 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4677 | INC_PC(sizeof(ldst_inst)); | 4676 | INC_PC(sizeof(ldst_inst)); |
| 4678 | FETCH_INST; | 4677 | FETCH_INST; |
| 4679 | GOTO_NEXT_INST; | 4678 | GOTO_NEXT_INST; |
| @@ -4684,7 +4683,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4684 | ldst_inst* inst_cream = (ldst_inst*)inst_base->component; | 4683 | ldst_inst* inst_cream = (ldst_inst*)inst_base->component; |
| 4685 | inst_cream->get_addr(cpu, inst_cream->inst, addr); | 4684 | inst_cream->get_addr(cpu, inst_cream->inst, addr); |
| 4686 | 4685 | ||
| 4687 | unsigned int value = ReadMemory32(cpu, addr); | 4686 | unsigned int value = cpu->ReadMemory32(addr); |
| 4688 | cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value; | 4687 | cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value; |
| 4689 | 4688 | ||
| 4690 | if (BITS(inst_cream->inst, 12, 15) == 15) { | 4689 | if (BITS(inst_cream->inst, 12, 15) == 15) { |
| @@ -4692,7 +4691,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4692 | goto DISPATCH; | 4691 | goto DISPATCH; |
| 4693 | } | 4692 | } |
| 4694 | } | 4693 | } |
| 4695 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4694 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4696 | INC_PC(sizeof(ldst_inst)); | 4695 | INC_PC(sizeof(ldst_inst)); |
| 4697 | FETCH_INST; | 4696 | FETCH_INST; |
| 4698 | GOTO_NEXT_INST; | 4697 | GOTO_NEXT_INST; |
| @@ -4707,10 +4706,10 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4707 | DEBUG_MSG; | 4706 | DEBUG_MSG; |
| 4708 | } else { | 4707 | } else { |
| 4709 | if (inst_cream->cp_num == 15) | 4708 | if (inst_cream->cp_num == 15) |
| 4710 | WriteCP15Register(cpu, RD, CRn, OPCODE_1, CRm, OPCODE_2); | 4709 | cpu->WriteCP15Register(RD, CRn, OPCODE_1, CRm, OPCODE_2); |
| 4711 | } | 4710 | } |
| 4712 | } | 4711 | } |
| 4713 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4712 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4714 | INC_PC(sizeof(mcr_inst)); | 4713 | INC_PC(sizeof(mcr_inst)); |
| 4715 | FETCH_INST; | 4714 | FETCH_INST; |
| 4716 | GOTO_NEXT_INST; | 4715 | GOTO_NEXT_INST; |
| @@ -4727,7 +4726,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4727 | inst_cream->cp_num, inst_cream->crm, inst_cream->opcode_1, inst_cream->rt, inst_cream->rt2); | 4726 | inst_cream->cp_num, inst_cream->crm, inst_cream->opcode_1, inst_cream->rt, inst_cream->rt2); |
| 4728 | } | 4727 | } |
| 4729 | 4728 | ||
| 4730 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4729 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4731 | INC_PC(sizeof(mcrr_inst)); | 4730 | INC_PC(sizeof(mcrr_inst)); |
| 4732 | FETCH_INST; | 4731 | FETCH_INST; |
| 4733 | GOTO_NEXT_INST; | 4732 | GOTO_NEXT_INST; |
| @@ -4752,7 +4751,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4752 | goto DISPATCH; | 4751 | goto DISPATCH; |
| 4753 | } | 4752 | } |
| 4754 | } | 4753 | } |
| 4755 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4754 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4756 | INC_PC(sizeof(mla_inst)); | 4755 | INC_PC(sizeof(mla_inst)); |
| 4757 | FETCH_INST; | 4756 | FETCH_INST; |
| 4758 | GOTO_NEXT_INST; | 4757 | GOTO_NEXT_INST; |
| @@ -4766,7 +4765,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4766 | if (inst_cream->S && (inst_cream->Rd == 15)) { | 4765 | if (inst_cream->S && (inst_cream->Rd == 15)) { |
| 4767 | if (CurrentModeHasSPSR) { | 4766 | if (CurrentModeHasSPSR) { |
| 4768 | cpu->Cpsr = cpu->Spsr_copy; | 4767 | cpu->Cpsr = cpu->Spsr_copy; |
| 4769 | switch_mode(cpu, cpu->Spsr_copy & 0x1f); | 4768 | cpu->ChangePrivilegeMode(cpu->Spsr_copy & 0x1F); |
| 4770 | LOAD_NZCVT; | 4769 | LOAD_NZCVT; |
| 4771 | } | 4770 | } |
| 4772 | } else if (inst_cream->S) { | 4771 | } else if (inst_cream->S) { |
| @@ -4779,7 +4778,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4779 | goto DISPATCH; | 4778 | goto DISPATCH; |
| 4780 | } | 4779 | } |
| 4781 | } | 4780 | } |
| 4782 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4781 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4783 | INC_PC(sizeof(mov_inst)); | 4782 | INC_PC(sizeof(mov_inst)); |
| 4784 | FETCH_INST; | 4783 | FETCH_INST; |
| 4785 | GOTO_NEXT_INST; | 4784 | GOTO_NEXT_INST; |
| @@ -4800,10 +4799,10 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4800 | goto END; | 4799 | goto END; |
| 4801 | } else { | 4800 | } else { |
| 4802 | if (inst_cream->cp_num == 15) | 4801 | if (inst_cream->cp_num == 15) |
| 4803 | RD = ReadCP15Register(cpu, CRn, OPCODE_1, CRm, OPCODE_2); | 4802 | RD = cpu->ReadCP15Register(CRn, OPCODE_1, CRm, OPCODE_2); |
| 4804 | } | 4803 | } |
| 4805 | } | 4804 | } |
| 4806 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4805 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4807 | INC_PC(sizeof(mrc_inst)); | 4806 | INC_PC(sizeof(mrc_inst)); |
| 4808 | FETCH_INST; | 4807 | FETCH_INST; |
| 4809 | GOTO_NEXT_INST; | 4808 | GOTO_NEXT_INST; |
| @@ -4820,7 +4819,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4820 | inst_cream->cp_num, inst_cream->crm, inst_cream->opcode_1, inst_cream->rt, inst_cream->rt2); | 4819 | inst_cream->cp_num, inst_cream->crm, inst_cream->opcode_1, inst_cream->rt, inst_cream->rt2); |
| 4821 | } | 4820 | } |
| 4822 | 4821 | ||
| 4823 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4822 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4824 | INC_PC(sizeof(mcrr_inst)); | 4823 | INC_PC(sizeof(mcrr_inst)); |
| 4825 | FETCH_INST; | 4824 | FETCH_INST; |
| 4826 | GOTO_NEXT_INST; | 4825 | GOTO_NEXT_INST; |
| @@ -4838,7 +4837,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4838 | RD = cpu->Cpsr; | 4837 | RD = cpu->Cpsr; |
| 4839 | } | 4838 | } |
| 4840 | } | 4839 | } |
| 4841 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4840 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4842 | INC_PC(sizeof(mrs_inst)); | 4841 | INC_PC(sizeof(mrs_inst)); |
| 4843 | FETCH_INST; | 4842 | FETCH_INST; |
| 4844 | GOTO_NEXT_INST; | 4843 | GOTO_NEXT_INST; |
| @@ -4861,7 +4860,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4861 | | (BIT(inst, 18) ? 0xff0000 : 0) | (BIT(inst, 19) ? 0xff000000 : 0); | 4860 | | (BIT(inst, 18) ? 0xff0000 : 0) | (BIT(inst, 19) ? 0xff000000 : 0); |
| 4862 | uint32_t mask = 0; | 4861 | uint32_t mask = 0; |
| 4863 | if (!inst_cream->R) { | 4862 | if (!inst_cream->R) { |
| 4864 | if (InAPrivilegedMode(cpu)) { | 4863 | if (cpu->InAPrivilegedMode()) { |
| 4865 | if ((operand & StateMask) != 0) { | 4864 | if ((operand & StateMask) != 0) { |
| 4866 | /// UNPREDICTABLE | 4865 | /// UNPREDICTABLE |
| 4867 | DEBUG_MSG; | 4866 | DEBUG_MSG; |
| @@ -4873,7 +4872,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4873 | SAVE_NZCVT; | 4872 | SAVE_NZCVT; |
| 4874 | 4873 | ||
| 4875 | cpu->Cpsr = (cpu->Cpsr & ~mask) | (operand & mask); | 4874 | cpu->Cpsr = (cpu->Cpsr & ~mask) | (operand & mask); |
| 4876 | switch_mode(cpu, cpu->Cpsr & 0x1f); | 4875 | cpu->ChangePrivilegeMode(cpu->Cpsr & 0x1F); |
| 4877 | LOAD_NZCVT; | 4876 | LOAD_NZCVT; |
| 4878 | } else { | 4877 | } else { |
| 4879 | if (CurrentModeHasSPSR) { | 4878 | if (CurrentModeHasSPSR) { |
| @@ -4882,7 +4881,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4882 | } | 4881 | } |
| 4883 | } | 4882 | } |
| 4884 | } | 4883 | } |
| 4885 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4884 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4886 | INC_PC(sizeof(msr_inst)); | 4885 | INC_PC(sizeof(msr_inst)); |
| 4887 | FETCH_INST; | 4886 | FETCH_INST; |
| 4888 | GOTO_NEXT_INST; | 4887 | GOTO_NEXT_INST; |
| @@ -4904,7 +4903,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4904 | goto DISPATCH; | 4903 | goto DISPATCH; |
| 4905 | } | 4904 | } |
| 4906 | } | 4905 | } |
| 4907 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4906 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4908 | INC_PC(sizeof(mul_inst)); | 4907 | INC_PC(sizeof(mul_inst)); |
| 4909 | FETCH_INST; | 4908 | FETCH_INST; |
| 4910 | GOTO_NEXT_INST; | 4909 | GOTO_NEXT_INST; |
| @@ -4919,7 +4918,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4919 | if (inst_cream->S && (inst_cream->Rd == 15)) { | 4918 | if (inst_cream->S && (inst_cream->Rd == 15)) { |
| 4920 | if (CurrentModeHasSPSR) { | 4919 | if (CurrentModeHasSPSR) { |
| 4921 | cpu->Cpsr = cpu->Spsr_copy; | 4920 | cpu->Cpsr = cpu->Spsr_copy; |
| 4922 | switch_mode(cpu, cpu->Spsr_copy & 0x1f); | 4921 | cpu->ChangePrivilegeMode(cpu->Spsr_copy & 0x1F); |
| 4923 | LOAD_NZCVT; | 4922 | LOAD_NZCVT; |
| 4924 | } | 4923 | } |
| 4925 | } else if (inst_cream->S) { | 4924 | } else if (inst_cream->S) { |
| @@ -4932,7 +4931,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4932 | goto DISPATCH; | 4931 | goto DISPATCH; |
| 4933 | } | 4932 | } |
| 4934 | } | 4933 | } |
| 4935 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4934 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4936 | INC_PC(sizeof(mvn_inst)); | 4935 | INC_PC(sizeof(mvn_inst)); |
| 4937 | FETCH_INST; | 4936 | FETCH_INST; |
| 4938 | GOTO_NEXT_INST; | 4937 | GOTO_NEXT_INST; |
| @@ -4949,7 +4948,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4949 | if (inst_cream->S && (inst_cream->Rd == 15)) { | 4948 | if (inst_cream->S && (inst_cream->Rd == 15)) { |
| 4950 | if (CurrentModeHasSPSR) { | 4949 | if (CurrentModeHasSPSR) { |
| 4951 | cpu->Cpsr = cpu->Spsr_copy; | 4950 | cpu->Cpsr = cpu->Spsr_copy; |
| 4952 | switch_mode(cpu, cpu->Spsr_copy & 0x1f); | 4951 | cpu->ChangePrivilegeMode(cpu->Spsr_copy & 0x1F); |
| 4953 | LOAD_NZCVT; | 4952 | LOAD_NZCVT; |
| 4954 | } | 4953 | } |
| 4955 | } else if (inst_cream->S) { | 4954 | } else if (inst_cream->S) { |
| @@ -4962,7 +4961,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4962 | goto DISPATCH; | 4961 | goto DISPATCH; |
| 4963 | } | 4962 | } |
| 4964 | } | 4963 | } |
| 4965 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4964 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4966 | INC_PC(sizeof(orr_inst)); | 4965 | INC_PC(sizeof(orr_inst)); |
| 4967 | FETCH_INST; | 4966 | FETCH_INST; |
| 4968 | GOTO_NEXT_INST; | 4967 | GOTO_NEXT_INST; |
| @@ -4970,7 +4969,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4970 | 4969 | ||
| 4971 | NOP_INST: | 4970 | NOP_INST: |
| 4972 | { | 4971 | { |
| 4973 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4972 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4974 | INC_PC_STUB; | 4973 | INC_PC_STUB; |
| 4975 | FETCH_INST; | 4974 | FETCH_INST; |
| 4976 | GOTO_NEXT_INST; | 4975 | GOTO_NEXT_INST; |
| @@ -4982,7 +4981,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4982 | pkh_inst *inst_cream = (pkh_inst *)inst_base->component; | 4981 | pkh_inst *inst_cream = (pkh_inst *)inst_base->component; |
| 4983 | RD = (RN & 0xFFFF) | ((RM << inst_cream->imm) & 0xFFFF0000); | 4982 | RD = (RN & 0xFFFF) | ((RM << inst_cream->imm) & 0xFFFF0000); |
| 4984 | } | 4983 | } |
| 4985 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4984 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4986 | INC_PC(sizeof(pkh_inst)); | 4985 | INC_PC(sizeof(pkh_inst)); |
| 4987 | FETCH_INST; | 4986 | FETCH_INST; |
| 4988 | GOTO_NEXT_INST; | 4987 | GOTO_NEXT_INST; |
| @@ -4995,7 +4994,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 4995 | int shift_imm = inst_cream->imm ? inst_cream->imm : 31; | 4994 | int shift_imm = inst_cream->imm ? inst_cream->imm : 31; |
| 4996 | RD = ((static_cast<s32>(RM) >> shift_imm) & 0xFFFF) | (RN & 0xFFFF0000); | 4995 | RD = ((static_cast<s32>(RM) >> shift_imm) & 0xFFFF) | (RN & 0xFFFF0000); |
| 4997 | } | 4996 | } |
| 4998 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 4997 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 4999 | INC_PC(sizeof(pkh_inst)); | 4998 | INC_PC(sizeof(pkh_inst)); |
| 5000 | FETCH_INST; | 4999 | FETCH_INST; |
| 5001 | GOTO_NEXT_INST; | 5000 | GOTO_NEXT_INST; |
| @@ -5005,7 +5004,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5005 | { | 5004 | { |
| 5006 | // Not implemented. PLD is a hint instruction, so it's optional. | 5005 | // Not implemented. PLD is a hint instruction, so it's optional. |
| 5007 | 5006 | ||
| 5008 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5007 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5009 | INC_PC(sizeof(pld_inst)); | 5008 | INC_PC(sizeof(pld_inst)); |
| 5010 | FETCH_INST; | 5009 | FETCH_INST; |
| 5011 | GOTO_NEXT_INST; | 5010 | GOTO_NEXT_INST; |
| @@ -5078,7 +5077,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5078 | RD = result; | 5077 | RD = result; |
| 5079 | } | 5078 | } |
| 5080 | 5079 | ||
| 5081 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5080 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5082 | INC_PC(sizeof(generic_arm_inst)); | 5081 | INC_PC(sizeof(generic_arm_inst)); |
| 5083 | FETCH_INST; | 5082 | FETCH_INST; |
| 5084 | GOTO_NEXT_INST; | 5083 | GOTO_NEXT_INST; |
| @@ -5140,7 +5139,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5140 | RD = (lo_result & 0xFFFF) | ((hi_result & 0xFFFF) << 16); | 5139 | RD = (lo_result & 0xFFFF) | ((hi_result & 0xFFFF) << 16); |
| 5141 | } | 5140 | } |
| 5142 | 5141 | ||
| 5143 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5142 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5144 | INC_PC(sizeof(generic_arm_inst)); | 5143 | INC_PC(sizeof(generic_arm_inst)); |
| 5145 | FETCH_INST; | 5144 | FETCH_INST; |
| 5146 | GOTO_NEXT_INST; | 5145 | GOTO_NEXT_INST; |
| @@ -5173,7 +5172,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5173 | } | 5172 | } |
| 5174 | } | 5173 | } |
| 5175 | 5174 | ||
| 5176 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5175 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5177 | INC_PC(sizeof(rev_inst)); | 5176 | INC_PC(sizeof(rev_inst)); |
| 5178 | FETCH_INST; | 5177 | FETCH_INST; |
| 5179 | GOTO_NEXT_INST; | 5178 | GOTO_NEXT_INST; |
| @@ -5187,8 +5186,8 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5187 | u32 address = 0; | 5186 | u32 address = 0; |
| 5188 | inst_cream->get_addr(cpu, inst_cream->inst, address); | 5187 | inst_cream->get_addr(cpu, inst_cream->inst, address); |
| 5189 | 5188 | ||
| 5190 | cpu->Cpsr = ReadMemory32(cpu, address); | 5189 | cpu->Cpsr = cpu->ReadMemory32(address); |
| 5191 | cpu->Reg[15] = ReadMemory32(cpu, address + 4); | 5190 | cpu->Reg[15] = cpu->ReadMemory32(address + 4); |
| 5192 | 5191 | ||
| 5193 | INC_PC(sizeof(ldst_inst)); | 5192 | INC_PC(sizeof(ldst_inst)); |
| 5194 | goto DISPATCH; | 5193 | goto DISPATCH; |
| @@ -5201,7 +5200,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5201 | 5200 | ||
| 5202 | u32 rn_val = RN; | 5201 | u32 rn_val = RN; |
| 5203 | if (inst_cream->Rn == 15) | 5202 | if (inst_cream->Rn == 15) |
| 5204 | rn_val += 2 * GET_INST_SIZE(cpu); | 5203 | rn_val += 2 * cpu->GetInstructionSize(); |
| 5205 | 5204 | ||
| 5206 | bool carry; | 5205 | bool carry; |
| 5207 | bool overflow; | 5206 | bool overflow; |
| @@ -5210,7 +5209,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5210 | if (inst_cream->S && (inst_cream->Rd == 15)) { | 5209 | if (inst_cream->S && (inst_cream->Rd == 15)) { |
| 5211 | if (CurrentModeHasSPSR) { | 5210 | if (CurrentModeHasSPSR) { |
| 5212 | cpu->Cpsr = cpu->Spsr_copy; | 5211 | cpu->Cpsr = cpu->Spsr_copy; |
| 5213 | switch_mode(cpu, cpu->Spsr_copy & 0x1f); | 5212 | cpu->ChangePrivilegeMode(cpu->Spsr_copy & 0x1F); |
| 5214 | LOAD_NZCVT; | 5213 | LOAD_NZCVT; |
| 5215 | } | 5214 | } |
| 5216 | } else if (inst_cream->S) { | 5215 | } else if (inst_cream->S) { |
| @@ -5224,7 +5223,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5224 | goto DISPATCH; | 5223 | goto DISPATCH; |
| 5225 | } | 5224 | } |
| 5226 | } | 5225 | } |
| 5227 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5226 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5228 | INC_PC(sizeof(rsb_inst)); | 5227 | INC_PC(sizeof(rsb_inst)); |
| 5229 | FETCH_INST; | 5228 | FETCH_INST; |
| 5230 | GOTO_NEXT_INST; | 5229 | GOTO_NEXT_INST; |
| @@ -5241,7 +5240,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5241 | if (inst_cream->S && (inst_cream->Rd == 15)) { | 5240 | if (inst_cream->S && (inst_cream->Rd == 15)) { |
| 5242 | if (CurrentModeHasSPSR) { | 5241 | if (CurrentModeHasSPSR) { |
| 5243 | cpu->Cpsr = cpu->Spsr_copy; | 5242 | cpu->Cpsr = cpu->Spsr_copy; |
| 5244 | switch_mode(cpu, cpu->Spsr_copy & 0x1f); | 5243 | cpu->ChangePrivilegeMode(cpu->Spsr_copy & 0x1F); |
| 5245 | LOAD_NZCVT; | 5244 | LOAD_NZCVT; |
| 5246 | } | 5245 | } |
| 5247 | } else if (inst_cream->S) { | 5246 | } else if (inst_cream->S) { |
| @@ -5255,7 +5254,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5255 | goto DISPATCH; | 5254 | goto DISPATCH; |
| 5256 | } | 5255 | } |
| 5257 | } | 5256 | } |
| 5258 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5257 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5259 | INC_PC(sizeof(rsc_inst)); | 5258 | INC_PC(sizeof(rsc_inst)); |
| 5260 | FETCH_INST; | 5259 | FETCH_INST; |
| 5261 | GOTO_NEXT_INST; | 5260 | GOTO_NEXT_INST; |
| @@ -5363,7 +5362,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5363 | } | 5362 | } |
| 5364 | } | 5363 | } |
| 5365 | 5364 | ||
| 5366 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5365 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5367 | INC_PC(sizeof(generic_arm_inst)); | 5366 | INC_PC(sizeof(generic_arm_inst)); |
| 5368 | FETCH_INST; | 5367 | FETCH_INST; |
| 5369 | GOTO_NEXT_INST; | 5368 | GOTO_NEXT_INST; |
| @@ -5381,7 +5380,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5381 | if (inst_cream->S && (inst_cream->Rd == 15)) { | 5380 | if (inst_cream->S && (inst_cream->Rd == 15)) { |
| 5382 | if (CurrentModeHasSPSR) { | 5381 | if (CurrentModeHasSPSR) { |
| 5383 | cpu->Cpsr = cpu->Spsr_copy; | 5382 | cpu->Cpsr = cpu->Spsr_copy; |
| 5384 | switch_mode(cpu, cpu->Spsr_copy & 0x1f); | 5383 | cpu->ChangePrivilegeMode(cpu->Spsr_copy & 0x1F); |
| 5385 | LOAD_NZCVT; | 5384 | LOAD_NZCVT; |
| 5386 | } | 5385 | } |
| 5387 | } else if (inst_cream->S) { | 5386 | } else if (inst_cream->S) { |
| @@ -5395,7 +5394,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5395 | goto DISPATCH; | 5394 | goto DISPATCH; |
| 5396 | } | 5395 | } |
| 5397 | } | 5396 | } |
| 5398 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5397 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5399 | INC_PC(sizeof(sbc_inst)); | 5398 | INC_PC(sizeof(sbc_inst)); |
| 5400 | FETCH_INST; | 5399 | FETCH_INST; |
| 5401 | GOTO_NEXT_INST; | 5400 | GOTO_NEXT_INST; |
| @@ -5434,7 +5433,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5434 | RD = result; | 5433 | RD = result; |
| 5435 | } | 5434 | } |
| 5436 | 5435 | ||
| 5437 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5436 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5438 | INC_PC(sizeof(generic_arm_inst)); | 5437 | INC_PC(sizeof(generic_arm_inst)); |
| 5439 | FETCH_INST; | 5438 | FETCH_INST; |
| 5440 | GOTO_NEXT_INST; | 5439 | GOTO_NEXT_INST; |
| @@ -5453,7 +5452,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5453 | 5452 | ||
| 5454 | LOG_WARNING(Core_ARM11, "SETEND %s executed", big_endian ? "BE" : "LE"); | 5453 | LOG_WARNING(Core_ARM11, "SETEND %s executed", big_endian ? "BE" : "LE"); |
| 5455 | 5454 | ||
| 5456 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5455 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5457 | INC_PC(sizeof(setend_inst)); | 5456 | INC_PC(sizeof(setend_inst)); |
| 5458 | FETCH_INST; | 5457 | FETCH_INST; |
| 5459 | GOTO_NEXT_INST; | 5458 | GOTO_NEXT_INST; |
| @@ -5466,7 +5465,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5466 | LOG_TRACE(Core_ARM11, "SEV executed."); | 5465 | LOG_TRACE(Core_ARM11, "SEV executed."); |
| 5467 | } | 5466 | } |
| 5468 | 5467 | ||
| 5469 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5468 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5470 | INC_PC_STUB; | 5469 | INC_PC_STUB; |
| 5471 | FETCH_INST; | 5470 | FETCH_INST; |
| 5472 | GOTO_NEXT_INST; | 5471 | GOTO_NEXT_INST; |
| @@ -5538,7 +5537,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5538 | } | 5537 | } |
| 5539 | } | 5538 | } |
| 5540 | 5539 | ||
| 5541 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5540 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5542 | INC_PC(sizeof(generic_arm_inst)); | 5541 | INC_PC(sizeof(generic_arm_inst)); |
| 5543 | FETCH_INST; | 5542 | FETCH_INST; |
| 5544 | GOTO_NEXT_INST; | 5543 | GOTO_NEXT_INST; |
| @@ -5563,7 +5562,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5563 | if (AddOverflow(operand1 * operand2, RN, RD)) | 5562 | if (AddOverflow(operand1 * operand2, RN, RD)) |
| 5564 | cpu->Cpsr |= (1 << 27); | 5563 | cpu->Cpsr |= (1 << 27); |
| 5565 | } | 5564 | } |
| 5566 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5565 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5567 | INC_PC(sizeof(smla_inst)); | 5566 | INC_PC(sizeof(smla_inst)); |
| 5568 | FETCH_INST; | 5567 | FETCH_INST; |
| 5569 | GOTO_NEXT_INST; | 5568 | GOTO_NEXT_INST; |
| @@ -5619,7 +5618,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5619 | } | 5618 | } |
| 5620 | } | 5619 | } |
| 5621 | 5620 | ||
| 5622 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5621 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5623 | INC_PC(sizeof(smlad_inst)); | 5622 | INC_PC(sizeof(smlad_inst)); |
| 5624 | FETCH_INST; | 5623 | FETCH_INST; |
| 5625 | GOTO_NEXT_INST; | 5624 | GOTO_NEXT_INST; |
| @@ -5648,7 +5647,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5648 | cpu->ZFlag = (RDHI == 0 && RDLO == 0); | 5647 | cpu->ZFlag = (RDHI == 0 && RDLO == 0); |
| 5649 | } | 5648 | } |
| 5650 | } | 5649 | } |
| 5651 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5650 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5652 | INC_PC(sizeof(umlal_inst)); | 5651 | INC_PC(sizeof(umlal_inst)); |
| 5653 | FETCH_INST; | 5652 | FETCH_INST; |
| 5654 | GOTO_NEXT_INST; | 5653 | GOTO_NEXT_INST; |
| @@ -5678,7 +5677,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5678 | RDHI = ((dest >> 32) & 0xFFFFFFFF); | 5677 | RDHI = ((dest >> 32) & 0xFFFFFFFF); |
| 5679 | } | 5678 | } |
| 5680 | 5679 | ||
| 5681 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5680 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5682 | INC_PC(sizeof(smlalxy_inst)); | 5681 | INC_PC(sizeof(smlalxy_inst)); |
| 5683 | FETCH_INST; | 5682 | FETCH_INST; |
| 5684 | GOTO_NEXT_INST; | 5683 | GOTO_NEXT_INST; |
| @@ -5703,7 +5702,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5703 | cpu->Cpsr |= (1 << 27); | 5702 | cpu->Cpsr |= (1 << 27); |
| 5704 | } | 5703 | } |
| 5705 | 5704 | ||
| 5706 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5705 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5707 | INC_PC(sizeof(smlad_inst)); | 5706 | INC_PC(sizeof(smlad_inst)); |
| 5708 | FETCH_INST; | 5707 | FETCH_INST; |
| 5709 | GOTO_NEXT_INST; | 5708 | GOTO_NEXT_INST; |
| @@ -5741,7 +5740,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5741 | RDHI = ((result >> 32) & 0xFFFFFFFF); | 5740 | RDHI = ((result >> 32) & 0xFFFFFFFF); |
| 5742 | } | 5741 | } |
| 5743 | 5742 | ||
| 5744 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5743 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5745 | INC_PC(sizeof(smlald_inst)); | 5744 | INC_PC(sizeof(smlald_inst)); |
| 5746 | FETCH_INST; | 5745 | FETCH_INST; |
| 5747 | GOTO_NEXT_INST; | 5746 | GOTO_NEXT_INST; |
| @@ -5777,7 +5776,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5777 | RD = ((result >> 32) & 0xFFFFFFFF); | 5776 | RD = ((result >> 32) & 0xFFFFFFFF); |
| 5778 | } | 5777 | } |
| 5779 | 5778 | ||
| 5780 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5779 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5781 | INC_PC(sizeof(smlad_inst)); | 5780 | INC_PC(sizeof(smlad_inst)); |
| 5782 | FETCH_INST; | 5781 | FETCH_INST; |
| 5783 | GOTO_NEXT_INST; | 5782 | GOTO_NEXT_INST; |
| @@ -5799,7 +5798,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5799 | operand2 = (BIT(RS, 31)) ? (BITS(RS, 16, 31) | 0xffff0000) : BITS(RS, 16, 31); | 5798 | operand2 = (BIT(RS, 31)) ? (BITS(RS, 16, 31) | 0xffff0000) : BITS(RS, 16, 31); |
| 5800 | RD = operand1 * operand2; | 5799 | RD = operand1 * operand2; |
| 5801 | } | 5800 | } |
| 5802 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5801 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5803 | INC_PC(sizeof(smul_inst)); | 5802 | INC_PC(sizeof(smul_inst)); |
| 5804 | FETCH_INST; | 5803 | FETCH_INST; |
| 5805 | GOTO_NEXT_INST; | 5804 | GOTO_NEXT_INST; |
| @@ -5825,7 +5824,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5825 | cpu->ZFlag = (RDHI == 0 && RDLO == 0); | 5824 | cpu->ZFlag = (RDHI == 0 && RDLO == 0); |
| 5826 | } | 5825 | } |
| 5827 | } | 5826 | } |
| 5828 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5827 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5829 | INC_PC(sizeof(umull_inst)); | 5828 | INC_PC(sizeof(umull_inst)); |
| 5830 | FETCH_INST; | 5829 | FETCH_INST; |
| 5831 | GOTO_NEXT_INST; | 5830 | GOTO_NEXT_INST; |
| @@ -5841,7 +5840,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5841 | s64 result = (s64)rm * (s64)(s32)RN; | 5840 | s64 result = (s64)rm * (s64)(s32)RN; |
| 5842 | RD = BITS(result, 16, 47); | 5841 | RD = BITS(result, 16, 47); |
| 5843 | } | 5842 | } |
| 5844 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5843 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5845 | INC_PC(sizeof(smlad_inst)); | 5844 | INC_PC(sizeof(smlad_inst)); |
| 5846 | FETCH_INST; | 5845 | FETCH_INST; |
| 5847 | GOTO_NEXT_INST; | 5846 | GOTO_NEXT_INST; |
| @@ -5855,10 +5854,10 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5855 | u32 address = 0; | 5854 | u32 address = 0; |
| 5856 | inst_cream->get_addr(cpu, inst_cream->inst, address); | 5855 | inst_cream->get_addr(cpu, inst_cream->inst, address); |
| 5857 | 5856 | ||
| 5858 | WriteMemory32(cpu, address + 0, cpu->Reg[14]); | 5857 | cpu->WriteMemory32(address + 0, cpu->Reg[14]); |
| 5859 | WriteMemory32(cpu, address + 4, cpu->Spsr_copy); | 5858 | cpu->WriteMemory32(address + 4, cpu->Spsr_copy); |
| 5860 | 5859 | ||
| 5861 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5860 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5862 | INC_PC(sizeof(ldst_inst)); | 5861 | INC_PC(sizeof(ldst_inst)); |
| 5863 | FETCH_INST; | 5862 | FETCH_INST; |
| 5864 | GOTO_NEXT_INST; | 5863 | GOTO_NEXT_INST; |
| @@ -5891,7 +5890,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5891 | RD = rn_val; | 5890 | RD = rn_val; |
| 5892 | } | 5891 | } |
| 5893 | 5892 | ||
| 5894 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5893 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5895 | INC_PC(sizeof(ssat_inst)); | 5894 | INC_PC(sizeof(ssat_inst)); |
| 5896 | FETCH_INST; | 5895 | FETCH_INST; |
| 5897 | GOTO_NEXT_INST; | 5896 | GOTO_NEXT_INST; |
| @@ -5913,7 +5912,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5913 | cpu->Cpsr |= (1 << 27); | 5912 | cpu->Cpsr |= (1 << 27); |
| 5914 | } | 5913 | } |
| 5915 | 5914 | ||
| 5916 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5915 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5917 | INC_PC(sizeof(ssat_inst)); | 5916 | INC_PC(sizeof(ssat_inst)); |
| 5918 | FETCH_INST; | 5917 | FETCH_INST; |
| 5919 | GOTO_NEXT_INST; | 5918 | GOTO_NEXT_INST; |
| @@ -5923,7 +5922,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5923 | { | 5922 | { |
| 5924 | // Instruction not implemented | 5923 | // Instruction not implemented |
| 5925 | //LOG_CRITICAL(Core_ARM11, "unimplemented instruction"); | 5924 | //LOG_CRITICAL(Core_ARM11, "unimplemented instruction"); |
| 5926 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5925 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5927 | INC_PC(sizeof(stc_inst)); | 5926 | INC_PC(sizeof(stc_inst)); |
| 5928 | FETCH_INST; | 5927 | FETCH_INST; |
| 5929 | GOTO_NEXT_INST; | 5928 | GOTO_NEXT_INST; |
| @@ -5941,36 +5940,36 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5941 | if (BIT(inst_cream->inst, 22) == 1) { | 5940 | if (BIT(inst_cream->inst, 22) == 1) { |
| 5942 | for (int i = 0; i < 13; i++) { | 5941 | for (int i = 0; i < 13; i++) { |
| 5943 | if (BIT(inst_cream->inst, i)) { | 5942 | if (BIT(inst_cream->inst, i)) { |
| 5944 | WriteMemory32(cpu, addr, cpu->Reg[i]); | 5943 | cpu->WriteMemory32(addr, cpu->Reg[i]); |
| 5945 | addr += 4; | 5944 | addr += 4; |
| 5946 | } | 5945 | } |
| 5947 | } | 5946 | } |
| 5948 | if (BIT(inst_cream->inst, 13)) { | 5947 | if (BIT(inst_cream->inst, 13)) { |
| 5949 | if (cpu->Mode == USER32MODE) | 5948 | if (cpu->Mode == USER32MODE) |
| 5950 | WriteMemory32(cpu, addr, cpu->Reg[13]); | 5949 | cpu->WriteMemory32(addr, cpu->Reg[13]); |
| 5951 | else | 5950 | else |
| 5952 | WriteMemory32(cpu, addr, cpu->Reg_usr[0]); | 5951 | cpu->WriteMemory32(addr, cpu->Reg_usr[0]); |
| 5953 | 5952 | ||
| 5954 | addr += 4; | 5953 | addr += 4; |
| 5955 | } | 5954 | } |
| 5956 | if (BIT(inst_cream->inst, 14)) { | 5955 | if (BIT(inst_cream->inst, 14)) { |
| 5957 | if (cpu->Mode == USER32MODE) | 5956 | if (cpu->Mode == USER32MODE) |
| 5958 | WriteMemory32(cpu, addr, cpu->Reg[14]); | 5957 | cpu->WriteMemory32(addr, cpu->Reg[14]); |
| 5959 | else | 5958 | else |
| 5960 | WriteMemory32(cpu, addr, cpu->Reg_usr[1]); | 5959 | cpu->WriteMemory32(addr, cpu->Reg_usr[1]); |
| 5961 | 5960 | ||
| 5962 | addr += 4; | 5961 | addr += 4; |
| 5963 | } | 5962 | } |
| 5964 | if (BIT(inst_cream->inst, 15)) { | 5963 | if (BIT(inst_cream->inst, 15)) { |
| 5965 | WriteMemory32(cpu, addr, cpu->Reg_usr[1] + 8); | 5964 | cpu->WriteMemory32(addr, cpu->Reg_usr[1] + 8); |
| 5966 | } | 5965 | } |
| 5967 | } else { | 5966 | } else { |
| 5968 | for (int i = 0; i < 15; i++) { | 5967 | for (int i = 0; i < 15; i++) { |
| 5969 | if (BIT(inst_cream->inst, i)) { | 5968 | if (BIT(inst_cream->inst, i)) { |
| 5970 | if (i == Rn) | 5969 | if (i == Rn) |
| 5971 | WriteMemory32(cpu, addr, old_RN); | 5970 | cpu->WriteMemory32(addr, old_RN); |
| 5972 | else | 5971 | else |
| 5973 | WriteMemory32(cpu, addr, cpu->Reg[i]); | 5972 | cpu->WriteMemory32(addr, cpu->Reg[i]); |
| 5974 | 5973 | ||
| 5975 | addr += 4; | 5974 | addr += 4; |
| 5976 | } | 5975 | } |
| @@ -5978,10 +5977,10 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5978 | 5977 | ||
| 5979 | // Check PC reg | 5978 | // Check PC reg |
| 5980 | if (BIT(inst_cream->inst, 15)) | 5979 | if (BIT(inst_cream->inst, 15)) |
| 5981 | WriteMemory32(cpu, addr, cpu->Reg_usr[1] + 8); | 5980 | cpu->WriteMemory32(addr, cpu->Reg_usr[1] + 8); |
| 5982 | } | 5981 | } |
| 5983 | } | 5982 | } |
| 5984 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 5983 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 5985 | INC_PC(sizeof(ldst_inst)); | 5984 | INC_PC(sizeof(ldst_inst)); |
| 5986 | FETCH_INST; | 5985 | FETCH_INST; |
| 5987 | GOTO_NEXT_INST; | 5986 | GOTO_NEXT_INST; |
| @@ -5999,7 +5998,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 5999 | } | 5998 | } |
| 6000 | RD = operand2; | 5999 | RD = operand2; |
| 6001 | } | 6000 | } |
| 6002 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6001 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6003 | INC_PC(sizeof(sxtb_inst)); | 6002 | INC_PC(sizeof(sxtb_inst)); |
| 6004 | FETCH_INST; | 6003 | FETCH_INST; |
| 6005 | GOTO_NEXT_INST; | 6004 | GOTO_NEXT_INST; |
| @@ -6011,9 +6010,9 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6011 | inst_cream->get_addr(cpu, inst_cream->inst, addr); | 6010 | inst_cream->get_addr(cpu, inst_cream->inst, addr); |
| 6012 | 6011 | ||
| 6013 | unsigned int value = cpu->Reg[BITS(inst_cream->inst, 12, 15)]; | 6012 | unsigned int value = cpu->Reg[BITS(inst_cream->inst, 12, 15)]; |
| 6014 | WriteMemory32(cpu, addr, value); | 6013 | cpu->WriteMemory32(addr, value); |
| 6015 | } | 6014 | } |
| 6016 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6015 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6017 | INC_PC(sizeof(ldst_inst)); | 6016 | INC_PC(sizeof(ldst_inst)); |
| 6018 | FETCH_INST; | 6017 | FETCH_INST; |
| 6019 | GOTO_NEXT_INST; | 6018 | GOTO_NEXT_INST; |
| @@ -6024,7 +6023,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6024 | uxtb_inst* inst_cream = (uxtb_inst*)inst_base->component; | 6023 | uxtb_inst* inst_cream = (uxtb_inst*)inst_base->component; |
| 6025 | RD = ROTATE_RIGHT_32(RM, 8 * inst_cream->rotate) & 0xff; | 6024 | RD = ROTATE_RIGHT_32(RM, 8 * inst_cream->rotate) & 0xff; |
| 6026 | } | 6025 | } |
| 6027 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6026 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6028 | INC_PC(sizeof(uxtb_inst)); | 6027 | INC_PC(sizeof(uxtb_inst)); |
| 6029 | FETCH_INST; | 6028 | FETCH_INST; |
| 6030 | GOTO_NEXT_INST; | 6029 | GOTO_NEXT_INST; |
| @@ -6037,7 +6036,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6037 | unsigned int operand2 = ROTATE_RIGHT_32(RM, 8 * inst_cream->rotate) & 0xff; | 6036 | unsigned int operand2 = ROTATE_RIGHT_32(RM, 8 * inst_cream->rotate) & 0xff; |
| 6038 | RD = RN + operand2; | 6037 | RD = RN + operand2; |
| 6039 | } | 6038 | } |
| 6040 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6039 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6041 | INC_PC(sizeof(uxtab_inst)); | 6040 | INC_PC(sizeof(uxtab_inst)); |
| 6042 | FETCH_INST; | 6041 | FETCH_INST; |
| 6043 | GOTO_NEXT_INST; | 6042 | GOTO_NEXT_INST; |
| @@ -6050,7 +6049,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6050 | unsigned int value = cpu->Reg[BITS(inst_cream->inst, 12, 15)] & 0xff; | 6049 | unsigned int value = cpu->Reg[BITS(inst_cream->inst, 12, 15)] & 0xff; |
| 6051 | Memory::Write8(addr, value); | 6050 | Memory::Write8(addr, value); |
| 6052 | } | 6051 | } |
| 6053 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6052 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6054 | INC_PC(sizeof(ldst_inst)); | 6053 | INC_PC(sizeof(ldst_inst)); |
| 6055 | FETCH_INST; | 6054 | FETCH_INST; |
| 6056 | GOTO_NEXT_INST; | 6055 | GOTO_NEXT_INST; |
| @@ -6063,7 +6062,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6063 | unsigned int value = cpu->Reg[BITS(inst_cream->inst, 12, 15)] & 0xff; | 6062 | unsigned int value = cpu->Reg[BITS(inst_cream->inst, 12, 15)] & 0xff; |
| 6064 | Memory::Write8(addr, value); | 6063 | Memory::Write8(addr, value); |
| 6065 | } | 6064 | } |
| 6066 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6065 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6067 | INC_PC(sizeof(ldst_inst)); | 6066 | INC_PC(sizeof(ldst_inst)); |
| 6068 | FETCH_INST; | 6067 | FETCH_INST; |
| 6069 | GOTO_NEXT_INST; | 6068 | GOTO_NEXT_INST; |
| @@ -6076,10 +6075,10 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6076 | 6075 | ||
| 6077 | // The 3DS doesn't have the Large Physical Access Extension (LPAE) | 6076 | // The 3DS doesn't have the Large Physical Access Extension (LPAE) |
| 6078 | // so STRD wouldn't store these as a single write. | 6077 | // so STRD wouldn't store these as a single write. |
| 6079 | WriteMemory32(cpu, addr + 0, cpu->Reg[BITS(inst_cream->inst, 12, 15)]); | 6078 | cpu->WriteMemory32(addr + 0, cpu->Reg[BITS(inst_cream->inst, 12, 15)]); |
| 6080 | WriteMemory32(cpu, addr + 4, cpu->Reg[BITS(inst_cream->inst, 12, 15) + 1]); | 6079 | cpu->WriteMemory32(addr + 4, cpu->Reg[BITS(inst_cream->inst, 12, 15) + 1]); |
| 6081 | } | 6080 | } |
| 6082 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6081 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6083 | INC_PC(sizeof(ldst_inst)); | 6082 | INC_PC(sizeof(ldst_inst)); |
| 6084 | FETCH_INST; | 6083 | FETCH_INST; |
| 6085 | GOTO_NEXT_INST; | 6084 | GOTO_NEXT_INST; |
| @@ -6094,14 +6093,14 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6094 | remove_exclusive(cpu, write_addr); | 6093 | remove_exclusive(cpu, write_addr); |
| 6095 | cpu->exclusive_state = 0; | 6094 | cpu->exclusive_state = 0; |
| 6096 | 6095 | ||
| 6097 | WriteMemory32(cpu, write_addr, RM); | 6096 | cpu->WriteMemory32(write_addr, RM); |
| 6098 | RD = 0; | 6097 | RD = 0; |
| 6099 | } else { | 6098 | } else { |
| 6100 | // Failed to write due to mutex access | 6099 | // Failed to write due to mutex access |
| 6101 | RD = 1; | 6100 | RD = 1; |
| 6102 | } | 6101 | } |
| 6103 | } | 6102 | } |
| 6104 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6103 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6105 | INC_PC(sizeof(generic_arm_inst)); | 6104 | INC_PC(sizeof(generic_arm_inst)); |
| 6106 | FETCH_INST; | 6105 | FETCH_INST; |
| 6107 | GOTO_NEXT_INST; | 6106 | GOTO_NEXT_INST; |
| @@ -6123,7 +6122,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6123 | RD = 1; | 6122 | RD = 1; |
| 6124 | } | 6123 | } |
| 6125 | } | 6124 | } |
| 6126 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6125 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6127 | INC_PC(sizeof(generic_arm_inst)); | 6126 | INC_PC(sizeof(generic_arm_inst)); |
| 6128 | FETCH_INST; | 6127 | FETCH_INST; |
| 6129 | GOTO_NEXT_INST; | 6128 | GOTO_NEXT_INST; |
| @@ -6142,12 +6141,12 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6142 | const u32 rt2 = cpu->Reg[inst_cream->Rm + 1]; | 6141 | const u32 rt2 = cpu->Reg[inst_cream->Rm + 1]; |
| 6143 | u64 value; | 6142 | u64 value; |
| 6144 | 6143 | ||
| 6145 | if (InBigEndianMode(cpu)) | 6144 | if (cpu->InBigEndianMode()) |
| 6146 | value = (((u64)rt << 32) | rt2); | 6145 | value = (((u64)rt << 32) | rt2); |
| 6147 | else | 6146 | else |
| 6148 | value = (((u64)rt2 << 32) | rt); | 6147 | value = (((u64)rt2 << 32) | rt); |
| 6149 | 6148 | ||
| 6150 | WriteMemory64(cpu, write_addr, value); | 6149 | cpu->WriteMemory64(write_addr, value); |
| 6151 | RD = 0; | 6150 | RD = 0; |
| 6152 | } | 6151 | } |
| 6153 | else { | 6152 | else { |
| @@ -6155,7 +6154,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6155 | RD = 1; | 6154 | RD = 1; |
| 6156 | } | 6155 | } |
| 6157 | } | 6156 | } |
| 6158 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6157 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6159 | INC_PC(sizeof(generic_arm_inst)); | 6158 | INC_PC(sizeof(generic_arm_inst)); |
| 6160 | FETCH_INST; | 6159 | FETCH_INST; |
| 6161 | GOTO_NEXT_INST; | 6160 | GOTO_NEXT_INST; |
| @@ -6170,14 +6169,14 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6170 | remove_exclusive(cpu, write_addr); | 6169 | remove_exclusive(cpu, write_addr); |
| 6171 | cpu->exclusive_state = 0; | 6170 | cpu->exclusive_state = 0; |
| 6172 | 6171 | ||
| 6173 | WriteMemory16(cpu, write_addr, RM); | 6172 | cpu->WriteMemory16(write_addr, RM); |
| 6174 | RD = 0; | 6173 | RD = 0; |
| 6175 | } else { | 6174 | } else { |
| 6176 | // Failed to write due to mutex access | 6175 | // Failed to write due to mutex access |
| 6177 | RD = 1; | 6176 | RD = 1; |
| 6178 | } | 6177 | } |
| 6179 | } | 6178 | } |
| 6180 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6179 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6181 | INC_PC(sizeof(generic_arm_inst)); | 6180 | INC_PC(sizeof(generic_arm_inst)); |
| 6182 | FETCH_INST; | 6181 | FETCH_INST; |
| 6183 | GOTO_NEXT_INST; | 6182 | GOTO_NEXT_INST; |
| @@ -6189,9 +6188,9 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6189 | inst_cream->get_addr(cpu, inst_cream->inst, addr); | 6188 | inst_cream->get_addr(cpu, inst_cream->inst, addr); |
| 6190 | 6189 | ||
| 6191 | unsigned int value = cpu->Reg[BITS(inst_cream->inst, 12, 15)] & 0xffff; | 6190 | unsigned int value = cpu->Reg[BITS(inst_cream->inst, 12, 15)] & 0xffff; |
| 6192 | WriteMemory16(cpu, addr, value); | 6191 | cpu->WriteMemory16(addr, value); |
| 6193 | } | 6192 | } |
| 6194 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6193 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6195 | INC_PC(sizeof(ldst_inst)); | 6194 | INC_PC(sizeof(ldst_inst)); |
| 6196 | FETCH_INST; | 6195 | FETCH_INST; |
| 6197 | GOTO_NEXT_INST; | 6196 | GOTO_NEXT_INST; |
| @@ -6203,9 +6202,9 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6203 | inst_cream->get_addr(cpu, inst_cream->inst, addr); | 6202 | inst_cream->get_addr(cpu, inst_cream->inst, addr); |
| 6204 | 6203 | ||
| 6205 | unsigned int value = cpu->Reg[BITS(inst_cream->inst, 12, 15)]; | 6204 | unsigned int value = cpu->Reg[BITS(inst_cream->inst, 12, 15)]; |
| 6206 | WriteMemory32(cpu, addr, value); | 6205 | cpu->WriteMemory32(addr, value); |
| 6207 | } | 6206 | } |
| 6208 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6207 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6209 | INC_PC(sizeof(ldst_inst)); | 6208 | INC_PC(sizeof(ldst_inst)); |
| 6210 | FETCH_INST; | 6209 | FETCH_INST; |
| 6211 | GOTO_NEXT_INST; | 6210 | GOTO_NEXT_INST; |
| @@ -6226,7 +6225,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6226 | if (inst_cream->S && (inst_cream->Rd == 15)) { | 6225 | if (inst_cream->S && (inst_cream->Rd == 15)) { |
| 6227 | if (CurrentModeHasSPSR) { | 6226 | if (CurrentModeHasSPSR) { |
| 6228 | cpu->Cpsr = cpu->Spsr_copy; | 6227 | cpu->Cpsr = cpu->Spsr_copy; |
| 6229 | switch_mode(cpu, cpu->Spsr_copy & 0x1f); | 6228 | cpu->ChangePrivilegeMode(cpu->Spsr_copy & 0x1F); |
| 6230 | LOAD_NZCVT; | 6229 | LOAD_NZCVT; |
| 6231 | } | 6230 | } |
| 6232 | } else if (inst_cream->S) { | 6231 | } else if (inst_cream->S) { |
| @@ -6240,7 +6239,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6240 | goto DISPATCH; | 6239 | goto DISPATCH; |
| 6241 | } | 6240 | } |
| 6242 | } | 6241 | } |
| 6243 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6242 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6244 | INC_PC(sizeof(sub_inst)); | 6243 | INC_PC(sizeof(sub_inst)); |
| 6245 | FETCH_INST; | 6244 | FETCH_INST; |
| 6246 | GOTO_NEXT_INST; | 6245 | GOTO_NEXT_INST; |
| @@ -6252,7 +6251,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6252 | SVC::CallSVC(inst_cream->num & 0xFFFF); | 6251 | SVC::CallSVC(inst_cream->num & 0xFFFF); |
| 6253 | } | 6252 | } |
| 6254 | 6253 | ||
| 6255 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6254 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6256 | INC_PC(sizeof(swi_inst)); | 6255 | INC_PC(sizeof(swi_inst)); |
| 6257 | FETCH_INST; | 6256 | FETCH_INST; |
| 6258 | GOTO_NEXT_INST; | 6257 | GOTO_NEXT_INST; |
| @@ -6263,12 +6262,12 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6263 | swp_inst* inst_cream = (swp_inst*)inst_base->component; | 6262 | swp_inst* inst_cream = (swp_inst*)inst_base->component; |
| 6264 | 6263 | ||
| 6265 | addr = RN; | 6264 | addr = RN; |
| 6266 | unsigned int value = ReadMemory32(cpu, addr); | 6265 | unsigned int value = cpu->ReadMemory32(addr); |
| 6267 | WriteMemory32(cpu, addr, RM); | 6266 | cpu->WriteMemory32(addr, RM); |
| 6268 | 6267 | ||
| 6269 | RD = value; | 6268 | RD = value; |
| 6270 | } | 6269 | } |
| 6271 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6270 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6272 | INC_PC(sizeof(swp_inst)); | 6271 | INC_PC(sizeof(swp_inst)); |
| 6273 | FETCH_INST; | 6272 | FETCH_INST; |
| 6274 | GOTO_NEXT_INST; | 6273 | GOTO_NEXT_INST; |
| @@ -6282,7 +6281,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6282 | Memory::Write8(addr, (RM & 0xFF)); | 6281 | Memory::Write8(addr, (RM & 0xFF)); |
| 6283 | RD = value; | 6282 | RD = value; |
| 6284 | } | 6283 | } |
| 6285 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6284 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6286 | INC_PC(sizeof(swp_inst)); | 6285 | INC_PC(sizeof(swp_inst)); |
| 6287 | FETCH_INST; | 6286 | FETCH_INST; |
| 6288 | GOTO_NEXT_INST; | 6287 | GOTO_NEXT_INST; |
| @@ -6298,7 +6297,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6298 | operand2 = (0x80 & operand2)? (0xFFFFFF00 | operand2):operand2; | 6297 | operand2 = (0x80 & operand2)? (0xFFFFFF00 | operand2):operand2; |
| 6299 | RD = RN + operand2; | 6298 | RD = RN + operand2; |
| 6300 | } | 6299 | } |
| 6301 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6300 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6302 | INC_PC(sizeof(uxtab_inst)); | 6301 | INC_PC(sizeof(uxtab_inst)); |
| 6303 | FETCH_INST; | 6302 | FETCH_INST; |
| 6304 | GOTO_NEXT_INST; | 6303 | GOTO_NEXT_INST; |
| @@ -6331,7 +6330,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6331 | } | 6330 | } |
| 6332 | } | 6331 | } |
| 6333 | 6332 | ||
| 6334 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6333 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6335 | INC_PC(sizeof(sxtab_inst)); | 6334 | INC_PC(sizeof(sxtab_inst)); |
| 6336 | FETCH_INST; | 6335 | FETCH_INST; |
| 6337 | GOTO_NEXT_INST; | 6336 | GOTO_NEXT_INST; |
| @@ -6347,7 +6346,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6347 | operand2 = (0x8000 & operand2) ? (0xFFFF0000 | operand2) : operand2; | 6346 | operand2 = (0x8000 & operand2) ? (0xFFFF0000 | operand2) : operand2; |
| 6348 | RD = RN + operand2; | 6347 | RD = RN + operand2; |
| 6349 | } | 6348 | } |
| 6350 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6349 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6351 | INC_PC(sizeof(sxtah_inst)); | 6350 | INC_PC(sizeof(sxtah_inst)); |
| 6352 | FETCH_INST; | 6351 | FETCH_INST; |
| 6353 | GOTO_NEXT_INST; | 6352 | GOTO_NEXT_INST; |
| @@ -6362,7 +6361,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6362 | u32 rop = SHIFTER_OPERAND; | 6361 | u32 rop = SHIFTER_OPERAND; |
| 6363 | 6362 | ||
| 6364 | if (inst_cream->Rn == 15) | 6363 | if (inst_cream->Rn == 15) |
| 6365 | lop += GET_INST_SIZE(cpu) * 2; | 6364 | lop += cpu->GetInstructionSize() * 2; |
| 6366 | 6365 | ||
| 6367 | u32 result = lop ^ rop; | 6366 | u32 result = lop ^ rop; |
| 6368 | 6367 | ||
| @@ -6370,7 +6369,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6370 | UPDATE_ZFLAG(result); | 6369 | UPDATE_ZFLAG(result); |
| 6371 | UPDATE_CFLAG_WITH_SC; | 6370 | UPDATE_CFLAG_WITH_SC; |
| 6372 | } | 6371 | } |
| 6373 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6372 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6374 | INC_PC(sizeof(teq_inst)); | 6373 | INC_PC(sizeof(teq_inst)); |
| 6375 | FETCH_INST; | 6374 | FETCH_INST; |
| 6376 | GOTO_NEXT_INST; | 6375 | GOTO_NEXT_INST; |
| @@ -6384,7 +6383,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6384 | u32 rop = SHIFTER_OPERAND; | 6383 | u32 rop = SHIFTER_OPERAND; |
| 6385 | 6384 | ||
| 6386 | if (inst_cream->Rn == 15) | 6385 | if (inst_cream->Rn == 15) |
| 6387 | lop += GET_INST_SIZE(cpu) * 2; | 6386 | lop += cpu->GetInstructionSize() * 2; |
| 6388 | 6387 | ||
| 6389 | u32 result = lop & rop; | 6388 | u32 result = lop & rop; |
| 6390 | 6389 | ||
| @@ -6392,7 +6391,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6392 | UPDATE_ZFLAG(result); | 6391 | UPDATE_ZFLAG(result); |
| 6393 | UPDATE_CFLAG_WITH_SC; | 6392 | UPDATE_CFLAG_WITH_SC; |
| 6394 | } | 6393 | } |
| 6395 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6394 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6396 | INC_PC(sizeof(tst_inst)); | 6395 | INC_PC(sizeof(tst_inst)); |
| 6397 | FETCH_INST; | 6396 | FETCH_INST; |
| 6398 | GOTO_NEXT_INST; | 6397 | GOTO_NEXT_INST; |
| @@ -6563,7 +6562,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6563 | RD = (lo_result & 0xFFFF) | ((hi_result & 0xFFFF) << 16); | 6562 | RD = (lo_result & 0xFFFF) | ((hi_result & 0xFFFF) << 16); |
| 6564 | } | 6563 | } |
| 6565 | 6564 | ||
| 6566 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6565 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6567 | INC_PC(sizeof(generic_arm_inst)); | 6566 | INC_PC(sizeof(generic_arm_inst)); |
| 6568 | FETCH_INST; | 6567 | FETCH_INST; |
| 6569 | GOTO_NEXT_INST; | 6568 | GOTO_NEXT_INST; |
| @@ -6643,7 +6642,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6643 | } | 6642 | } |
| 6644 | } | 6643 | } |
| 6645 | 6644 | ||
| 6646 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6645 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6647 | INC_PC(sizeof(generic_arm_inst)); | 6646 | INC_PC(sizeof(generic_arm_inst)); |
| 6648 | FETCH_INST; | 6647 | FETCH_INST; |
| 6649 | GOTO_NEXT_INST; | 6648 | GOTO_NEXT_INST; |
| @@ -6662,7 +6661,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6662 | RDLO = (result & 0xFFFFFFFF); | 6661 | RDLO = (result & 0xFFFFFFFF); |
| 6663 | RDHI = ((result >> 32) & 0xFFFFFFFF); | 6662 | RDHI = ((result >> 32) & 0xFFFFFFFF); |
| 6664 | } | 6663 | } |
| 6665 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6664 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6666 | INC_PC(sizeof(umaal_inst)); | 6665 | INC_PC(sizeof(umaal_inst)); |
| 6667 | FETCH_INST; | 6666 | FETCH_INST; |
| 6668 | GOTO_NEXT_INST; | 6667 | GOTO_NEXT_INST; |
| @@ -6685,7 +6684,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6685 | cpu->ZFlag = (RDHI == 0 && RDLO == 0); | 6684 | cpu->ZFlag = (RDHI == 0 && RDLO == 0); |
| 6686 | } | 6685 | } |
| 6687 | } | 6686 | } |
| 6688 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6687 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6689 | INC_PC(sizeof(umlal_inst)); | 6688 | INC_PC(sizeof(umlal_inst)); |
| 6690 | FETCH_INST; | 6689 | FETCH_INST; |
| 6691 | GOTO_NEXT_INST; | 6690 | GOTO_NEXT_INST; |
| @@ -6705,7 +6704,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6705 | cpu->ZFlag = (RDHI == 0 && RDLO == 0); | 6704 | cpu->ZFlag = (RDHI == 0 && RDLO == 0); |
| 6706 | } | 6705 | } |
| 6707 | } | 6706 | } |
| 6708 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6707 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6709 | INC_PC(sizeof(umull_inst)); | 6708 | INC_PC(sizeof(umull_inst)); |
| 6710 | FETCH_INST; | 6709 | FETCH_INST; |
| 6711 | GOTO_NEXT_INST; | 6710 | GOTO_NEXT_INST; |
| @@ -6733,7 +6732,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6733 | { | 6732 | { |
| 6734 | bl_1_thumb* inst_cream = (bl_1_thumb*)inst_base->component; | 6733 | bl_1_thumb* inst_cream = (bl_1_thumb*)inst_base->component; |
| 6735 | cpu->Reg[14] = cpu->Reg[15] + 4 + inst_cream->imm; | 6734 | cpu->Reg[14] = cpu->Reg[15] + 4 + inst_cream->imm; |
| 6736 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6735 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6737 | INC_PC(sizeof(bl_1_thumb)); | 6736 | INC_PC(sizeof(bl_1_thumb)); |
| 6738 | FETCH_INST; | 6737 | FETCH_INST; |
| 6739 | GOTO_NEXT_INST; | 6738 | GOTO_NEXT_INST; |
| @@ -6814,7 +6813,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6814 | RD = ((lo_val & 0xFFFF) | hi_val << 16); | 6813 | RD = ((lo_val & 0xFFFF) | hi_val << 16); |
| 6815 | } | 6814 | } |
| 6816 | 6815 | ||
| 6817 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6816 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6818 | INC_PC(sizeof(generic_arm_inst)); | 6817 | INC_PC(sizeof(generic_arm_inst)); |
| 6819 | FETCH_INST; | 6818 | FETCH_INST; |
| 6820 | GOTO_NEXT_INST; | 6819 | GOTO_NEXT_INST; |
| @@ -6844,7 +6843,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6844 | RD = finalDif; | 6843 | RD = finalDif; |
| 6845 | } | 6844 | } |
| 6846 | 6845 | ||
| 6847 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6846 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6848 | INC_PC(sizeof(generic_arm_inst)); | 6847 | INC_PC(sizeof(generic_arm_inst)); |
| 6849 | FETCH_INST; | 6848 | FETCH_INST; |
| 6850 | GOTO_NEXT_INST; | 6849 | GOTO_NEXT_INST; |
| @@ -6877,7 +6876,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6877 | RD = rn_val; | 6876 | RD = rn_val; |
| 6878 | } | 6877 | } |
| 6879 | 6878 | ||
| 6880 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6879 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6881 | INC_PC(sizeof(ssat_inst)); | 6880 | INC_PC(sizeof(ssat_inst)); |
| 6882 | FETCH_INST; | 6881 | FETCH_INST; |
| 6883 | GOTO_NEXT_INST; | 6882 | GOTO_NEXT_INST; |
| @@ -6899,7 +6898,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6899 | cpu->Cpsr |= (1 << 27); | 6898 | cpu->Cpsr |= (1 << 27); |
| 6900 | } | 6899 | } |
| 6901 | 6900 | ||
| 6902 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6901 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6903 | INC_PC(sizeof(ssat_inst)); | 6902 | INC_PC(sizeof(ssat_inst)); |
| 6904 | FETCH_INST; | 6903 | FETCH_INST; |
| 6905 | GOTO_NEXT_INST; | 6904 | GOTO_NEXT_INST; |
| @@ -6930,7 +6929,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6930 | } | 6929 | } |
| 6931 | } | 6930 | } |
| 6932 | 6931 | ||
| 6933 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6932 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6934 | INC_PC(sizeof(uxtab_inst)); | 6933 | INC_PC(sizeof(uxtab_inst)); |
| 6935 | FETCH_INST; | 6934 | FETCH_INST; |
| 6936 | GOTO_NEXT_INST; | 6935 | GOTO_NEXT_INST; |
| @@ -6943,7 +6942,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6943 | LOG_TRACE(Core_ARM11, "WFE executed."); | 6942 | LOG_TRACE(Core_ARM11, "WFE executed."); |
| 6944 | } | 6943 | } |
| 6945 | 6944 | ||
| 6946 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6945 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6947 | INC_PC_STUB; | 6946 | INC_PC_STUB; |
| 6948 | FETCH_INST; | 6947 | FETCH_INST; |
| 6949 | GOTO_NEXT_INST; | 6948 | GOTO_NEXT_INST; |
| @@ -6956,7 +6955,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6956 | LOG_TRACE(Core_ARM11, "WFI executed."); | 6955 | LOG_TRACE(Core_ARM11, "WFI executed."); |
| 6957 | } | 6956 | } |
| 6958 | 6957 | ||
| 6959 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6958 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6960 | INC_PC_STUB; | 6959 | INC_PC_STUB; |
| 6961 | FETCH_INST; | 6960 | FETCH_INST; |
| 6962 | GOTO_NEXT_INST; | 6961 | GOTO_NEXT_INST; |
| @@ -6969,7 +6968,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) { | |||
| 6969 | LOG_TRACE(Core_ARM11, "YIELD executed."); | 6968 | LOG_TRACE(Core_ARM11, "YIELD executed."); |
| 6970 | } | 6969 | } |
| 6971 | 6970 | ||
| 6972 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6971 | cpu->Reg[15] += cpu->GetInstructionSize(); |
| 6973 | INC_PC_STUB; | 6972 | INC_PC_STUB; |
| 6974 | FETCH_INST; | 6973 | FETCH_INST; |
| 6975 | GOTO_NEXT_INST; | 6974 | GOTO_NEXT_INST; |
diff --git a/src/core/arm/dyncom/arm_dyncom_run.cpp b/src/core/arm/dyncom/arm_dyncom_run.cpp deleted file mode 100644 index 4c6acba98..000000000 --- a/src/core/arm/dyncom/arm_dyncom_run.cpp +++ /dev/null | |||
| @@ -1,93 +0,0 @@ | |||
| 1 | // Copyright 2012 Michael Kang, 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "core/arm/dyncom/arm_dyncom_run.h" | ||
| 6 | #include "core/arm/skyeye_common/armstate.h" | ||
| 7 | |||
| 8 | void switch_mode(ARMul_State* core, uint32_t mode) { | ||
| 9 | if (core->Mode == mode) | ||
| 10 | return; | ||
| 11 | |||
| 12 | if (mode != USERBANK) { | ||
| 13 | switch (core->Mode) { | ||
| 14 | case SYSTEM32MODE: // Shares registers with user mode | ||
| 15 | case USER32MODE: | ||
| 16 | core->Reg_usr[0] = core->Reg[13]; | ||
| 17 | core->Reg_usr[1] = core->Reg[14]; | ||
| 18 | break; | ||
| 19 | case IRQ32MODE: | ||
| 20 | core->Reg_irq[0] = core->Reg[13]; | ||
| 21 | core->Reg_irq[1] = core->Reg[14]; | ||
| 22 | core->Spsr[IRQBANK] = core->Spsr_copy; | ||
| 23 | break; | ||
| 24 | case SVC32MODE: | ||
| 25 | core->Reg_svc[0] = core->Reg[13]; | ||
| 26 | core->Reg_svc[1] = core->Reg[14]; | ||
| 27 | core->Spsr[SVCBANK] = core->Spsr_copy; | ||
| 28 | break; | ||
| 29 | case ABORT32MODE: | ||
| 30 | core->Reg_abort[0] = core->Reg[13]; | ||
| 31 | core->Reg_abort[1] = core->Reg[14]; | ||
| 32 | core->Spsr[ABORTBANK] = core->Spsr_copy; | ||
| 33 | break; | ||
| 34 | case UNDEF32MODE: | ||
| 35 | core->Reg_undef[0] = core->Reg[13]; | ||
| 36 | core->Reg_undef[1] = core->Reg[14]; | ||
| 37 | core->Spsr[UNDEFBANK] = core->Spsr_copy; | ||
| 38 | break; | ||
| 39 | case FIQ32MODE: | ||
| 40 | core->Reg_firq[0] = core->Reg[13]; | ||
| 41 | core->Reg_firq[1] = core->Reg[14]; | ||
| 42 | core->Spsr[FIQBANK] = core->Spsr_copy; | ||
| 43 | break; | ||
| 44 | } | ||
| 45 | |||
| 46 | switch (mode) { | ||
| 47 | case USER32MODE: | ||
| 48 | core->Reg[13] = core->Reg_usr[0]; | ||
| 49 | core->Reg[14] = core->Reg_usr[1]; | ||
| 50 | core->Bank = USERBANK; | ||
| 51 | break; | ||
| 52 | case IRQ32MODE: | ||
| 53 | core->Reg[13] = core->Reg_irq[0]; | ||
| 54 | core->Reg[14] = core->Reg_irq[1]; | ||
| 55 | core->Spsr_copy = core->Spsr[IRQBANK]; | ||
| 56 | core->Bank = IRQBANK; | ||
| 57 | break; | ||
| 58 | case SVC32MODE: | ||
| 59 | core->Reg[13] = core->Reg_svc[0]; | ||
| 60 | core->Reg[14] = core->Reg_svc[1]; | ||
| 61 | core->Spsr_copy = core->Spsr[SVCBANK]; | ||
| 62 | core->Bank = SVCBANK; | ||
| 63 | break; | ||
| 64 | case ABORT32MODE: | ||
| 65 | core->Reg[13] = core->Reg_abort[0]; | ||
| 66 | core->Reg[14] = core->Reg_abort[1]; | ||
| 67 | core->Spsr_copy = core->Spsr[ABORTBANK]; | ||
| 68 | core->Bank = ABORTBANK; | ||
| 69 | break; | ||
| 70 | case UNDEF32MODE: | ||
| 71 | core->Reg[13] = core->Reg_undef[0]; | ||
| 72 | core->Reg[14] = core->Reg_undef[1]; | ||
| 73 | core->Spsr_copy = core->Spsr[UNDEFBANK]; | ||
| 74 | core->Bank = UNDEFBANK; | ||
| 75 | break; | ||
| 76 | case FIQ32MODE: | ||
| 77 | core->Reg[13] = core->Reg_firq[0]; | ||
| 78 | core->Reg[14] = core->Reg_firq[1]; | ||
| 79 | core->Spsr_copy = core->Spsr[FIQBANK]; | ||
| 80 | core->Bank = FIQBANK; | ||
| 81 | break; | ||
| 82 | case SYSTEM32MODE: // Shares registers with user mode. | ||
| 83 | core->Reg[13] = core->Reg_usr[0]; | ||
| 84 | core->Reg[14] = core->Reg_usr[1]; | ||
| 85 | core->Bank = SYSTEMBANK; | ||
| 86 | break; | ||
| 87 | } | ||
| 88 | |||
| 89 | // Set the mode bits in the APSR | ||
| 90 | core->Cpsr = (core->Cpsr & ~core->Mode) | mode; | ||
| 91 | core->Mode = mode; | ||
| 92 | } | ||
| 93 | } | ||
diff --git a/src/core/arm/dyncom/arm_dyncom_run.h b/src/core/arm/dyncom/arm_dyncom_run.h index ef18455bc..13bef17fc 100644 --- a/src/core/arm/dyncom/arm_dyncom_run.h +++ b/src/core/arm/dyncom/arm_dyncom_run.h | |||
| @@ -20,38 +20,29 @@ | |||
| 20 | 20 | ||
| 21 | #include "core/arm/skyeye_common/armstate.h" | 21 | #include "core/arm/skyeye_common/armstate.h" |
| 22 | 22 | ||
| 23 | void switch_mode(ARMul_State* core, uint32_t mode); | ||
| 24 | |||
| 25 | // Note that for the 3DS, a Thumb instruction will only ever be | ||
| 26 | // two bytes in size. Thus we don't need to worry about ThumbEE | ||
| 27 | // or Thumb-2 where instructions can be 4 bytes in length. | ||
| 28 | static inline u32 GET_INST_SIZE(ARMul_State* core) { | ||
| 29 | return core->TFlag? 2 : 4; | ||
| 30 | } | ||
| 31 | |||
| 32 | /** | 23 | /** |
| 33 | * Checks if the PC is being read, and if so, word-aligns it. | 24 | * Checks if the PC is being read, and if so, word-aligns it. |
| 34 | * Used with address calculations. | 25 | * Used with address calculations. |
| 35 | * | 26 | * |
| 36 | * @param core The ARM CPU state instance. | 27 | * @param cpu The ARM CPU state instance. |
| 37 | * @param Rn The register being read. | 28 | * @param Rn The register being read. |
| 38 | * | 29 | * |
| 39 | * @return If the PC is being read, then the word-aligned PC value is returned. | 30 | * @return If the PC is being read, then the word-aligned PC value is returned. |
| 40 | * If the PC is not being read, then the value stored in the register is returned. | 31 | * If the PC is not being read, then the value stored in the register is returned. |
| 41 | */ | 32 | */ |
| 42 | static inline u32 CHECK_READ_REG15_WA(ARMul_State* core, int Rn) { | 33 | static inline u32 CHECK_READ_REG15_WA(ARMul_State* cpu, int Rn) { |
| 43 | return (Rn == 15) ? ((core->Reg[15] & ~0x3) + GET_INST_SIZE(core) * 2) : core->Reg[Rn]; | 34 | return (Rn == 15) ? ((cpu->Reg[15] & ~0x3) + cpu->GetInstructionSize() * 2) : cpu->Reg[Rn]; |
| 44 | } | 35 | } |
| 45 | 36 | ||
| 46 | /** | 37 | /** |
| 47 | * Reads the PC. Used for data processing operations that use the PC. | 38 | * Reads the PC. Used for data processing operations that use the PC. |
| 48 | * | 39 | * |
| 49 | * @param core The ARM CPU state instance. | 40 | * @param cpu The ARM CPU state instance. |
| 50 | * @param Rn The register being read. | 41 | * @param Rn The register being read. |
| 51 | * | 42 | * |
| 52 | * @return If the PC is being read, then the incremented PC value is returned. | 43 | * @return If the PC is being read, then the incremented PC value is returned. |
| 53 | * If the PC is not being read, then the values stored in the register is returned. | 44 | * If the PC is not being read, then the values stored in the register is returned. |
| 54 | */ | 45 | */ |
| 55 | static inline u32 CHECK_READ_REG15(ARMul_State* core, int Rn) { | 46 | static inline u32 CHECK_READ_REG15(ARMul_State* cpu, int Rn) { |
| 56 | return (Rn == 15) ? ((core->Reg[15] & ~0x1) + GET_INST_SIZE(core) * 2) : core->Reg[Rn]; | 47 | return (Rn == 15) ? ((cpu->Reg[15] & ~0x1) + cpu->GetInstructionSize() * 2) : cpu->Reg[Rn]; |
| 57 | } | 48 | } |