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/] [scosh.S] - Blame information for rev 30

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
//
2
//      $Id: scosh.S,v 1.2 2001-09-27 12:01:22 chris Exp $
3
//
4
//      scosh.sa 3.1 12/10/90
5
//
6
//      The entry point sCosh computes the hyperbolic cosine of
7
//      an input argument; sCoshd 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 cosh(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 sCOSH takes approximately 250 cycles.
21
//
22
//      Algorithm:
23
//
24
//      COSH
25
//      1. If |X| > 16380 log2, go to 3.
26
//
27
//      2. (|X| <= 16380 log2) Cosh(X) is obtained by the formulae
28
//              y = |X|, z = exp(Y), and
29
//              cosh(X) = (1/2)*( z + 1/z ).
30
//              Exit.
31
//
32
//      3. (|X| > 16380 log2). If |X| > 16480 log2, go to 5.
33
//
34
//      4. (16380 log2 < |X| <= 16480 log2)
35
//              cosh(X) = sign(X) * exp(|X|)/2.
36
//              However, invoking exp(|X|) may cause premature overflow.
37
//              Thus, we calculate sinh(X) as follows:
38
//              Y       := |X|
39
//              Fact    :=      2**(16380)
40
//              Y'      := Y - 16381 log2
41
//              cosh(X) := Fact * exp(Y').
42
//              Exit.
43
//
44
//      5. (|X| > 16480 log2) sinh(X) must overflow. Return
45
//              Huge*Huge to generate overflow and an infinity with
46
//              the appropriate sign. Huge is the largest finite number in
47
//              extended format. Exit.
48
//
49
//
50
 
51
//              Copyright (C) Motorola, Inc. 1990
52
//                      All Rights Reserved
53
//
54
//      THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MOTOROLA
55
//      The copyright notice above does not evidence any
56
//      actual or intended publication of such source code.
57
 
58
//SCOSH idnt    2,1 | Motorola 040 Floating Point Software Package
59
 
60
        |section        8
61
 
62
        |xref   t_ovfl
63
        |xref   t_frcinx
64
        |xref   setox
65
 
66
T1:     .long 0x40C62D38,0xD3D64634 // ... 16381 LOG2 LEAD
67
T2:     .long 0x3D6F90AE,0xB1E75CC7 // ... 16381 LOG2 TRAIL
68
 
69
TWO16380: .long 0x7FFB0000,0x80000000,0x00000000,0x00000000
70
 
71
        .global scoshd
72
scoshd:
73
//--COSH(X) = 1 FOR DENORMALIZED X
74
 
75
        fmoves          #0x3F800000,%fp0
76
 
77
        fmovel          %d1,%FPCR
78
        fadds           #0x00800000,%fp0
79
        bra             t_frcinx
80
 
81
        .global scosh
82
scosh:
83
        fmovex          (%a0),%fp0      // ...LOAD INPUT
84
 
85
        movel           (%a0),%d0
86
        movew           4(%a0),%d0
87
        andil           #0x7FFFFFFF,%d0
88
        cmpil           #0x400CB167,%d0
89
        bgts            COSHBIG
90
 
91
//--THIS IS THE USUAL CASE, |X| < 16380 LOG2
92
//--COSH(X) = (1/2) * ( EXP(X) + 1/EXP(X) )
93
 
94
        fabsx           %fp0            // ...|X|
95
 
96
        movel           %d1,-(%sp)
97
        clrl            %d1
98
        fmovemx %fp0-%fp0,(%a0) //pass parameter to setox
99
        bsr             setox           // ...FP0 IS EXP(|X|)
100
        fmuls           #0x3F000000,%fp0        // ...(1/2)EXP(|X|)
101
        movel           (%sp)+,%d1
102
 
103
        fmoves          #0x3E800000,%fp1        // ...(1/4)
104
        fdivx           %fp0,%fp1               // ...1/(2 EXP(|X|))
105
 
106
        fmovel          %d1,%FPCR
107
        faddx           %fp1,%fp0
108
 
109
        bra             t_frcinx
110
 
111
COSHBIG:
112
        cmpil           #0x400CB2B3,%d0
113
        bgts            COSHHUGE
114
 
115
        fabsx           %fp0
116
        fsubd           T1(%pc),%fp0            // ...(|X|-16381LOG2_LEAD)
117
        fsubd           T2(%pc),%fp0            // ...|X| - 16381 LOG2, ACCURATE
118
 
119
        movel           %d1,-(%sp)
120
        clrl            %d1
121
        fmovemx %fp0-%fp0,(%a0)
122
        bsr             setox
123
        fmovel          (%sp)+,%fpcr
124
 
125
        fmulx           TWO16380(%pc),%fp0
126
        bra             t_frcinx
127
 
128
COSHHUGE:
129
        fmovel          #0,%fpsr                //clr N bit if set by source
130
        bclrb           #7,(%a0)                //always return positive value
131
        fmovemx (%a0),%fp0-%fp0
132
        bra             t_ovfl
133
 
134
        |end

powered by: WebSVN 2.1.0

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