Category : Miscellaneous Language Source Code
Archive   : TP387.ZIP
Filename : TP387.DOC

 
Output of file : TP387.DOC contained in archive : TP387.ZIP
This program illustrates how floating point performance can be improved
by taking advantage of the 80387/i486 (and non-Intel 287 and 387)
trig functions. The 8087 and 80287 handled these functions in only the
most primitive way, requiring extensive coding to convert the partial
tangent and partial arctangent instructions into sin, cos, and arctan.

The program consists of several routines to replace the turbo pascal
runtime routines with routines taking advantage of the 387's fsin, fcos,
and fsincos instructions, and the 387's improved implementation of the
fptan and fpatan instructions.

ChangeSystemSinCos patches the tp run time routines to use the fsin and
fcos instructions. This has been tested on TP5.0 and TP6.0. The change
gives an improvement of about a factor of 4.

MySin and MyCos are replacement functions for the TP sin and cos functions,
and do not require the TP run time routines to be patched. They are somewhat
slower than the patched version.

MySinCos is a routine than computes both the sin and the cos of a single
argument. This is faster than computing the sin and cos independently.

Tan is a function than computes the tangent of an argument using the sin
and cos routines.

Tan387 computes the tangent using the 387 fptan instruction.

Arctan2 computes the arctangent of the quotent of two arguments, setting the
result into the correct quadrant (0 to 2pi) using the TP arctan function.

ArcTan387 computes the arctangent of the quotent of two arguments, setting
the result into the correct quadrant (0 to 2pi) using the 387 fpatan
instruction.

The rest of the program tests the accuracy of the various routines, and
test the speeds of the routines. The output of the program produced on
my Northgate 486/25 was:

Co-Processor 80387 detected.

fsin vs sin 1.110223E-0016
fcos vs cos 1.110223E-0016
fsincos vs sin 1.110223E-0016
fsincos vs cos 1.110223E-0016
arctan2 8.881784E-0016
tan 4.547474E-0013

type ticks time/op
TP sin/cos 138 75.824 usec
TP tan 148 81.319 usec
new sin/cos 54 29.670 usec
my sin/cos 67 36.813 usec
mysincos 40 21.978 usec
arctan2 79 43.407 usec
arctan387 37 20.330 usec
tan387 31 17.033 usec

Joseph R Ahlgren 2218 N Tuckahoe St Arlington, VA 22205
RBBS 703-241-7980 CompuServe 70461,2340

These routines may be freely distributed provided they are unmodified and
include the above attribution. I would appreciate any comments or
suggestions.


  3 Responses to “Category : Miscellaneous Language Source Code
Archive   : TP387.ZIP
Filename : TP387.DOC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/