ftp.nice.ch/pub/next/developer/hardware/m68k/SoftwareMathCoprocFor68040.README

This is the README for SoftwareMathCoprocFor68040.2.0.N.sa.tar.gz [Download] [Browse] [Up]

Bug fixes by Avery Wang, May 11, 1993

I posted this on May 6, 1993 but
frank@lucas.medicine.nwu.edu was kind enough to point out
that there were some bugs in the library.  This was the result of
leaving out function headers in the functions log10(),
pow(,), so that the internally called functions were
implicity (and wrongly) defined.  Also, in the process of
checking out all of the other functions I found some
anomalies.  floor() returned the wrong result for negative
integers (I fixed that too).  And the strangeness remains that
log(0) and log10(0) are returned as
-7.090895657128240800e+02 and
-3.079536855642527900e+02 respectively.  The log
functions in libm.a give -Infinity.  I also found that the
functions differ in general from their counterparts in
libm.a by about a factor of 10^-13 or so.  This means that for all
practical purposes, these functions are fine for everyday
use.  The float values should be pretty much identical, but you
may notice some discrepancies with double results.  

Now these problems are fixed so theoretically, everything should work, under reasonable limits.

Send me bug reports, etc. (oh, boy...)

	Avery Wang
	email: avery@ccrma.stanford.edu
---------------------------------------------------------

Modified by Avery Wang, February 20, 1993

I put the jv_ prefix before every function name in order to
avoid the collision with NeXT's shared libraries, so it now
works with NS 3.0 and ProjectBuilder..  All you need to do is
include the library libjvr.a in your project and add  

#include "jv.h"

to every *.[mc] file which uses transcendental functions. 
The file jv.h redefines the transcencentals so the compiler
uses the new faster routines. 

---------------------------------------------------------


Enclosed is a floating point library that avoids the problems of line-f 
calls as is done in NeXT-step 2.
The problem is the following:
In the 68030 there are no floating point operations. Hence the 68882 has 
been added. Its instructions are accessed by a direct link between the 
68030 and the 68882. The instructions that use this link are called 
line-f instructions and they can be programmed even at the assembly 
level. This system was used in the old NeXT computers that worked with 
the 68030.
The NeXT-stations and the newer cubes use a 68040. This chip has a 
number of floating point operations (*,/,+,-,sqrt) built in. Because of 
this no floating point coprocessor has been added. These operations are 
again accessed by (the same) line-f instructions. The problems arise 
with the extra transcendental functions that were available in the 
68882. These have to be simulated in software. However the math library 
still provides the old routines with the lin-f calls for these 
functions. What happens when such a function is called is then:
1:  the chip gets the line-f instruction.
2:  it does not recognize it
3:  it generates an exception
4:  the exception handler figures out what went wrong
5:  the exception handler calls the appropriate routine
The overhead of this is such that it can make floating point intensive 
programs, that use the transcendental functions frequently, 
significantly slower than necessary. Often even by more than a factor 2. 
The routines in this distribution avoid this problem. If you use 
cc ........ -ljv -lm
rather than
cc ........ -lm
the routines that are in libjv.a take priority. This avoids the 
exception handler. The -lm may be necessary if you use routines that are 
not in libjv.a. If you do not use such routines, it can be omitted.
I did not have time to do all routines because when I made this I was in 
the middle of a project and needed some speed.

Caution:
The routines are guaranteed to work for IEEE precision. They do not 
return extended 80 bits precision. In the way these routines are used 
and because the compiler never uses the passing of arguments by 
(floating point) registers there is no need for this precision. 

Remark 1:
From version 3.0 on there will be similar routines in libm.a

Remark 2:
You may use these routines freely. All rights remain with the author.

Remark 3:
The author is Jos Vermaseren (t68@nikhef.nl). If you have useful 
suggestions (like bug reports), please send them.

Remark 4:
In the distribution you should find the files
  acos.c asin.c atan.c atan2.c cos.c exp.c floor.c fmod.c
  libjv.a log.c log10.c makefile pow.c sin.c sqrt.s tan.c
You can use the libjv.a file directly. You can also make a new library 
file by typing in 'make'.

Remark 5:
Note that if you try to make additional routines you should try to avoid 
divisions. They are quite 'expensive'.

Remark 6:
If your programs use only multiplications, divisions, additions and 
subtractions the use of libjv.a will not make a difference at all. 
Hence the actual improvement is very much a function of your program.

Good Luck
Jos Vermaseren

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.