[fpc-pascal]Double-precision recursion
Rich Pasco
pasco at acm.org
Thu Mar 29 23:40:41 CEST 2001
Apparently the problem is that neither Borland Pascal (BP) nor Free
Pascal (FP) appropriately handle the Floating Point Unit (FPU) hardware
stack during procedure calls, although apparently Microsoft Visual C
(MSVC) does, as demonstrated by successful operation of the C version of
my example.
The stack should either be extended into RAM or saved and restored, but
apparently BP and FP do neither.
Here are some relevant quotes from Intel's "Guidelines for Writing FPU
Exception Handlers" at
http://www.intel.nl/design/intarch/techinfo/Pentium/fpuhandl.htm
"In some operating systems supporting the FPU, the numeric register
stack is extended to memory. To extend the FPU stack to memory, the
invalid exception is unmasked."
"In order to support multi-tasking, each thread in the system needs
a save area for the general purpose registers, and each task that is
allowed to use floating point needs an FPU save area large enough to
hold the entire FPU stack and associated FPU state such as the control
word and status word. (See "Saving the FPU's State", for a complete
description of the FPU save image.)"
A relevant application note of further interest, "AP-578:
Software and Hardware Considerations for FPU Exception Handlers
for Intel Architecture Processors" may be obtained from
http://developer.intel.com/design/pro/applnots/243291.htm
Whew.
- Rich
More information about the fpc-pascal
mailing list