[68k] improved MULU/MULS instructions timing accuracy

This commit is contained in:
ekeeke31 2010-08-07 14:22:36 +00:00
parent c7e2dad7b4
commit efc7c3000a

View File

@ -169,12 +169,10 @@ INLINE unsigned getDivs68kCycles( LONG dividend, SHORT divisor)
INLINE unsigned getMulu68kCycles( WORD source) INLINE unsigned getMulu68kCycles( WORD source)
{ {
int i;
unsigned mcycles = 266; unsigned mcycles = 266;
/* count number of bits set to 1 */ /* count number of bits set to 1 */
for( i = 0; i < 15; i++) while (source)
{ {
if (source & 1) if (source & 1)
{ {
@ -194,22 +192,20 @@ INLINE unsigned getMulu68kCycles( WORD source)
INLINE unsigned getMuls68kCycles( SHORT source) INLINE unsigned getMuls68kCycles( SHORT source)
{ {
int i;
unsigned mcycles = 266; unsigned mcycles = 266;
/* detect 01 or 10 patterns */ /* detect 01 or 10 patterns */
LONG temp = source << 1; LONG temp = source << 1;
temp ^= source; temp = (temp ^ source) & 0xFFFF;
/* count number of bits set to 1 */ /* count number of bits set to 1 */
for( i = 0; i < 15; i++) while (temp)
{ {
if (source & 1) if (temp & 1)
{ {
mcycles += 14; mcycles += 14;
} }
source >>= 1; temp >>= 1;
} }
/* 38 + 2*N */ /* 38 + 2*N */