diff options
| author | 2014-12-21 20:33:14 -0500 | |
|---|---|---|
| committer | 2014-12-21 20:33:14 -0500 | |
| commit | 770b274c868e1d05befe5be88f96b0c6b590955d (patch) | |
| tree | 2410f905a53c04e3b3524399161225101ebe68ba /src | |
| parent | Merge pull request #291 from purpasmart96/license (diff) | |
| parent | dyncom: Move over SASX/SSAX/SADD16/SSUB16 (diff) | |
| download | yuzu-770b274c868e1d05befe5be88f96b0c6b590955d.tar.gz yuzu-770b274c868e1d05befe5be88f96b0c6b590955d.tar.xz yuzu-770b274c868e1d05befe5be88f96b0c6b590955d.zip | |
Merge pull request #324 from lioncash/dync
dyncom: Move over SASX/SSAX/SADD16/SSUB16
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/arm/dyncom/arm_dyncom_interpreter.cpp | 109 |
1 files changed, 102 insertions, 7 deletions
diff --git a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp index 84b4a38f0..b6b94b7a8 100644 --- a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp +++ b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp | |||
| @@ -1019,6 +1019,15 @@ typedef struct _arm_inst { | |||
| 1019 | char component[0]; | 1019 | char component[0]; |
| 1020 | } arm_inst; | 1020 | } arm_inst; |
| 1021 | 1021 | ||
| 1022 | typedef struct generic_arm_inst { | ||
| 1023 | u32 Ra; | ||
| 1024 | u32 Rm; | ||
| 1025 | u32 Rn; | ||
| 1026 | u32 Rd; | ||
| 1027 | u8 op1; | ||
| 1028 | u8 op2; | ||
| 1029 | } generic_arm_inst; | ||
| 1030 | |||
| 1022 | typedef struct _adc_inst { | 1031 | typedef struct _adc_inst { |
| 1023 | unsigned int I; | 1032 | unsigned int I; |
| 1024 | unsigned int S; | 1033 | unsigned int S; |
| @@ -2469,9 +2478,29 @@ ARM_INST_PTR INTERPRETER_TRANSLATE(rsc)(unsigned int inst, int index) | |||
| 2469 | } | 2478 | } |
| 2470 | return inst_base; | 2479 | return inst_base; |
| 2471 | } | 2480 | } |
| 2472 | ARM_INST_PTR INTERPRETER_TRANSLATE(sadd16)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SADD16"); } | ||
| 2473 | ARM_INST_PTR INTERPRETER_TRANSLATE(sadd8)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SADD8"); } | 2481 | ARM_INST_PTR INTERPRETER_TRANSLATE(sadd8)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SADD8"); } |
| 2474 | ARM_INST_PTR INTERPRETER_TRANSLATE(saddsubx)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SADDSUBX"); } | 2482 | ARM_INST_PTR INTERPRETER_TRANSLATE(sadd16)(unsigned int inst, int index) |
| 2483 | { | ||
| 2484 | arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(generic_arm_inst)); | ||
| 2485 | generic_arm_inst* const inst_cream = (generic_arm_inst*)inst_base->component; | ||
| 2486 | |||
| 2487 | inst_base->cond = BITS(inst, 28, 31); | ||
| 2488 | inst_base->idx = index; | ||
| 2489 | inst_base->br = NON_BRANCH; | ||
| 2490 | inst_base->load_r15 = 0; | ||
| 2491 | |||
| 2492 | inst_cream->Rm = BITS(inst, 0, 3); | ||
| 2493 | inst_cream->Rn = BITS(inst, 16, 19); | ||
| 2494 | inst_cream->Rd = BITS(inst, 12, 15); | ||
| 2495 | inst_cream->op1 = BITS(inst, 20, 21); | ||
| 2496 | inst_cream->op2 = BITS(inst, 5, 7); | ||
| 2497 | |||
| 2498 | return inst_base; | ||
| 2499 | } | ||
| 2500 | ARM_INST_PTR INTERPRETER_TRANSLATE(saddsubx)(unsigned int inst, int index) | ||
| 2501 | { | ||
| 2502 | return INTERPRETER_TRANSLATE(sadd16)(inst, index); | ||
| 2503 | } | ||
| 2475 | ARM_INST_PTR INTERPRETER_TRANSLATE(sbc)(unsigned int inst, int index) | 2504 | ARM_INST_PTR INTERPRETER_TRANSLATE(sbc)(unsigned int inst, int index) |
| 2476 | { | 2505 | { |
| 2477 | arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(sbc_inst)); | 2506 | arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(sbc_inst)); |
| @@ -2637,9 +2666,15 @@ ARM_INST_PTR INTERPRETER_TRANSLATE(smusd)(unsigned int inst, int index) { UNI | |||
| 2637 | ARM_INST_PTR INTERPRETER_TRANSLATE(srs)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SRS"); } | 2666 | ARM_INST_PTR INTERPRETER_TRANSLATE(srs)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SRS"); } |
| 2638 | ARM_INST_PTR INTERPRETER_TRANSLATE(ssat)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SSAT"); } | 2667 | ARM_INST_PTR INTERPRETER_TRANSLATE(ssat)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SSAT"); } |
| 2639 | ARM_INST_PTR INTERPRETER_TRANSLATE(ssat16)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SSAT16"); } | 2668 | ARM_INST_PTR INTERPRETER_TRANSLATE(ssat16)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SSAT16"); } |
| 2640 | ARM_INST_PTR INTERPRETER_TRANSLATE(ssub16)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SSUB16"); } | ||
| 2641 | ARM_INST_PTR INTERPRETER_TRANSLATE(ssub8)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SSUB8"); } | 2669 | ARM_INST_PTR INTERPRETER_TRANSLATE(ssub8)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SSUB8"); } |
| 2642 | ARM_INST_PTR INTERPRETER_TRANSLATE(ssubaddx)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SSUBADDX"); } | 2670 | ARM_INST_PTR INTERPRETER_TRANSLATE(ssub16)(unsigned int inst, int index) |
| 2671 | { | ||
| 2672 | return INTERPRETER_TRANSLATE(sadd16)(inst, index); | ||
| 2673 | } | ||
| 2674 | ARM_INST_PTR INTERPRETER_TRANSLATE(ssubaddx)(unsigned int inst, int index) | ||
| 2675 | { | ||
| 2676 | return INTERPRETER_TRANSLATE(sadd16)(inst, index); | ||
| 2677 | } | ||
| 2643 | ARM_INST_PTR INTERPRETER_TRANSLATE(stc)(unsigned int inst, int index) | 2678 | ARM_INST_PTR INTERPRETER_TRANSLATE(stc)(unsigned int inst, int index) |
| 2644 | { | 2679 | { |
| 2645 | arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(stc_inst)); | 2680 | arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(stc_inst)); |
| @@ -5626,9 +5661,71 @@ unsigned InterpreterMainLoop(ARMul_State* state) | |||
| 5626 | FETCH_INST; | 5661 | FETCH_INST; |
| 5627 | GOTO_NEXT_INST; | 5662 | GOTO_NEXT_INST; |
| 5628 | } | 5663 | } |
| 5629 | SADD16_INST: | ||
| 5630 | SADD8_INST: | 5664 | SADD8_INST: |
| 5665 | |||
| 5666 | SADD16_INST: | ||
| 5631 | SADDSUBX_INST: | 5667 | SADDSUBX_INST: |
| 5668 | SSUBADDX_INST: | ||
| 5669 | SSUB16_INST: | ||
| 5670 | { | ||
| 5671 | INC_ICOUNTER; | ||
| 5672 | if (inst_base->cond == 0xE || CondPassed(cpu, inst_base->cond)) { | ||
| 5673 | generic_arm_inst* const inst_cream = (generic_arm_inst*)inst_base->component; | ||
| 5674 | |||
| 5675 | const s16 rn_lo = (RN & 0xFFFF); | ||
| 5676 | const s16 rn_hi = ((RN >> 16) & 0xFFFF); | ||
| 5677 | const s16 rm_lo = (RM & 0xFFFF); | ||
| 5678 | const s16 rm_hi = ((RM >> 16) & 0xFFFF); | ||
| 5679 | |||
| 5680 | s32 lo_result = 0; | ||
| 5681 | s32 hi_result = 0; | ||
| 5682 | |||
| 5683 | // SADD16 | ||
| 5684 | if (inst_cream->op2 == 0x00) { | ||
| 5685 | lo_result = (rn_lo + rm_lo); | ||
| 5686 | hi_result = (rn_hi + rm_hi); | ||
| 5687 | } | ||
| 5688 | // SASX | ||
| 5689 | else if (inst_cream->op2 == 0x01) { | ||
| 5690 | lo_result = (rn_lo - rm_hi); | ||
| 5691 | hi_result = (rn_hi + rm_lo); | ||
| 5692 | } | ||
| 5693 | // SSAX | ||
| 5694 | else if (inst_cream->op2 == 0x02) { | ||
| 5695 | lo_result = (rn_lo + rm_hi); | ||
| 5696 | hi_result = (rn_hi - rm_lo); | ||
| 5697 | } | ||
| 5698 | // SSUB16 | ||
| 5699 | else if (inst_cream->op2 == 0x03) { | ||
| 5700 | lo_result = (rn_lo - rm_lo); | ||
| 5701 | hi_result = (rn_hi - rm_hi); | ||
| 5702 | } | ||
| 5703 | |||
| 5704 | RD = (lo_result & 0xFFFF) | ((hi_result & 0xFFFF) << 16); | ||
| 5705 | |||
| 5706 | if (lo_result >= 0) { | ||
| 5707 | cpu->Cpsr |= (1 << 16); | ||
| 5708 | cpu->Cpsr |= (1 << 17); | ||
| 5709 | } else { | ||
| 5710 | cpu->Cpsr &= ~(1 << 16); | ||
| 5711 | cpu->Cpsr &= ~(1 << 17); | ||
| 5712 | } | ||
| 5713 | |||
| 5714 | if (hi_result >= 0) { | ||
| 5715 | cpu->Cpsr |= (1 << 18); | ||
| 5716 | cpu->Cpsr |= (1 << 19); | ||
| 5717 | } else { | ||
| 5718 | cpu->Cpsr &= ~(1 << 18); | ||
| 5719 | cpu->Cpsr &= ~(1 << 19); | ||
| 5720 | } | ||
| 5721 | } | ||
| 5722 | |||
| 5723 | cpu->Reg[15] += GET_INST_SIZE(cpu); | ||
| 5724 | INC_PC(sizeof(generic_arm_inst)); | ||
| 5725 | FETCH_INST; | ||
| 5726 | GOTO_NEXT_INST; | ||
| 5727 | } | ||
| 5728 | |||
| 5632 | SBC_INST: | 5729 | SBC_INST: |
| 5633 | { | 5730 | { |
| 5634 | INC_ICOUNTER; | 5731 | INC_ICOUNTER; |
| @@ -5851,9 +5948,7 @@ unsigned InterpreterMainLoop(ARMul_State* state) | |||
| 5851 | SRS_INST: | 5948 | SRS_INST: |
| 5852 | SSAT_INST: | 5949 | SSAT_INST: |
| 5853 | SSAT16_INST: | 5950 | SSAT16_INST: |
| 5854 | SSUB16_INST: | ||
| 5855 | SSUB8_INST: | 5951 | SSUB8_INST: |
| 5856 | SSUBADDX_INST: | ||
| 5857 | STC_INST: | 5952 | STC_INST: |
| 5858 | { | 5953 | { |
| 5859 | INC_ICOUNTER; | 5954 | INC_ICOUNTER; |