[comp.sys.mac.programmer] 68881 Questions/Troubles

6500stom@hub.UUCP (Josh Pritikin) (02/14/90)

I don't have the Motorola Manual so I've resorting to posting here-

1. I get a NaN(255) after my program runs for 1-60 seconds. Its very
irregular and I'm pretty sure I'm not dividing by zero or overflowing.
Does the '881 give a NaN when you underflow?

2. I need to use the '881 during interupt time. I know it needs it's
environment saved and restored somehow.. how do you do this?

I like you get mail but maybe you should post to the net (too?).

/            Josh Pritikin             T The C++ programming language  \
| Internet:  6500stom@ucsbuxa.ucsb.edu | is at worst, the second best  |
| AppleLink: Josh.P                    | for a given application.      |
\ GEnie:     J.Pritikin                ! But usually, it is the best.  /

rcfische@polyslo.CalPoly.EDU (Raymond C. Fischer) (02/15/90)

In article <3943@hub.UUCP> 6500stom@hub.UUCP (Josh Pritikin) writes:
>I don't have the Motorola Manual so I've resorting to posting here-
>
>1. I get a NaN(255) after my program runs for 1-60 seconds. Its very
>irregular and I'm pretty sure I'm not dividing by zero or overflowing.
>Does the '881 give a NaN when you underflow?

No.

The likeliest couse of this problem is the use of uninitialized floating-
point variables, probably register variables.  The registers in the
68882 are all initialized to NaN(255) when you turn on your Mac.
With register saves/restores, they tend to stay that way for a long while.


>2. I need to use the '881 during interupt time. I know it needs it's
>environment saved and restored somehow.. how do you do this?

	FSAVE    -(SP)
	FMOVE.X  <regs used>,-(SP)

	your routine

	FMOVE    (SP)+,<regs used>
	FRESTORE (SP)+

Tech note 235 describes this in more detail.  Two things to
be aware of about FSAVE/FRESTORE however.
1) they are priviledged instructions and won't work in user mode
   (not presently relevent)
2) they are expensive instructions.  FSAVE uses 4 to 216 (28 typically)
   bytes on the stack and 15-330 (100 typical) clock cycles.  FRESTORE
   is similar


Ray Fischer
rcfische@polyslo.calpoly.edu