* One if may be removed by using the boolean result of the comparison
directly
* I didn't test the result of the multiply for zero to decide if to check
x and y for zero (this would drop the need of one comparison in most cases)
because a) another variable would be needed and it may not fit into a
register (especially on x86) b) with DOS compilers (16 bit) no advantage
will be achieved as comparing a 32 bit int won't be faster than comparing
two 16 bit ints ....
(This version should be fast on x86 - especially on those without a good cache)
#define MUL(x,y) (t32 = (word16)(y),\
t32 = (uint16)t32 ? (word16)x ? t32*(word16)x :\
t32 << 16 : (word32)(word16)x << 16,\
x = (word16)t32 - (word16)(t32 >> 16) +\
((word16)t32 <= (word16)(t32 >> 16)))
Daniel (please test this code and report bugs and speed relations
on different systems with different compilers)
Geek Code 1.0.1:
GCS/MU d--@ p---@ c++ l@ u++(+) e@ m* s++/ !n@ h--(*) f? !g w+++ t+++ r@ y*
PGP key available (ask your keyserver or mail me)
## CrossPoint v3.02 ##