diff --git a/m68k_in.c b/m68k_in.c index e5811b3..cfbacf4 100644 --- a/m68k_in.c +++ b/m68k_in.c @@ -215,6 +215,7 @@ void m68ki_build_opcode_table(void) m68ki_instruction_jump_table[instr] = ostruct->opcode_handler; for(k=0;kcycles[k]; +/* SBF: don't add it here or the costs are added twice! // For all shift operations with known shift distance (encoded in instruction word) if((instr & 0xf000) == 0xe000 && (!(instr & 0x20))) { @@ -226,6 +227,7 @@ void m68ki_build_opcode_table(void) // On the 68020 shift distance does not affect execution time m68ki_cycles[2][instr] += 0; } +*/ } } ostruct++; @@ -719,10 +721,10 @@ moves 8 . . 0000111000...... A+-DXWL... . S S S S . 14 5 moves 16 . . 0000111001...... A+-DXWL... . S S S S . 14 5 5 5 moves 32 . . 0000111010...... A+-DXWL... . S S S S . 16 5 5 5 move16 32 . . 1111011000100... .......... . . . . U . . . . 4 TODO: correct timing -muls 16 . d 1100...111000... .......... U U U U U 54 32 27 27 27 -muls 16 . . 1100...111...... A+-DXWLdxI U U U U U 54 32 27 27 27 -mulu 16 . d 1100...011000... .......... U U U U U 54 30 27 27 27 -mulu 16 . . 1100...011...... A+-DXWLdxI U U U U U 54 30 27 27 27 +muls 16 . d 1100...111000... .......... U U U U U 38 32 27 27 27 +muls 16 . . 1100...111...... A+-DXWLdxI U U U U U 38 32 27 27 27 +mulu 16 . d 1100...011000... .......... U U U U U 38 30 27 27 27 +mulu 16 . . 1100...011...... A+-DXWLdxI U U U U U 38 30 27 27 27 mull 32 . d 0100110000000... .......... . . U U U . . 43 43 43 mull 32 . . 0100110000...... A+-DXWLdxI . . U U U . . 43 43 43 nbcd 8 . d 0100100000000... .......... U U U U U 6 6 6 6 6 @@ -1866,7 +1868,7 @@ M68KMAKE_OP(asr, 8, s, .) uint src = MASK_OUT_ABOVE_8(*r_dst); uint res = src >> shift; - if(shift != 0) + if(shift != 0 && CPU_TYPE_IS_010_LESS(CPU_TYPE)) USE_CYCLES(shift<> shift; - if(shift != 0) + if(shift != 0 && CPU_TYPE_IS_010_LESS(CPU_TYPE)) USE_CYCLES(shift<> shift; - if(shift != 0) + if(shift != 0 && CPU_TYPE_IS_010_LESS(CPU_TYPE)) USE_CYCLES(shift<> shift; - if(shift != 0) + if(shift != 0 ) { - USE_CYCLES(shift<> shift; - if(shift != 0) + if(shift != 0 && CPU_TYPE_IS_010_LESS(CPU_TYPE)) USE_CYCLES(shift<> shift; - if(shift != 0) + if(shift != 0 && CPU_TYPE_IS_010_LESS(CPU_TYPE)) USE_CYCLES(shift<> shift; - if(shift != 0) + if(shift != 0 && CPU_TYPE_IS_010_LESS(CPU_TYPE)) USE_CYCLES(shift<>=1) { + if ((y&1) != f) { + c += 2; + f = 1 - f; + } + } + USE_CYCLES(c); + } + + uint res = MASK_OUT_ABOVE_32(x * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); *r_dst = res; @@ -7454,7 +7480,18 @@ M68KMAKE_OP(muls, 16, ., d) M68KMAKE_OP(muls, 16, ., .) { uint* r_dst = &DX; - uint res = MASK_OUT_ABOVE_32(MAKE_INT_16(M68KMAKE_GET_OPER_AY_16) * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); + uint x = MAKE_INT_16(M68KMAKE_GET_OPER_AY_16); + if(CPU_TYPE_IS_010_LESS(CPU_TYPE)) { + uint c = 0; + for (uint y = x, f = 0; y; y>>=1) { + if ((y&1) != f) { + c += 2; + f = 1 - f; + } + } + USE_CYCLES(c); + } + uint res = MASK_OUT_ABOVE_32(x * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); *r_dst = res; @@ -7468,7 +7505,17 @@ M68KMAKE_OP(muls, 16, ., .) M68KMAKE_OP(mulu, 16, ., d) { uint* r_dst = &DX; - uint res = MASK_OUT_ABOVE_16(DY) * MASK_OUT_ABOVE_16(*r_dst); + uint x = MASK_OUT_ABOVE_16(DY); + if(CPU_TYPE_IS_010_LESS(CPU_TYPE)) { + uint c = 0; + for (uint y = x; y; y>>=1) { + if ((y&1)) { + c += 2; + } + } + USE_CYCLES(c); + } + uint res = x * MASK_OUT_ABOVE_16(*r_dst); *r_dst = res; @@ -7482,7 +7529,18 @@ M68KMAKE_OP(mulu, 16, ., d) M68KMAKE_OP(mulu, 16, ., .) { uint* r_dst = &DX; - uint res = M68KMAKE_GET_OPER_AY_16 * MASK_OUT_ABOVE_16(*r_dst); + uint x = M68KMAKE_GET_OPER_AY_16; + if(CPU_TYPE_IS_010_LESS(CPU_TYPE)) { + uint c = 0; + for (uint y = x; y; y>>=1) { + if ((y&1)) { + c += 2; + } + } + USE_CYCLES(c); + } + + uint res = x * MASK_OUT_ABOVE_16(*r_dst); *r_dst = res;