all repos — mgba @ f6592b17b88b749b86101c60ca0034f5a5f4d3f6

mGBA Game Boy Advance Emulator

Implement MUL timings
Jeffrey Pfau jeffrey@endrift.com
Sat, 11 May 2013 14:35:10 -0700
commit

f6592b17b88b749b86101c60ca0034f5a5f4d3f6

parent

5c3175791228cde0f9228af5983f50f710087043

3 files changed, 13 insertions(+), 1 deletions(-)

jump to
M src/arm/isa-arm.csrc/arm/isa-arm.c

@@ -416,6 +416,7 @@ int rdHi = (opcode >> 16) & 0xF; \

int rs = (opcode >> 8) & 0xF; \ int rm = opcode & 0xF; \ UNUSED(rdHi); \ + ARM_WAIT_MUL(cpu->gprs[rs]); \ BODY; \ S_BODY; \ if (rd == ARM_PC) { \
M src/arm/isa-inlines.hsrc/arm/isa-inlines.h

@@ -52,6 +52,17 @@ #define ARM_BORROW_FROM(M, N, D) (((uint32_t) (M)) >= ((uint32_t) (N)))

#define ARM_V_ADDITION(M, N, D) (!(ARM_SIGN((M) ^ (N))) && (ARM_SIGN((M) ^ (D))) && (ARM_SIGN((N) ^ (D)))) #define ARM_V_SUBTRACTION(M, N, D) ((ARM_SIGN((M) ^ (N))) && (ARM_SIGN((M) ^ (D)))) +#define ARM_WAIT_MUL(R) \ + if ((R & 0xFFFFFF00) == 0xFFFFFF00 || !(R & 0xFFFFFF00)) { \ + cpu->cycles += 1; \ + } else if ((R & 0xFFFF0000) == 0xFFFF0000 || !(R & 0xFFFF0000)) { \ + cpu->cycles += 2; \ + } else if ((R & 0xFF000000) == 0xFF000000 || !(R & 0xFF000000)) { \ + cpu->cycles += 3; \ + } else { \ + cpu->cycles += 4; \ + } + #define ARM_STUB cpu->board->hitStub(cpu->board, opcode) #define ARM_WRITE_PC \
M src/arm/isa-thumb.csrc/arm/isa-thumb.c

@@ -275,7 +275,7 @@ DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(NEG, THUMB_SUBTRACTION(cpu->gprs[rd], 0, cpu->gprs[rn]))

DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(CMP2, int32_t aluOut = cpu->gprs[rd] - cpu->gprs[rn]; THUMB_SUBTRACTION_S(cpu->gprs[rd], cpu->gprs[rn], aluOut)) DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(CMN, int32_t aluOut = cpu->gprs[rd] + cpu->gprs[rn]; THUMB_ADDITION_S(cpu->gprs[rd], cpu->gprs[rn], aluOut)) DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(ORR, cpu->gprs[rd] = cpu->gprs[rd] | cpu->gprs[rn]; THUMB_NEUTRAL_S( , , cpu->gprs[rd])) -DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(MUL, cpu->gprs[rd] *= cpu->gprs[rn]; THUMB_NEUTRAL_S( , , cpu->gprs[rd])) +DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(MUL, ARM_WAIT_MUL(cpu->gprs[rn]); cpu->gprs[rd] *= cpu->gprs[rn]; THUMB_NEUTRAL_S( , , cpu->gprs[rd])) DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(BIC, cpu->gprs[rd] = cpu->gprs[rd] & ~cpu->gprs[rn]; THUMB_NEUTRAL_S( , , cpu->gprs[rd])) DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(MVN, cpu->gprs[rd] = ~cpu->gprs[rn]; THUMB_NEUTRAL_S( , , cpu->gprs[rd]))