Below is a list of the Borland documentation that BitSavers added in 2022, ordered by relevance to me (and how I finally asked Peter Sawatzki if he still had the monochrome TDVIDEO.DLL he wrote for Turbo Debugger 3.0 for Windows):
Archive for the ‘8087’ Category
BitSavers added some more Borland documentation in 2022 (most relevant for me: Assembler, Debugger, Profiler)
Posted by jpluimers on 2024/02/28
Posted in 8087, Algorithms, Assembly Language, Borland C++, C, C++, Debugging, Development, Floating point handling, Profiling, Software Development, Turbo Assembler, Turbo C, Turbo Debugger, Turbo Profiler, x86 | Leave a Comment »
Delphi history – on the FINITEFLOAT compiler option that has no one-character shortcut
Posted by jpluimers on 2016/12/14
Back in the .NET days, Delphi had an FINITEFLOAT compile option that came without a single-character shortcut.
It was about the handling of infinite float and other special float values in cases like overflow and underflow (including +Inf, -Inf and [Wayback] NaN).
At first – in the [Wayback] Delphi 8 (Octane) era of which few people want to be reminded off – it was the [Wayback] undocumented counterpart of the [Wayback] 8087 exception mask in x86 mode. Hallvard Vassbotn wrote an article about it and Chee Wee Chua documented it before it got documented in Delphi 2009 (that coincidentally dropped .NET support in the compiler – go figure):
- [Wayback] Hallvard’s Blog: DN4DP#16: .NET only: Floating-point semantics
- [Wayback] Undocumented Delphi 8 compiler directive FINITEFLOAT – Chee Wee’s blog: IT solutions for Singapore and companies worldwide
- [Wayback] Floating Point Exception Checking (Delphi)
$FINITEFLOAT
Whereas the native Delphi compilers had exceptions turned on, Microsoft compilers (including .NET) had them turned off, hence the compiler option.
Like most new Delphi features in this century, FINITEFLOAT didn’t come without quirks. Often these are fleshed out in 2-3 product releases, but this one wasn’t:
The FINITEFLOAT compile option didn’t have a single-character shortcut. This made it impossible to use the {$IFOPT ...} construct as IFOPT only works for single-character compiler options.
Which means you get questions like [Wayback] Why doesn’t {$ifopt FINITEFLOAT ON} compile? – Stack Overflow (I actually got into writing this article because I found a {$DEFINE FINFINITEFLOAT_ENABLED} in some pretty old code) and compiler enhancement requests like [WayBack] QualityCentral – Please enhance the IFOPT directive for long switch names. It’s easier to read (which will likely never bee fixed).
For completeness some more information about exception masks in the native compiler:
- In the past you could only set the exception mask as part of the full control word using [Wayback] Set8087CW, nowadays you can use [Wayback] SetExceptionMask.
- Next to a precision mask, there are five exception masks you can set, see for instance this table from the [Wayback] Simply FPU Chap.1 Control Word section:
PM (bit 5) or Precision Mask
UM (bit 4) or Underflow Mask
OM (bit 3) or Overflow Mask
ZM (bit 2) or Zero divide Mask
DM (bit 1) or Denormalized operand Mask
IM (bit 0) or Invalid operation Mask
–jeroen
Posted in 8087, Algorithms, Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 8, Development, Floating point handling, History, QC, Software Development | 1 Comment »
Delphi – Direct3D and the wrong FPU state: Now() function returns a wrong value (via: StackOverflow)
Posted by jpluimers on 2013/10/31
The question datetime – Delphi Now() function returns a wrong value – Stack Overflow is similar to my article Delphi – Michael Justin had strange floating point results when his 8087 FPU Control Word got hosed.
Good that stackoverflow user Anton Zhuchkov found out the cause himself: his answer indicates the Precision Control (and rounding) part of the FPU state got hosed by wrongly initializing the Direct3D device.
I edited his answer with some extra links to documentation.
Finally I’ve found the solution. I needed to specify the
D3DCREATE_FPU_PRESERVEflag when creating a D3D device byD3D.CreateDevice.Otherwise, without that flag, all floating point operations are performed with single precision. As the
TDateTimeis a simpleDouble, andNow()functions is consist of simple addition of date value to time value, it all get messed up by DirectX “smart” override.Problem solved. It was a tricky one indeed. :)
–jeroen
via: datetime – Delphi Now() function returns a wrong value – Stack Overflow.
Posted in 8087, Algorithms, Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 5, Delphi 6, Delphi 7, Delphi XE, Delphi XE2, Delphi XE3, Development, Floating point handling, Software Development | 2 Comments »
Delphi – Michael Justin had strange floating point results when his 8087 FPU Control Word got hosed
Posted by jpluimers on 2009/05/06
Two days ago, [Wayback] Michael Justin (who just released version 1.7 of the [Wayback] Habari Active MQ Client components) posted a blog entry about a strange circumstance [Wayback] when 1.99 would not compare equally to 1.99.
He tracked it down to the [Wayback] 8087 (more formally: Intel [Wayback] FPU) Control Word being hosed on his system.
I could not reproduce his particular case, but since I have seen similar issues in the past, I wrote the DUnit test case below which shows you what can happen by manually setting the 8087 Control Word.
The difference between the 8087 Control Word values $1372 (default) and $1272 (failure) is the internal mantissa precision (see the [Wayback] “Art of Assembly Language” and the [Wayback] Intel FPU Control Word documentation on this).
Edit: Found a [Wayback] much more complete description of the bits in the FPU Control word.
It changes from 64 bits to 53 bits, which is enough to make 1.99 not equal to 1.99.
I have seen behaviour like this in the past with some networking stacks in the Turbo Pascal 7 era, with some C++ DLL’s in the Delphi 1-3 era, and some printer drivers in the Delphi 5-7 era.
Let me know in the comments (or using the contact form) where you have bumped into this.
The code below makes use of the Jcl8087 unit which is part of the JCL ([Wayback] JEDI Code Library) at [Wayback] SourceForge.
Add the unit to any DUnit test project you created and observe the results.
Read the rest of this entry »
Posted in 8087, Algorithms, Delphi, Development, Floating point handling, Software Development | 8 Comments »





