Logic ; FMUL source ; FMUL and FMULP ST ← ST * source ST(1) ← ST(1) * ST pop ST
; FMUL dest, source ; FMULP dest, ST ST(dest) ← ST(dest) * ST(src) ST(dest) ← ST(dest) * ST pop ST
FMUL/FMULP multiply the destination operand by the source operand and return the product to the destination.
The one-operand form of FMUL multiplies ST by a (single or double real) memory operand. The two-operand form of FMUL multiplies two register operands (one of these must be ST) and stores the result in the destination register. FMULP works like the two-operand FMUL but requires ST to be the source operand; it also pops the stack. The no-operand forms FMUL and FMULP equal 'FMULP ST(1), ST'.
Example ; C-callable integer power function ; by Nicholas Wilt, 1991 (DDJ 9203) ; ; double intpow(double x, unsigned int y); ; returns x**y
model small, C public intpow
proc intpow arg x:qword, y:word fld1 ; result = 1.0 mov cx, [y] fld [x] ; load x jcxz @@ret ; if exponent zero, result made @@1: test cx, 1 jz @@2 fmul st(1), st ; multiply result by x @@2: fmul st, st ; square x shr cx, 1 jnz @@1 @@ret: fstp st ; discard x ret ; return result in st(0) endp
Opcode Format D8 /1 FMUL m32 DC /1 FMUL m64 D8 C8 + i FMUL ST, ST(i) DC C8 + i FMUL ST(i), ST DE C8 + i FMULP ST(i), ST DE C9 FMUL DE C9 FMULP
Timing Variations/ operand 8087 287 387 486 Pentium fmul reg s 90-105 90-105 29-52 16 3/1 FX fmul reg 130-145 130-145 46-57 16 3/1 FX fmul m32 (110-125)+EA 110-125 27-35 11 3/1 FX fmul m64 (154-168)+EA 154-168 32-57 14 3/1 FX fmulp reg s 94-108 94-108 29-52 16 3/1 FX fmulp reg 134-148 134-148 29-57 16 3/1 FX