[fpc-devel] Cannot trap divide by zero in xmm register

Henry Vermaak henry.vermaak at gmail.com
Tue Jun 20 17:12:18 CEST 2017

On Tue, Jun 20, 2017 at 10:53:32AM -0400, Anthony Walter wrote:
> Some progress ... Since this is an OpenGL app I had been
> setting Set8087CW($133F) to prevent FPU errors from showing as exceptions.
> When I omit Set8087CW I get EDivByZero an exception, but my program is
> still in an unusable state.
> Since this error occurs in the SSE XMM registers, I think I should also be
> using the SetSSECSR function. Does anyone have any details about how this
> function works in relation to XMM registers and rounding or divide by zero
> errors and how it could be applied in my situation?

I use this for all my programs that use C libraries:

{$if defined(cpui386) or defined(cpux86_64)}
  SetExceptionMask(GetExceptionMask + [exZeroDivide, exInvalidOp]);

Works fine with libs like OpenCV, etc.


More information about the fpc-devel mailing list