The old MUL instruction is very slow on modern pentiums so if
you have to hard code a multiplication into an algorithm, there
is an alternative way using LEA which is much faster.
LEA is often a source of AGI stalls but even so, it is a lot
faster than MUL.
Regards,
[email protected]
------------------
you have to hard code a multiplication into an algorithm, there
is an alternative way using LEA which is much faster.
Code:
! mov eax, var ' ! lea eax, [eax+eax] ; x 2 ' ! lea eax, [eax*2+eax] ; x 3 ' ! lea eax, [eax*4] ; x 4 ' ! lea eax, [eax*4+eax] ; x 5 ' ! lea ecx, [eax*2] ' ! lea eax, [eax*4+ecx] ; x 6 ' ! lea ecx, [eax*2+eax] ' ! lea eax, [eax*4+ecx] ; x 7 ' ! lea eax, [eax*8] ; x 8 ' ! lea eax, [eax*8+eax] ; x 9 ' ! lea ecx, [eax*2] ' ! lea eax, [eax*8+ecx] ; x 10
faster than MUL.
Regards,
[email protected]
------------------
Comment