From: adam@microware.com (Adam Goldberg) Subject: Re: Can be sin() compiled inline ( as (3)87 command) in gcc under Linux? Date: Tue, 6 Jul 1993 13:34:29 GMT
In <216bfm$3ai@klaava.Helsinki.FI> torvalds@klaava.Helsinki.FI (Linus Torvalds) writes:
>In article <1993Jul3.185636.3016@wisipc.weizmann.ac.il> yuri@wiscon.weizmann.ac.il (Shirman Yuri) writes:
>>
>> I've compiled my program with intensive using of coprocessor ( in fact,
>> I have 486) and from *.s files i've learned that sin() is a function,
>> not operation. The -m486 flag doesn't help. There is header file for
>> 68... in /usr/g++-include which shows that the problem can be solved
>> somehow. So, what should be done in order to obtain nice 387 code and
>> avoid calls of functions from libm? I tried to write asm fun
><example deleted>
>(no the above isn't a complete example, but you get the idea). The
>problem is that the i387 limits the range of the 'fsin' instruction to
>positive values less than pi*(2^62) (according to one source: another
>one tells me that the value must be in the range -2^62 < x < 2^62.
>Could be a 387/487 difference).
According to the 80387 programmer's reference manual (dated 1987),
page 4-17, the _ABSOLUTE VALUE_ of the operand to FSIN, FCOS, FSINCOS,
and FPTAN is requred to be < 2^63. (ie, -2^63 < x < 2^63).
Quoting now:
>4.6.1 FCOS
>When complete, this function replaces the contents of ST with COS(ST).
>ST, expressed in radians, must lie in the range |<theta>| < 2^63 (for
>most practical purposes unrestricted). If ST is in range, C2 of the
>status word is cleared and the result of the operation is produced.
>If the operand is outside of the range, C2 is set to one (function
>incomplete) and ST remains intact (i.e., no reduction of the operand
>is performed). It is the programmers responsibility to reduce the
>operand to an absolute value smaller than 2^63. The instructions
>FPREM1 and FPREM are available for this purpose.
>4.6.2 FSIN
>When complete, this function replaces the contents of ST with SIN(ST).
>FSIN is equivalent to FCOS in the way it reduces the operand. ST is
>expressed in radians.
Adam
-- Adam G. adamg@microware.com, or ...!uunet!mcrware!adamg The above is not to be construed in any way as the official or unofficial statements of Microware, or any Microware employees.