fscale

Scale

FSCALE

Scales ST(0) by ST(1) (ST(0) * 2^ST(1)).

Details

Scales ST(0) by raising 2 to the power of ST(1): ST(0) ← ST(0) × 2^ST(1). ST(1) must be an integer within the range [−2^31, 2^31−1]; if out of range or NaN, an invalid-operation exception is generated. The stack is not popped; ST(0) is replaced with the scaled result.

Pseudocode Operation

if (ST(1) is not integer or out_of_range) {
  raise_exception(invalid_operation)
} else {
  ST(0) ← ST(0) * (2 ^ trunc(ST(1)))
}

Example

FSCALE

Encoding

Binary Layout
D9
+0
FD
+1
 
Format Legacy
Opcode D9 FD
Extension x87 FPU

Operands

Reference (Intel® SDM)

Instruction Forms

Opcode Instruction Op/En 64/32-bit Mode CPUID Description
D9 FD FSCALE Valid Valid Scale ST(0) by ST(1).

Description

Truncates the value in the source operand (toward 0) to an integral value and adds that value to the exponent of the destination operand. The destination and source operands are floating-point values located in registers ST(0) and ST(1), respectively. This instruction provides rapid multiplication or division by integral powers of 2. The following table shows the results obtained when scaling various classes of numbers, assuming that neither overflow nor underflow occurs. Table 3-36. FSCALE Results ST(1) − ∞ − F − 0 + 0 + F + ∞ NaN − ∞ NaN − ∞ − ∞ − ∞ − ∞ − ∞ NaN ST(0) − F − 0 − F − F − F − F − ∞ NaN − 0 − 0 − 0 − 0 − 0 − 0 NaN NaN + 0 + 0 + 0 + 0 + 0 + 0 NaN NaN + F + 0 + F + F + F + F + ∞ NaN + ∞ NaN + ∞ + ∞ + ∞ + ∞ + ∞ NaN NaN NaN NaN NaN NaN NaN NaN NaN

Operation

ST(0) := ST(0) ∗ 2RoundTowardZero(ST(1));

Exceptions

Protected Mode Exceptions

#NM CR0.EM[bit 2] or CR0.TS[bit 3] = 1. #MF If there is a pending x87 FPU exception. #UD If the LOCK prefix is used.

Real-Address Mode Exceptions

Same exceptions as in protected mode.

Virtual-8086 Mode Exceptions

Same exceptions as in protected mode.

Compatibility Mode Exceptions

Same exceptions as in protected mode.

64-Bit Mode Exceptions

Same exceptions as in protected mode. FSCALE—Scale Vol. 2A 3-379