Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- iAPx86 - <b>fyl2x compute y * log2(x) exceptions: p</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
FYL2X           Compute Y * log2(x)                  Exceptions: P
                                                     (operands not checked)
FYL2X                                                C3 C2 C1 C0: ? ? * ?

        Logic   ST(1) . ST(1) * Log2(ST)
                pop ST

    FYL2X computes the base-2 logarithm of ST, multiplies the logarithm
    by ST(1), and puts the result in ST(1). Then it pops the stack. The
    operand in ST cannot be negative.


    Note
    If the operand in ST is negative, the invalid-operation exception is
    raised. The 80486+ checks for interrupts while executing this
    instruction. It will abort FYL2X to service interrupts.

    If the operand is very close to 1, use FYL2XP1 instead of FYL2XP.


    Example
    Many math applications require natural logarithms (log base e) or
    common logarithms (log base 10). These are easy to calculate by
    using the following equation to change the base of a logarithm to a
    new base n:
                log(n)X = log(n)2 * log(2)X

    In this case, n is e or 10. The following programs assume that X is
    on the top of the stack; they replace X with its natural logarithm.
    The program that produces natural logs is:

                fldln2  ; push log base e of 2
                fxch    ; swap ST and ST(1)
                fyl2x   ; pop ST, replace it with natual log

    The program that produces common logs is:

                fldlg2  ; push log base e of 10
                fxch    ; swap ST and ST(1)
                fyl2x   ; pop ST, replace it with common log
    

    Opcode      Format
    D9 F1       FYL2X


    Timing
    Variations    8087         287        387      486     Pentium
    fyl2x       900-1100     900-1100   120-538  196-329   22-111  NP

See Also: FYL2XP1 CC

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson