diff options
| author | 2015-02-17 23:54:01 -0500 | |
|---|---|---|
| committer | 2015-02-17 23:54:01 -0500 | |
| commit | 60f9cd6a4a67c3232ae2e0a7fe1c8cdd74e67feb (patch) | |
| tree | 15e66ce5d3f36fbfffa111536ace16d2b16bf6e2 | |
| parent | Merge pull request #578 from linkmauve/math-typo (diff) | |
| parent | dyncom: Support conditional BKPT instructions (diff) | |
| download | yuzu-60f9cd6a4a67c3232ae2e0a7fe1c8cdd74e67feb.tar.gz yuzu-60f9cd6a4a67c3232ae2e0a7fe1c8cdd74e67feb.tar.xz yuzu-60f9cd6a4a67c3232ae2e0a7fe1c8cdd74e67feb.zip | |
Merge pull request #579 from lioncash/bkpt
dyncom: Support conditional BKPT instructions
| -rw-r--r-- | src/core/arm/dyncom/arm_dyncom_dec.cpp | 2 | ||||
| -rw-r--r-- | src/core/arm/dyncom/arm_dyncom_interpreter.cpp | 28 |
2 files changed, 28 insertions, 2 deletions
diff --git a/src/core/arm/dyncom/arm_dyncom_dec.cpp b/src/core/arm/dyncom/arm_dyncom_dec.cpp index ffa627352..9f3b90fd0 100644 --- a/src/core/arm/dyncom/arm_dyncom_dec.cpp +++ b/src/core/arm/dyncom/arm_dyncom_dec.cpp | |||
| @@ -42,7 +42,7 @@ const ISEITEM arm_instruction[] = { | |||
| 42 | 42 | ||
| 43 | { "srs", 4, 6, 25, 31, 0x0000007c, 22, 22, 0x00000001, 16, 20, 0x0000000d, 8, 11, 0x00000005 }, | 43 | { "srs", 4, 6, 25, 31, 0x0000007c, 22, 22, 0x00000001, 16, 20, 0x0000000d, 8, 11, 0x00000005 }, |
| 44 | { "rfe", 4, 6, 25, 31, 0x0000007c, 22, 22, 0x00000000, 20, 20, 0x00000001, 8, 11, 0x0000000a }, | 44 | { "rfe", 4, 6, 25, 31, 0x0000007c, 22, 22, 0x00000000, 20, 20, 0x00000001, 8, 11, 0x0000000a }, |
| 45 | { "bkpt", 2, 3, 20, 31, 0x00000e12, 4, 7, 0x00000007 }, | 45 | { "bkpt", 2, 3, 20, 27, 0x00000012, 4, 7, 0x00000007 }, |
| 46 | { "blx", 1, 3, 25, 31, 0x0000007d }, | 46 | { "blx", 1, 3, 25, 31, 0x0000007d }, |
| 47 | { "cps", 3, 6, 20, 31, 0x00000f10, 16, 16, 0x00000000, 5, 5, 0x00000000 }, | 47 | { "cps", 3, 6, 20, 31, 0x00000f10, 16, 16, 0x00000000, 5, 5, 0x00000000 }, |
| 48 | { "pld", 4, 4, 26, 31, 0x0000003d, 24, 24, 0x00000001, 20, 22, 0x00000005, 12, 15, 0x0000000f }, | 48 | { "pld", 4, 4, 26, 31, 0x0000003d, 24, 24, 0x00000001, 20, 22, 0x00000005, 12, 15, 0x0000000f }, |
diff --git a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp index a8b3c1276..b691ffbc3 100644 --- a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp +++ b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp | |||
| @@ -792,6 +792,7 @@ typedef struct _stm_inst { | |||
| 792 | } stm_inst; | 792 | } stm_inst; |
| 793 | 793 | ||
| 794 | struct bkpt_inst { | 794 | struct bkpt_inst { |
| 795 | u32 imm; | ||
| 795 | }; | 796 | }; |
| 796 | 797 | ||
| 797 | struct blx1_inst { | 798 | struct blx1_inst { |
| @@ -1371,7 +1372,22 @@ static ARM_INST_PTR INTERPRETER_TRANSLATE(bic)(unsigned int inst, int index) | |||
| 1371 | inst_base->br = INDIRECT_BRANCH; | 1372 | inst_base->br = INDIRECT_BRANCH; |
| 1372 | return inst_base; | 1373 | return inst_base; |
| 1373 | } | 1374 | } |
| 1374 | static ARM_INST_PTR INTERPRETER_TRANSLATE(bkpt)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("BKPT"); } | 1375 | |
| 1376 | static ARM_INST_PTR INTERPRETER_TRANSLATE(bkpt)(unsigned int inst, int index) | ||
| 1377 | { | ||
| 1378 | arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(bkpt_inst)); | ||
| 1379 | bkpt_inst* const inst_cream = (bkpt_inst*)inst_base->component; | ||
| 1380 | |||
| 1381 | inst_base->cond = BITS(inst, 28, 31); | ||
| 1382 | inst_base->idx = index; | ||
| 1383 | inst_base->br = NON_BRANCH; | ||
| 1384 | inst_base->load_r15 = 0; | ||
| 1385 | |||
| 1386 | inst_cream->imm = BITS(inst, 8, 19) | BITS(inst, 0, 3); | ||
| 1387 | |||
| 1388 | return inst_base; | ||
| 1389 | } | ||
| 1390 | |||
| 1375 | static ARM_INST_PTR INTERPRETER_TRANSLATE(blx)(unsigned int inst, int index) | 1391 | static ARM_INST_PTR INTERPRETER_TRANSLATE(blx)(unsigned int inst, int index) |
| 1376 | { | 1392 | { |
| 1377 | arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(blx_inst)); | 1393 | arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(blx_inst)); |
| @@ -4081,6 +4097,16 @@ unsigned InterpreterMainLoop(ARMul_State* state) { | |||
| 4081 | GOTO_NEXT_INST; | 4097 | GOTO_NEXT_INST; |
| 4082 | } | 4098 | } |
| 4083 | BKPT_INST: | 4099 | BKPT_INST: |
| 4100 | { | ||
| 4101 | if (inst_base->cond == 0xE || CondPassed(cpu, inst_base->cond)) { | ||
| 4102 | bkpt_inst* const inst_cream = (bkpt_inst*)inst_base->component; | ||
| 4103 | LOG_DEBUG(Core_ARM11, "Breakpoint instruction hit. Immediate: 0x%08X", inst_cream->imm); | ||
| 4104 | } | ||
| 4105 | cpu->Reg[15] += GET_INST_SIZE(cpu); | ||
| 4106 | INC_PC(sizeof(bkpt_inst)); | ||
| 4107 | FETCH_INST; | ||
| 4108 | GOTO_NEXT_INST; | ||
| 4109 | } | ||
| 4084 | BLX_INST: | 4110 | BLX_INST: |
| 4085 | { | 4111 | { |
| 4086 | blx_inst *inst_cream = (blx_inst *)inst_base->component; | 4112 | blx_inst *inst_cream = (blx_inst *)inst_base->component; |