summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Oliver Stöneberg <firewave@users.noreply.github.com>2013-05-19 18:48:10 +0000
committer Oliver Stöneberg <firewave@users.noreply.github.com>2013-05-19 18:48:10 +0000
commitedd2d136a062a9fe06b0c7dd506e203e6bb80081 (patch)
treed4dfa70a7b6e0f5700d1d6ddd8d69f7eb656dfd5
parent46c6b98571ffd8a521ea4624f23a26b98ba35611 (diff)
unrolled modulo in {div|divu}_64x32_rem() and {mod|modu}_64x32() since it is apparently faster - this also gets rid of a duplicated div operation in {div|divu}_64x32_rem() / div*_64x32_rem() now call div*_64x32() (nw)
-rw-r--r--src/emu/eminline.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/emu/eminline.h b/src/emu/eminline.h
index 992a5039cf9..b6ae6fce342 100644
--- a/src/emu/eminline.h
+++ b/src/emu/eminline.h
@@ -155,8 +155,9 @@ INLINE UINT32 divu_64x32(UINT64 a, UINT32 b)
#ifndef div_64x32_rem
INLINE INT32 div_64x32_rem(INT64 a, INT32 b, INT32 *remainder)
{
- *remainder = a % (INT64)b;
- return a / (INT64)b;
+ INT32 res = div_64x32(a, b);
+ *remainder = a - ((INT64)b * res);
+ return res;
}
#endif
@@ -170,8 +171,9 @@ INLINE INT32 div_64x32_rem(INT64 a, INT32 b, INT32 *remainder)
#ifndef divu_64x32_rem
INLINE UINT32 divu_64x32_rem(UINT64 a, UINT32 b, UINT32 *remainder)
{
- *remainder = a % (UINT64)b;
- return a / (UINT64)b;
+ UINT32 res = divu_64x32(a, b);
+ *remainder = a - ((UINT64)b * res);
+ return res;
}
#endif
@@ -212,7 +214,7 @@ INLINE UINT32 divu_32x32_shift(UINT32 a, UINT32 b, UINT8 shift)
#ifndef mod_64x32
INLINE INT32 mod_64x32(INT64 a, INT32 b)
{
- return a % (INT64)b;
+ return a - (b * div_64x32(a, b));
}
#endif
@@ -225,7 +227,7 @@ INLINE INT32 mod_64x32(INT64 a, INT32 b)
#ifndef modu_64x32
INLINE UINT32 modu_64x32(UINT64 a, UINT32 b)
{
- return a % (UINT64)b;
+ return a - (b * divu_64x32(a, b));
}
#endif