Results 1 to 7 of 7

Thread: Set8087CW... Huh? :shock:

  1. #1

    Set8087CW... Huh? :shock:

    Code:
    { Save the current FPU state and then disable FPU exceptions }
      Saved8087CW := Default8087CW;
      Set8087CW($133f); { Disable all fpu exceptions }
    I have seen this line in a few 3D Engines, both Delphi & C++, however I have no clue what it does exactly... It disables FPU exceptions and FPU seems to be some sort of instruction set for the i386, but since I'm quite an ASM n00b I have no clue what it does! ops:

    Can anyone explain it (generally) to me ? Thanks in advance!
    Do it by the book, but be the author!
    <br />
    <br />Visit the Lion Productions website at:
    <br />http://lionprod.f2o.org

  2. #2

    Set8087CW... Huh? :shock:

    Straight from Borland docs:
    Default8087CW is the value to which the Floating Point Unit (FPU) control register is set. The FPU control word includes bits that control the FPU's precision, rounding mode, and whether exceptions generate signals if they occur.
    So this:[pascal]Set8087CW($133f); { Disable all fpu exceptions }[/pascal]Disables all FP-coprocessor exceptions. By default in Delphi/C++Builder: InvalidOp, ZeroDivide, Overflow exceptions are enabled and RAISED in BAD CODE!!!
    There are only 10 types of people in this world; those who understand binary and those who don't.

  3. #3

    Set8087CW... Huh? :shock:

    Thanks!

    I read the help file on it, but could never quite figure out what errors it suppressed! Thanks again!
    Do it by the book, but be the author!
    <br />
    <br />Visit the Lion Productions website at:
    <br />http://lionprod.f2o.org

  4. #4

    Set8087CW... Huh? :shock:

    Microsoft Visual C++ masks (disables) FPU exceptions by default. Direct3D and OpenGL raise quite a few FPU exceptions during normal operation, usually divide by zero. Borland does not normally mask these FPU exceptions, so any Direct3D or OpenGL code you see for Delphi or C++ Builder will usually include that call to Set8087CW to set this exception mask.

  5. #5

    Set8087CW... Huh? :shock:

    Borland does not normally mask these FPU exceptions
    Even worse - some (old) versions of Delphi change Floating Point Control Word during normal operations. Most notable examples are Int, Frac, Round functions. So normal situations in Delphi was: you call some OpenGL/DirectX functions, later call one of the above mentioned functions - and got EXCEPTION! Becase inside these functions Delphi sets FP control word to another state and not clearing exception flags before it!

    About Delphi versions:
    Delphi2 - has this bag
    Delphi7 - contain correct version.

    I'm lazy to look at RTL source on other Delphi versions, but IIRC till Delphi 3-5 have this bug too.
    There are only 10 types of people in this world; those who understand binary and those who don't.

  6. #6

    Set8087CW... Huh? :shock:

    I'll piggy-back a question.

    I sometimes get problems w/ Delphi 5 and OpenGL - it says that my project "raised too many consecutive exceptions." I think it only appears (intermittently) when running from the IDE, and I can continue without any problems by hitting Run again. I'm pretty sure that my code is fine - could this issue be related to the Set8087CW or does my code suck :?:
    "All paid jobs absorb and degrade the mind."
    <br />-- Aristotle

  7. #7

    Set8087CW... Huh? :shock:

    Quote Originally Posted by Alimonster
    ... does my code suck :?:
    Surely a contradiction in terms?
    [size=10px][ Join us in #pgd on irc.freenode.net ] [ Sign the Petition for a Software Patent Free Europe ][/size]

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •