OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libcpu/] [m68k/] [m68040/] [fpsp/] [sacos.S] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
//
2
//      $Id: sacos.S,v 1.2 2001-09-27 12:01:22 chris Exp $
3
//
4
//      sacos.sa 3.3 12/19/90
5
//
6
//      Description: The entry point sAcos computes the inverse cosine of
7
//              an input argument; sAcosd 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 arccos(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 sCOS takes approximately 310 cycles.
21
//
22
//      Algorithm:
23
//
24
//      ACOS
25
//      1. If |X| >= 1, go to 3.
26
//
27
//      2. (|X| < 1) Calculate acos(X) by
28
//              z := (1-X) / (1+X)
29
//              acos(X) = 2 * atan( sqrt(z) ).
30
//              Exit.
31
//
32
//      3. If |X| > 1, go to 5.
33
//
34
//      4. (|X| = 1) If X > 0, return 0. Otherwise, return Pi. 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
//SACOS idnt    2,1 | Motorola 040 Floating Point Software Package
48
 
49
        |section        8
50
 
51
PI:     .long 0x40000000,0xC90FDAA2,0x2168C235,0x00000000
52
PIBY2:  .long 0x3FFF0000,0xC90FDAA2,0x2168C235,0x00000000
53
 
54
        |xref   t_operr
55
        |xref   t_frcinx
56
        |xref   satan
57
 
58
        .global sacosd
59
sacosd:
60
//--ACOS(X) = PI/2 FOR DENORMALIZED X
61
        fmovel          %d1,%fpcr               // ...load user's rounding mode/precision
62
        fmovex          PIBY2,%fp0
63
        bra             t_frcinx
64
 
65
        .global sacos
66
sacos:
67
        fmovex          (%a0),%fp0      // ...LOAD INPUT
68
 
69
        movel           (%a0),%d0               // ...pack exponent with upper 16 fraction
70
        movew           4(%a0),%d0
71
        andil           #0x7FFFFFFF,%d0
72
        cmpil           #0x3FFF8000,%d0
73
        bges            ACOSBIG
74
 
75
//--THIS IS THE USUAL CASE, |X| < 1
76
//--ACOS(X) = 2 * ATAN( SQRT( (1-X)/(1+X) )     )
77
 
78
        fmoves          #0x3F800000,%fp1
79
        faddx           %fp0,%fp1               // ...1+X
80
        fnegx           %fp0            // ... -X
81
        fadds           #0x3F800000,%fp0        // ...1-X
82
        fdivx           %fp1,%fp0               // ...(1-X)/(1+X)
83
        fsqrtx          %fp0            // ...SQRT((1-X)/(1+X))
84
        fmovemx %fp0-%fp0,(%a0) // ...overwrite input
85
        movel           %d1,-(%sp)      //save original users fpcr
86
        clrl            %d1
87
        bsr             satan           // ...ATAN(SQRT([1-X]/[1+X]))
88
        fmovel          (%sp)+,%fpcr    //restore users exceptions
89
        faddx           %fp0,%fp0               // ...2 * ATAN( STUFF )
90
        bra             t_frcinx
91
 
92
ACOSBIG:
93
        fabsx           %fp0
94
        fcmps           #0x3F800000,%fp0
95
        fbgt            t_operr         //cause an operr exception
96
 
97
//--|X| = 1, ACOS(X) = 0 OR PI
98
        movel           (%a0),%d0               // ...pack exponent with upper 16 fraction
99
        movew           4(%a0),%d0
100
        cmpl            #0,%d0          //D0 has original exponent+fraction
101
        bgts            ACOSP1
102
 
103
//--X = -1
104
//Returns PI and inexact exception
105
        fmovex          PI,%fp0
106
        fmovel          %d1,%FPCR
107
        fadds           #0x00800000,%fp0        //cause an inexact exception to be put
108
//                                      ;into the 040 - will not trap until next
109
//                                      ;fp inst.
110
        bra             t_frcinx
111
 
112
ACOSP1:
113
        fmovel          %d1,%FPCR
114
        fmoves          #0x00000000,%fp0
115
        rts                             //Facos ; of +1 is exact
116
 
117
        |end

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.