diff options
| author | 2011-09-04 20:45:05 +0000 | |
|---|---|---|
| committer | 2011-09-04 20:45:05 +0000 | |
| commit | 0e0607bfb27de77b2ed007427b82c95ef9a5771a (patch) | |
| tree | 867499e5dfb74ba8acbb62cedaf41b84cfa5129e /src | |
| parent | 2607e7310193757d8764319cb5847d1f42dc42d8 (diff) | |
OP_MPY: fix N flag on 32bit (int -> UINT32)
OP_DIV: V flag when overflow, and software interrupt when divide by zero (see official manual for details)
OP_BRK: forgot CLK
OP_COP is junk/leftover?
Diffstat (limited to 'src')
| -rw-r--r-- | src/emu/cpu/m37710/m37710op.h | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/src/emu/cpu/m37710/m37710op.h b/src/emu/cpu/m37710/m37710op.h index e6d9c269155..964ea82c46a 100644 --- a/src/emu/cpu/m37710/m37710op.h +++ b/src/emu/cpu/m37710/m37710op.h @@ -647,34 +647,44 @@ INLINE uint EA_SIY(m37710i_cpu_struct *cpustate) {return MAKE_UINT_16(read_16_ #define OP_MPY(MODE) \ CLK(CLK_OP + CLK_R8 + CLK_##MODE); \ SRC = OPER_8_##MODE(cpustate); \ - { int temp = SRC * REG_A; REG_A = temp & 0xff; REG_BA = (temp>>8)&0xff; FLAG_Z = temp; FLAG_N = (temp & 0x8000) ? 1 : 0; FLAG_C = 0; } + { UINT16 temp = SRC * (REG_A&0xff); REG_A = temp & 0xff; REG_BA = (temp>>8)&0xff; FLAG_Z = temp; FLAG_N = (temp & 0x8000) ? 1 : 0; FLAG_C = 0; } #else #define OP_MPY(MODE) \ CLK(CLK_OP + CLK_R16 + CLK_##MODE); \ SRC = OPER_16_##MODE(cpustate); \ - { int temp = SRC * REG_A; REG_A = temp & 0xffff; REG_BA = (temp>>16)&0xffff; FLAG_Z = temp; FLAG_N = (temp & 0x80000000) ? 1 : 0; FLAG_C = 0; } + { UINT32 temp = SRC * REG_A; REG_A = temp & 0xffff; REG_BA = (temp>>16)&0xffff; FLAG_Z = temp; FLAG_N = (temp & 0x80000000) ? 1 : 0; FLAG_C = 0; } #endif /* M37710 Divide */ #undef OP_DIV #if FLAG_SET_M #define OP_DIV(MODE) \ - CLK(CLK_OP + CLK_R8 + CLK_##MODE + 25); \ + CLK(CLK_OP + CLK_R8 + CLK_##MODE + 17); \ SRC = (REG_BA&0xff)<<8 | (REG_A & 0xff); \ DST = OPER_8_##MODE(cpustate); \ - if (DST != 0) { REG_A = SRC / DST; REG_BA = SRC % DST; SRC /= DST; } \ - FLAG_N = (SRC & 0x80) ? 1 : 0; \ - FLAG_Z = MAKE_UINT_8(SRC); \ - if (DST != 0) { FLAG_V = 0; FLAG_C = 0; } + if (DST != 0) \ + { \ + UINT16 tempa = SRC / DST; UINT16 tempb = SRC % DST; \ + FLAG_V = ((tempa | tempb) & 0xff00) ? VFLAG_SET : 0; \ + FLAG_C = FLAG_V ? CFLAG_SET : 0; \ + if (!FLAG_V) { FLAG_N = (tempa & 0x80) ? 1 : 0; } \ + FLAG_Z = REG_A = tempa & 0xff; REG_BA = tempb & 0xff; \ + CLK(8); \ + } else m37710i_interrupt_software(cpustate, 0xfffc) #else #define OP_DIV(MODE) \ - CLK(CLK_OP + CLK_R16 + CLK_##MODE + 25); \ + CLK(CLK_OP + CLK_R16 + CLK_##MODE + 17); \ SRC = (REG_BA<<16) | REG_A; \ DST = OPER_16_##MODE(cpustate); \ - if (DST != 0) { REG_A = SRC / DST; REG_BA = SRC % DST; SRC /= DST; } \ - FLAG_N = (SRC & 0x8000) ? 1 : 0; \ - FLAG_Z = SRC; \ - if (DST != 0) { FLAG_V = 0; FLAG_C = 0; } + if (DST != 0) \ + { \ + UINT32 tempa = SRC / DST; UINT32 tempb = SRC % DST; \ + FLAG_V = ((tempa | tempb) & 0xffff0000) ? VFLAG_SET : 0; \ + FLAG_C = FLAG_V ? CFLAG_SET : 0; \ + if (!FLAG_V) { FLAG_N = (tempa & 0x8000) ? 1 : 0; } \ + FLAG_Z = REG_A = tempa & 0xffff; REG_BA = tempb & 0xffff; \ + CLK(8+15); \ + } else m37710i_interrupt_software(cpustate, 0xfffc) #endif /* M37710 Add With Carry */ @@ -893,8 +903,8 @@ INLINE uint EA_SIY(m37710i_cpu_struct *cpustate) {return MAKE_UINT_16(read_16_ /* M37710 Cause a Break interrupt */ #undef OP_BRK #define OP_BRK() \ - REG_PC++; \ - logerror("fatalerror M37710: BRK at PC=%06x", REG_PB|REG_PC); \ + REG_PC++; CLK(CLK_OP + CLK_R8 + CLK_IMM + 5); \ + logerror("fatalerror M37710: BRK at PC=%06x", REG_PB|REG_PC); \ m37710i_interrupt_software(cpustate, 0xfffa) /* M37710 Branch Always */ @@ -987,12 +997,6 @@ INLINE uint EA_SIY(m37710i_cpu_struct *cpustate) {return MAKE_UINT_16(read_16_ FLAG_C = ~CFLAG_16(FLAG_C) #endif -/* M37710 Coprocessor operation */ -#undef OP_COP -#define OP_COP() \ - REG_PC++; \ - m37710i_interrupt_software(cpustate, VECTOR_COP) - /* M37710 Decrement accumulator */ #undef OP_DEC #if FLAG_SET_M |
