Intel 80287, 80286 manual Calculating Trigonometric Functions, Numeric Programming Examples

Models: 80287 80286

1 515
Download 515 pages 45.04 Kb
Page 474
Image 474

NUMERIC PROGRAMMING EXAMPLES

Cosine Uses Sine Code

To save code space, the cosine function uses most of the sine function code. The relation sin ( IA I + 7r/2) = cos(A) is used to convert the cosine a.rgument into a sine argument. Adding 7r/2 to the angle is performed by adding 0102 to the FPREM quotient bits identifying the argument's octant.

It would be very inaccurate to add 7r/2 to the cosine argument if it was very much different from 7r/2.

Depending on which octant the argument falls in, a different relation will be used in the sine and tangent functions. The program listings show which relations are used.

For the tangent function, the ratio produced by FPTAN will be directly evaluated. The sine function will use either a sine or cosine relation depending on which octant the angle fell into. On exit, these functions will normally leave a divide instruction in progress to maintain concurrency.

If the input angles are of a restricted range, such as from 0 to 45 degrees, then considerable optimiza- tion is possible since full angle reduction and octant identification is not necessary.

All three functions begin by looking at the value given to them. Not a Number (NaN), infinity, or empty registers must be specially treated. Unnormals need to be converted to normal values before the FPTAN instruction will work correctly. Denormals will be converted to very small unnormals that do work correctly for the FPTAN instruction. The sign of the angle is saved to control the sign of the result.

Within the functions, close attention was paid to maintain concurrent execution of the 80287 and host. The concurrent execution will effectively hide the execution time of the decision logic used in the program.

iAPX286 MACRO

A.SSEMBLER

80287

Trignoltletric Functions

10: 13: 51 OQ/25/83 PAGE

SERIES-III iAPX286 MACRO ASSEMBLER XI08 ASSEMBLY OF MODULE TRIO FUNCTIONS

OBJECT MODULE

PLACED IN

: F3: TRIO. OBJ

 

-

ASSEMBLER INVOKED BY:

ASM:!86.96; F3: TRIQ. AP2

 

 

LOC OBJ

 

LINE

SOURCE

 

 

 

 

1 +1

ttitle("80287

Trignometric Functions")

 

 

2

 

 

 

 

 

3

 

nama

trig_function~

 

 

4

 

public sine. cosine. tangent

 

 

5

 

 

 

 

 

6

stack

 

I Ra.erve local space

 

 

7

 

 

 

 

 

8

SIIl_2B7

record

res1: 1, tend3: I. top: 3. tend:?: 1. tend1: 1, condO: 1.

 

 

9

tc

 

,..,2: 8

 

 

11

code

segment

el'" public

 

 

12

 

 

 

13Define local constants.

0000

35CO;!b821A2DAOF

15

pi_ltuarter

aven

 

 

 

16

dt

3FFEC90FDAA2216BC:235R,

Pl/4

 

C9FE3F

 

 

 

 

 

 

OOOA

OOOOCOFF

17

indefinite

dd

OFFCOOOOOR

,

Indefinite special ..... lu.

18 +1 $eJllct

Figure 4-7. Calculating Trigonometric Functions

4-18

Page 474
Image 474
Intel 80287, 80286 manual Calculating Trigonometric Functions, Numeric Programming Examples