source: rtems/c/src/lib/libcpu/m68k/m68040/fpsp/sasin.S @ f8e4755f

5
Last change on this file since f8e4755f was f8e4755f, checked in by Sebastian Huber <sebastian.huber@…>, on 03/26/18 at 09:59:23

bsps/m68k: Use namespace header

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1#include "fpsp-namespace.h"
2//
3//
4//      sasin.sa 3.3 12/19/90
5//
6//      Description: The entry point sAsin computes the inverse sine of
7//              an input argument; sAsind does the same except for denormalized
8//              input.
9//
10//      Input: Double-extended number X in location pointed to
11//              by address register a0.
12//
13//      Output: The value arcsin(X) returned in floating-point register Fp0.
14//
15//      Accuracy and Monotonicity: The returned result is within 3 ulps in
16//              64 significant bit, i.e. within 0.5001 ulp to 53 bits if the
17//              result is subsequently rounded to double precision. The
18//              result is provably monotonic in double precision.
19//
20//      Speed: The program sASIN takes approximately 310 cycles.
21//
22//      Algorithm:
23//
24//      ASIN
25//      1. If |X| >= 1, go to 3.
26//
27//      2. (|X| < 1) Calculate asin(X) by
28//              z := sqrt( [1-X][1+X] )
29//              asin(X) = atan( x / z ).
30//              Exit.
31//
32//      3. If |X| > 1, go to 5.
33//
34//      4. (|X| = 1) sgn := sign(X), return asin(X) := sgn * Pi/2. Exit.
35//
36//      5. (|X| > 1) Generate an invalid operation by 0 * infinity.
37//              Exit.
38//
39
40//              Copyright (C) Motorola, Inc. 1990
41//                      All Rights Reserved
42//
43//      THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MOTOROLA
44//      The copyright notice above does not evidence any
45//      actual or intended publication of such source code.
46
47//SASIN idnt    2,1 | Motorola 040 Floating Point Software Package
48
49        |section        8
50
51PIBY2:  .long 0x3FFF0000,0xC90FDAA2,0x2168C235,0x00000000
52
53        |xref   t_operr
54        |xref   t_frcinx
55        |xref   t_extdnrm
56        |xref   satan
57
58        .global sasind
59sasind:
60//--ASIN(X) = X FOR DENORMALIZED X
61
62        bra             t_extdnrm
63
64        .global sasin
65sasin:
66        fmovex          (%a0),%fp0      // ...LOAD INPUT
67
68        movel           (%a0),%d0
69        movew           4(%a0),%d0
70        andil           #0x7FFFFFFF,%d0
71        cmpil           #0x3FFF8000,%d0
72        bges            asinbig
73
74//--THIS IS THE USUAL CASE, |X| < 1
75//--ASIN(X) = ATAN( X / SQRT( (1-X)(1+X) ) )
76
77        fmoves          #0x3F800000,%fp1
78        fsubx           %fp0,%fp1               // ...1-X
79        fmovemx %fp2-%fp2,-(%a7)
80        fmoves          #0x3F800000,%fp2
81        faddx           %fp0,%fp2               // ...1+X
82        fmulx           %fp2,%fp1               // ...(1+X)(1-X)
83        fmovemx (%a7)+,%fp2-%fp2
84        fsqrtx          %fp1            // ...SQRT([1-X][1+X])
85        fdivx           %fp1,%fp0               // ...X/SQRT([1-X][1+X])
86        fmovemx %fp0-%fp0,(%a0)
87        bsr             satan
88        bra             t_frcinx
89
90asinbig:
91        fabsx           %fp0     // ...|X|
92        fcmps           #0x3F800000,%fp0
93        fbgt            t_operr         //cause an operr exception
94
95//--|X| = 1, ASIN(X) = +- PI/2.
96
97        fmovex          PIBY2,%fp0
98        movel           (%a0),%d0
99        andil           #0x80000000,%d0 // ...SIGN BIT OF X
100        oril            #0x3F800000,%d0 // ...+-1 IN SGL FORMAT
101        movel           %d0,-(%sp)      // ...push SIGN(X) IN SGL-FMT
102        fmovel          %d1,%FPCR
103        fmuls           (%sp)+,%fp0
104        bra             t_frcinx
105
106        |end
Note: See TracBrowser for help on using the repository browser.