diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/arm/dyncom/arm_dyncom_dec.cpp | 4 | ||||
| -rw-r--r-- | src/core/arm/dyncom/arm_dyncom_dec.h | 37 | ||||
| -rw-r--r-- | src/core/arm/dyncom/arm_dyncom_interpreter.cpp | 64 |
3 files changed, 64 insertions, 41 deletions
diff --git a/src/core/arm/dyncom/arm_dyncom_dec.cpp b/src/core/arm/dyncom/arm_dyncom_dec.cpp index 9f3b90fd0..12181d0ec 100644 --- a/src/core/arm/dyncom/arm_dyncom_dec.cpp +++ b/src/core/arm/dyncom/arm_dyncom_dec.cpp | |||
| @@ -413,7 +413,7 @@ int decode_arm_instr(uint32_t instr, int32_t *idx) { | |||
| 413 | if (instr != arm_instruction[i].content[base + 2]) { | 413 | if (instr != arm_instruction[i].content[base + 2]) { |
| 414 | break; | 414 | break; |
| 415 | } | 415 | } |
| 416 | } else if (BITS(arm_instruction[i].content[base], arm_instruction[i].content[base + 1]) != arm_instruction[i].content[base + 2]) { | 416 | } else if (BITS(instr, arm_instruction[i].content[base], arm_instruction[i].content[base + 1]) != arm_instruction[i].content[base + 2]) { |
| 417 | break; | 417 | break; |
| 418 | } | 418 | } |
| 419 | base += 3; | 419 | base += 3; |
| @@ -429,7 +429,7 @@ int decode_arm_instr(uint32_t instr, int32_t *idx) { | |||
| 429 | if (n != 0) { | 429 | if (n != 0) { |
| 430 | base = 0; | 430 | base = 0; |
| 431 | while (n) { | 431 | while (n) { |
| 432 | if (BITS(arm_exclusion_code[i].content[base], arm_exclusion_code[i].content[base + 1]) != arm_exclusion_code[i].content[base + 2]) { | 432 | if (BITS(instr, arm_exclusion_code[i].content[base], arm_exclusion_code[i].content[base + 1]) != arm_exclusion_code[i].content[base + 2]) { |
| 433 | break; | 433 | break; |
| 434 | } | 434 | } |
| 435 | base += 3; | 435 | base += 3; |
diff --git a/src/core/arm/dyncom/arm_dyncom_dec.h b/src/core/arm/dyncom/arm_dyncom_dec.h index ee8ff5992..4b5f5ad7e 100644 --- a/src/core/arm/dyncom/arm_dyncom_dec.h +++ b/src/core/arm/dyncom/arm_dyncom_dec.h | |||
| @@ -4,43 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #define BITS(a,b) ((instr >> (a)) & ((1 << (1+(b)-(a)))-1)) | ||
| 8 | #define BIT(n) ((instr >> (n)) & 1) | ||
| 9 | |||
| 10 | // For MUL instructions | ||
| 11 | #define RDHi ((instr >> 16) & 0xF) | ||
| 12 | #define RDLo ((instr >> 12) & 0xF) | ||
| 13 | #define MUL_RD ((instr >> 16) & 0xF) | ||
| 14 | #define MUL_RN ((instr >> 12) & 0xF) | ||
| 15 | #define RS ((instr >> 8) & 0xF) | ||
| 16 | #define RD ((instr >> 12) & 0xF) | ||
| 17 | #define RN ((instr >> 16) & 0xF) | ||
| 18 | #define RM (instr & 0xF) | ||
| 19 | |||
| 20 | // CP15 registers | ||
| 21 | #define OPCODE_1 BITS(21, 23) | ||
| 22 | #define CRn BITS(16, 19) | ||
| 23 | #define CRm BITS(0, 3) | ||
| 24 | #define OPCODE_2 BITS(5, 7) | ||
| 25 | |||
| 26 | #define I BIT(25) | ||
| 27 | #define S BIT(20) | ||
| 28 | |||
| 29 | #define SHIFT BITS(5,6) | ||
| 30 | #define SHIFT_IMM BITS(7,11) | ||
| 31 | #define IMMH BITS(8,11) | ||
| 32 | #define IMML BITS(0,3) | ||
| 33 | |||
| 34 | #define LSPBIT BIT(24) | ||
| 35 | #define LSUBIT BIT(23) | ||
| 36 | #define LSBBIT BIT(22) | ||
| 37 | #define LSWBIT BIT(21) | ||
| 38 | #define LSLBIT BIT(20) | ||
| 39 | #define LSSHBITS BITS(5,6) | ||
| 40 | #define OFFSET12 BITS(0,11) | ||
| 41 | #define SBIT BIT(20) | ||
| 42 | #define DESTReg (BITS (12, 15)) | ||
| 43 | |||
| 44 | int decode_arm_instr(uint32_t instr, int32_t *idx); | 7 | int decode_arm_instr(uint32_t instr, int32_t *idx); |
| 45 | 8 | ||
| 46 | enum DECODE_STATUS { | 9 | enum DECODE_STATUS { |
diff --git a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp index cfa6de8fc..2765cb36e 100644 --- a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp +++ b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp | |||
| @@ -2156,7 +2156,22 @@ static ARM_INST_PTR INTERPRETER_TRANSLATE(revsh)(unsigned int inst, int index) | |||
| 2156 | return INTERPRETER_TRANSLATE(rev)(inst, index); | 2156 | return INTERPRETER_TRANSLATE(rev)(inst, index); |
| 2157 | } | 2157 | } |
| 2158 | 2158 | ||
| 2159 | static ARM_INST_PTR INTERPRETER_TRANSLATE(rfe)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("RFE"); } | 2159 | static ARM_INST_PTR INTERPRETER_TRANSLATE(rfe)(unsigned int inst, int index) |
| 2160 | { | ||
| 2161 | arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(ldst_inst)); | ||
| 2162 | ldst_inst* const inst_cream = (ldst_inst*)inst_base->component; | ||
| 2163 | |||
| 2164 | inst_base->cond = AL; | ||
| 2165 | inst_base->idx = index; | ||
| 2166 | inst_base->br = INDIRECT_BRANCH; | ||
| 2167 | inst_base->load_r15 = 0; | ||
| 2168 | |||
| 2169 | inst_cream->inst = inst; | ||
| 2170 | inst_cream->get_addr = get_calc_addr_op(inst); | ||
| 2171 | |||
| 2172 | return inst_base; | ||
| 2173 | } | ||
| 2174 | |||
| 2160 | static ARM_INST_PTR INTERPRETER_TRANSLATE(rsb)(unsigned int inst, int index) | 2175 | static ARM_INST_PTR INTERPRETER_TRANSLATE(rsb)(unsigned int inst, int index) |
| 2161 | { | 2176 | { |
| 2162 | arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(rsb_inst)); | 2177 | arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(rsb_inst)); |
| @@ -2570,7 +2585,23 @@ static ARM_INST_PTR INTERPRETER_TRANSLATE(smulw)(unsigned int inst, int index) | |||
| 2570 | inst_base->load_r15 = 1; | 2585 | inst_base->load_r15 = 1; |
| 2571 | return inst_base; | 2586 | return inst_base; |
| 2572 | } | 2587 | } |
| 2573 | static ARM_INST_PTR INTERPRETER_TRANSLATE(srs)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SRS"); } | 2588 | |
| 2589 | static ARM_INST_PTR INTERPRETER_TRANSLATE(srs)(unsigned int inst, int index) | ||
| 2590 | { | ||
| 2591 | arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(ldst_inst)); | ||
| 2592 | ldst_inst* const inst_cream = (ldst_inst*)inst_base->component; | ||
| 2593 | |||
| 2594 | inst_base->cond = AL; | ||
| 2595 | inst_base->idx = index; | ||
| 2596 | inst_base->br = NON_BRANCH; | ||
| 2597 | inst_base->load_r15 = 0; | ||
| 2598 | |||
| 2599 | inst_cream->inst = inst; | ||
| 2600 | inst_cream->get_addr = get_calc_addr_op(inst); | ||
| 2601 | |||
| 2602 | return inst_base; | ||
| 2603 | } | ||
| 2604 | |||
| 2574 | static ARM_INST_PTR INTERPRETER_TRANSLATE(ssat)(unsigned int inst, int index) | 2605 | static ARM_INST_PTR INTERPRETER_TRANSLATE(ssat)(unsigned int inst, int index) |
| 2575 | { | 2606 | { |
| 2576 | arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(ssat_inst)); | 2607 | arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(ssat_inst)); |
| @@ -5293,6 +5324,20 @@ unsigned InterpreterMainLoop(ARMul_State* state) { | |||
| 5293 | } | 5324 | } |
| 5294 | 5325 | ||
| 5295 | RFE_INST: | 5326 | RFE_INST: |
| 5327 | { | ||
| 5328 | // RFE is unconditional | ||
| 5329 | ldst_inst* const inst_cream = (ldst_inst*)inst_base->component; | ||
| 5330 | |||
| 5331 | u32 address = 0; | ||
| 5332 | inst_cream->get_addr(cpu, inst_cream->inst, address, 1); | ||
| 5333 | |||
| 5334 | cpu->Cpsr = ReadMemory32(cpu, address); | ||
| 5335 | cpu->Reg[15] = ReadMemory32(cpu, address + 4); | ||
| 5336 | |||
| 5337 | INC_PC(sizeof(ldst_inst)); | ||
| 5338 | goto DISPATCH; | ||
| 5339 | } | ||
| 5340 | |||
| 5296 | RSB_INST: | 5341 | RSB_INST: |
| 5297 | { | 5342 | { |
| 5298 | if (inst_base->cond == 0xE || CondPassed(cpu, inst_base->cond)) { | 5343 | if (inst_base->cond == 0xE || CondPassed(cpu, inst_base->cond)) { |
| @@ -5934,6 +5979,21 @@ unsigned InterpreterMainLoop(ARMul_State* state) { | |||
| 5934 | } | 5979 | } |
| 5935 | 5980 | ||
| 5936 | SRS_INST: | 5981 | SRS_INST: |
| 5982 | { | ||
| 5983 | // SRS is unconditional | ||
| 5984 | ldst_inst* const inst_cream = (ldst_inst*)inst_base->component; | ||
| 5985 | |||
| 5986 | u32 address = 0; | ||
| 5987 | inst_cream->get_addr(cpu, inst_cream->inst, address, 1); | ||
| 5988 | |||
| 5989 | WriteMemory32(cpu, address + 0, cpu->Reg[14]); | ||
| 5990 | WriteMemory32(cpu, address + 4, cpu->Spsr_copy); | ||
| 5991 | |||
| 5992 | cpu->Reg[15] += GET_INST_SIZE(cpu); | ||
| 5993 | INC_PC(sizeof(ldst_inst)); | ||
| 5994 | FETCH_INST; | ||
| 5995 | GOTO_NEXT_INST; | ||
| 5996 | } | ||
| 5937 | 5997 | ||
| 5938 | SSAT_INST: | 5998 | SSAT_INST: |
| 5939 | { | 5999 | { |