[comp.sys.mac.programmer] How do I use a floating point chip in a MAC II?

bob@aecom.YU.EDU (Bob Lummis) (03/11/89)

I am programming in LSC.  I want to do floating point arithmetic as fast as
possible on a machine with a floating point chip, but have the program still
run (slower) on a plain Mac.  How do I do that?  How do I determine if I am
executing on a machine with floating point?

Even if the answer is that a floating point expression in LSC is automatically
executed with the floating point package, which invokes SANE,
which invokes the floating point chip if it is present, is there
a faster way? I.e. can I bypass the floating point package and
SANE to get faster execution?
-- 
Robert C. Lummis, Director of Scientific Computing
Albert Einstein College of Medicine, Bronx, N.Y.
Domain: bob@aecom.yu.edu
UUCP: {uunet,philabs,phri}!aecom!bob

siegel@endor.harvard.edu (Rich Siegel) (03/13/89)

In article <2129@aecom.YU.EDU> bob@aecom.YU.EDU (Bob Lummis) writes:
>I am programming in LSC.  I want to do floating point arithmetic as fast as
>possible on a machine with a floating point chip, but have the program still
>run (slower) on a plain Mac.  How do I do that?  How do I determine if I am
>executing on a machine with floating point?

	Use the 68881 code generation option, which will generate direct
calls to the coprocessor, and the Math881 library. The easy way to run
on multiple machines is to have separate versions of your program.

	You can determine the presence of the coprocessor by using SysEnvirons.

		--Rich



Rich Siegel
Staff Software Developer
THINK Technologies Division, Symantec Corp.
Internet: siegel@endor.harvard.edu
UUCP: ..harvard!endor!siegel
Phone: (617) 275-4800 x305

earleh@eleazar.dartmouth.edu (Earle R. Horton) (03/13/89)

In article <1397@husc6.harvard.edu> siegel@endor.UUCP (Rich Siegel) writes:
>
>	Use the 68881 code generation option, which will generate direct
>calls to the coprocessor, and the Math881 library. The easy way to run
>on multiple machines is to have separate versions of your program.
>
     This is the easy way for the programmer, maybe.  For ease of use
on the customer end, you might want to do what Microsoft Excel does:
use the math chip if present, use SANE if not.  I have thought about
this, and it does not appear to be easy.  The worst part seems to be
that the fundamental floating point data type, "extended," is 10 bytes
with SANE and 12 bytes with the math chip.  This seems to mean that
Excel, for instance, must have duplicate functions for all floating
point operations, and loads in the right ones at the start based on
the environment.  The previous sentence is a guess, of course, but you
would have to do something slick to have a program which makes use of
the math chip when it can, and uses SANE when it cannot.

     Another choice is to write a 68881 emulator.  In view of the
large number of addressing modes, registers, and operations, this
might be a horrendous task.  I seem to remember from a previous
article in this newsgroup that someone claims to have written one, by
the way.



Earle R. Horton. 23 Fletcher Circle, Hanover, NH 03755--Graduate student.
He who puts his hand to the plow and looks back is not fit for the kingdom
of winners.  In any case, 'BACK' doesn't work.