please dont rip this site
 IMUL  Rb      {Rb/Ms} B/w  011010s1 MdRegR/m {disp}   {disp}	data	 {data}



For constants, use the following 32bit MASM code:

mMulC MACRO pDest, pSrc, pConst
IF pConst EQ 2
	FIDNI pDest, pSrc
	shl pDest, 1
	ELSE
	lea pDest, [pSrc*2]
		ENDIF
ELSEIF pConst EQ 3
	lea pDest, [pSrc*2+pSrc]
ELSEIF pConst EQ 4
	;SHL pDest, 2 ;lea is faster
	lea pDest, [pSrc*4]
ELSEIF pConst EQ 5
	lea pDest, [pSrc*4+pSrc]
ELSEIF pConst EQ 6
	lea pDest, [pSrc*2+pSrc]	;Src x3
	shl pDest, 1			;(Src X3) x2
ELSEIF pConst EQ 7
	IFIDNI pDest, pSrc
	;if I can't get back to pSrc after
	;overwriteing pDest (i.e. pDest is pSrc
	imul pdest, pSrc, pConst
	ELSE
	;Thanks Tim Roberts, timr@probo.com
	lea pDest, [pSrc*8]
	sub pDest, pSrc
		ENDIF
ELSEIF pConst EQ 8
	lea pDest, [pSrc*8]
ELSEIF pConst EQ 9
	lea pDest, [pSrc*8+pSrc]
ELSEIF pConst EQ 10
	lea pDest, [pSrc*4+pSrc]	;Src x5
	shl pDest, 1			;(Src X5) x2
ELSEIF pConst EQ 11
	IFIDNI pDest, pSrc
	imul pdest, pSrc, pConst
	ELSE
	lea pDest, [pSrc*4+pSrc]	;Src x5
	shl pDest, 1			;(Src X5) x2
	add pDest, pSrc			;((Src x5) x2) + Src
		ENDIF
ELSEIF pConst EQ 12
	lea pDest, [pSrc*2+pSrc]	;Src x3
	lea pDest, [pDest*4]		;(Src x3) x4
ELSEIF pConst EQ 13
	IFIDNI pDest, pSrc
	imul pdest, pSrc, pConst
	ELSE
	;Thanks Tim Roberts, timr@probo.com
	lea pDest, [pSrc*4+pSrc] ; src x 5
	lea pDest, [pSrc*8+pDest] ; src x 13
		ENDIF
ELSEIF pConst EQ 15
	lea pDest, [pSrc*4+pSrc]	;Src x5
	lea pDest, [pDest*2+pDest]	;(Src x5) x3
ELSEIF pConst EQ 16
	IFIDNI pDest, pSrc
	shl pDest, 2
	ELSE
	lea pDest, [pSrc*8]		;Src x8
	shl pDest, 1			;(Src X8) x2
		ENDIF
ELSEIF pConst EQ 17
	IFIDNI pDest, pSrc
	imul pdest, pSrc, pConst
	ELSE
	;Thanks Tim Roberts, timr@probo.com
	lea pDest, [pSrc*8]
	lea pDest, [pDest*2+pSrc]
		ENDIF
ELSEIF pConst EQ 18
	lea pDest, [pSrc*8+pSrc]
	shl pDest, 1			;(Src X9) x2
ELSEIF pConst EQ 19
	IFIDNI pDest, pSrc
	imul pdest, pSrc, pConst
	ELSE
	lea pDest, [pSrc*8]		;Src x8
	shl pDest, 1			;(Src X8) x2
	add pDest, pSrc			;((Src x8) x2) + Src
		ENDIF
ELSEIF pConst EQ 20
	lea pDest, [pSrc*4+pSrc]	;Src x5
	lea pDest, [pDest*4]		;(Src x5) x4
ELSEIF pConst EQ 24
	lea pDest, [pSrc*2+pSrc]	;Src x3
	lea pDest, [pDest*8]		;(Src x3) x8
ELSEIF pConst EQ 25
	lea pDest, [pSrc*4+pSrc]	;Src x5
	lea pDest, [pDest*4+pDest];(Src x5) x5
ELSEIF pConst EQ 30
	lea pDest, [pSrc*4+pSrc]	;Src x5
	shl pDest, 1			;(Src X5) x2
	lea pDest, [pDest*2+pDest]	;((Src x5) x2) x3
ELSE
	imul pdest, pSrc, pConst
	ENDIF
	ENDM

Note: On the Pentium II's imul may actually be as fast or faster! This macro is good for older chips.


file: /Techref/intel/x86/inst/imul.htm, 2KB, , updated: 2000/1/24 08:49, local time: 2024/12/27 08:16,
TOP NEW HELP FIND: 
18.225.54.147:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://ecomorder.com/Techref/intel/x86/inst/imul.htm"> intel x86 inst imul</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to ecomorder.com!

 

Welcome to ecomorder.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .