x86 Instruction Set Reference

FYL2XP1

Compute y * log_2(x + 1)

Opcode Mnemonic Description
D9 F9 FYL2XP1 Replace ST(1) with ST(1) * log_2(ST(0) + 1.0) and pop the register stack.
Description

Computes (ST(1) * log_2(ST(0) + 1.0)), stores the result in register ST(1), and pops the FPU register stack. The source operand in ST(0) must be in the range:

sqrt(2) / 2 - 1 to 1 + sqrt(2) / 2

The source operand in ST(1) can range from -infinite to +infinite. If the ST(0) operand is outside of its acceptable range, the result is undefined and software should not rely on an exception being generated. Under some circumstances exceptions may be generated when ST(0) is out of range, but this behavior is implementation specific and not guaranteed.

The following table shows the results obtained when taking the log epsilon of various classes of numbers, assuming that underflow does not occur.

FYL2XP1 Results
-ST(0): -(1 - sqrt(2) / 2) to -0-0ST(0): +0ST(0): +0 to +(1 - sqrt(2) / 2)ST(0): Nan
ST(1): -inf+inf**-infNaN
ST(1): -F+F+0-0-FNaN
ST(1): -0+0+0-0-0NaN
ST(1): +0-0-0+0+0NaN
ST(1): +F-F-0+0+FNaN
ST(1): +inf-inf**+infNaN
ST(1): NaNNaNNaNNaNNaNNaN
F Means finite floating-point value.
* Indicates floating-point invalid-operation (#IA) exception.

This instruction provides optimal accuracy for values of epsilon [the value in register ST(0)] that are close to 0. For small epsilon (?) values, more significant digits can be retained by using the FYL2XP1 instruction than by using (?+1) as an argument to the FYL2X instruction. The (?+1) expression is commonly found in compound interest and annuity calculations. The result can be simply converted into a value in another logarithm base by including a scale factor in the ST(1) source operand. The following equation is used to calculate the scale factor for a particular logarithm base, where n is the logarithm base desired for the result of the FYL2XP1 instruction:

scale factor = log_n(2)

Operation
ST(1) = ST(1) * log_2(ST(0) + 1.0);
PopRegisterStack();
[/code]
FPU flags affected

C1 Set to 0 if stack underflow occurred. Set if result was rounded up; cleared otherwise. C0, C2, C3 Undefined.

Floating-Point Exceptions
#ISStack underflow occurred.
#ISStack underflow occurred.
#IAEither operand is an SNaN value or unsupported format.
#DSource operand is a denormal value.
#UResult is too small for destination format.
#OResult is too large for destination format.
Protected Mode Exceptions
#NMEM or TS in CR0 is set.
Real-Address Mode Exceptions
#NMEM or TS in CR0 is set.
Virtual-8086 Mode Exceptions
#NMEM or TS in CR0 is set.
Instruction Latency Throughput Execution Unit
CPUID0F3n/0F2n0F3n/0F2n0F2n
FYL2XP1 140-19085-