mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2024-12-30 21:21:49 +01:00
[68k] improved MULU/MULS instructions timing accuracy
This commit is contained in:
parent
c7e2dad7b4
commit
efc7c3000a
@ -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 */
|
||||||
|
Loading…
Reference in New Issue
Block a user