News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

mul vs imul

Started by bushpilot, May 17, 2006, 09:56:31 PM

Previous topic - Next topic

bushpilot

Hi Everyone,

Dumb question - do the "tricks" on Paul Hsieh's web site "Integer multiplying by constants" http://www.azillionmonkeys.com/qed/amultl2.html work with imul or just mul?

Greg

Tedd

They're tricks for multiplying by a constant - instead of using multiplies.
But they're unsigned, so they're substitutes mul. imul requires copying the sign-bit, which none those appear to do.
No snowflake in an avalanche feels responsible.

hutch--

Greg,

It has got a bit more complicated than it used to be. On later hardware LEA is slow and bit shifts are slow as well but for multiplying by a constant it is still probably faster than using MUL or IMUL. Now Tedd has mentioned an obvious thing which you must consider as well and you may just be able to use NEG and/or ADD to fix it.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php