~ubuntu-branches/ubuntu/gutsy/avr-libc/gutsy

« back to all changes in this revision

Viewing changes to libm/fplib/tan.S

  • Committer: Bazaar Package Importer
  • Author(s): Hakan Ardo
  • Date: 2006-05-01 12:03:39 UTC
  • mto: (3.1.1 edgy)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20060501120339-q93dxulpunby36dj
Tags: upstream-1.4.4
ImportĀ upstreamĀ versionĀ 1.4.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
   POSSIBILITY OF SUCH DAMAGE. 
33
33
*/
34
34
 
 
35
/* $Id: tan.S,v 1.7.2.1 2005/12/11 19:40:01 aesok Exp $ */
 
36
 
35
37
/*
36
38
    tan.S is part of     FPlib V 0.3.0       ported to avr-as
37
39
    for details see readme.fplib
46
48
 * the formula tan(x) = 1/tan(PI/2 - x) is used for values > PI/4
47
49
 */
48
50
 
49
 
#if !defined(DOXYGEN)
 
51
#if !defined(__DOXYGEN__)
50
52
 
51
53
#include "gasava.inc"
 
54
#include "macros.inc"
52
55
#include "fplib.inc"
53
56
 
54
57
          TEXT_SEG(fplib, tan)
61
64
       ANDI    rSI0,0x80        ; assume inversion flag zero
62
65
       ANDI    rA3,0x7F
63
66
       CPI     rA3,0x39
64
 
       BRCS    _tan_100         ; (tan(A < 0x39000000)=A)
 
67
       BRCS    100f             ; (tan(A < 0x39000000)=A)
65
68
 
66
69
       LDI     rB3,0x40
67
70
       LDI     rB2,0x49
77
80
       CPC     rB1,rA1
78
81
       CPC     rB2,rA2
79
82
       CPC     rB3,rA3          ; B(=PI/2) - A
80
 
       BREQ    _tan_INF
81
 
       BRCC    _tan_10
 
83
       BREQ    101f
 
84
       BRCC    1f
82
85
       LDI     rB3,0x40
83
86
       LDI     rB2,0x49         ; load PI
84
87
       ORI     rA3,0x80         ; A = -A
85
88
       RCALL   _U(__addsf3)     ; A = A+B = B + (-A)
86
89
       LDI     rB3,0x80
87
90
       EOR     rSI0,rB3
88
 
 _tan_10:
 
91
1:
89
92
       LDI     rB3,0x3F
90
93
       LDI     rB2,0x49
91
94
       LDI     rB1,0x0F
94
97
       CPC     rB1,rA1
95
98
       CPC     rB2,rA2
96
99
       CPC     rB3,rA3          ; B(=PI/4) - A
97
 
       BRCC    _tan_00
 
100
       BRCC    1f
98
101
       INC     rSI0
99
102
       ORI     rA3,0x80         ; negate A
100
103
       LDI     rB2,0xC9         ; P/4 -> PI/2
101
104
       RCALL   _U(__addsf3)     ; PI/2 - A
102
 
 _tan_00:
 
105
1:
103
106
       PUSH    rA3
104
107
       PUSH    rA2
105
108
       PUSH    rA1
115
118
       POP     rB3
116
119
       RCALL   _U(__mulsf3)
117
120
       SBRS    rSI0,0
118
 
       RJMP    _tan_100
 
121
       RJMP    100f
119
122
       RCALL   _U(__fp_inverse)
120
 
 _tan_100:
 
123
100:
121
124
       SBRC    rSI0,7
122
125
       ORI     rA3,0x80
123
126
       POP     rSI0
124
127
       RET
125
 
 _tan_INF:
 
128
101:
126
129
       POP     rSI0
127
130
       RJMP    _U(__fp_nan)
128
131
 
144
147
 * h3  : 0.000253971
145
148
 * h2  : 0.0245202
146
149
 * h1  : 0.464239
 
150
 * 1.0
147
151
 */
148
152
 
149
153
        PGM_SECTION
150
154
 
151
 
        /* these constants are *no* IEEE float values:  exponent unpacked allready
152
 
         *                                              first byte : exponent
153
 
         *                                              2nd byte   : msb of mantissa with sign as bit 7
154
 
         *                                              3rd & 4th byte : mantissa
155
 
         */
156
 
 table_tan:  DCB 3 ; no of table entries - 1 (preload value)
157
 
             DCB 0x73, 0x05, 0x27, 0x60     ; h - first calculate denominator
158
 
             DCB 0x79, 0x48, 0xDE, 0x92
159
 
             DCB 0x7D, 0x6D, 0xB0, 0xCA
160
 
             DCB 0x7F, 0x00, 0x00, 0x00
 
155
table_tan:  DCB 3 ; no of table entries - 1 (preload value)
 
156
             DCB 0x39, 0x85, 0x27, 0x60     ; h - first calculate denominator
 
157
             DCB 0x3C, 0xC8, 0xDE, 0x92
 
158
             DCB 0x3E, 0xED, 0xB0, 0xCA
 
159
             DCB 0x3F, 0x80, 0x00, 0x00
161
160
             DCB 3 ; no of table entries - 1 (preload value)
162
 
             DCB 0x6E, 0x37, 0x00, 0xF3     ; f
163
 
             DCB 0x76, 0x4B, 0x9F, 0xB8
164
 
             DCB 0x7C, 0x06, 0x0C, 0x3E
165
 
             DCB 0x7F, 0x00, 0x00, 0x00
 
161
             DCB 0x37, 0x37, 0x00, 0xF3     ; f
 
162
             DCB 0x3B, 0x4B, 0x9F, 0xB8
 
163
             DCB 0x3E, 0x06, 0x0C, 0x3E
 
164
             DCB 0x3F, 0x80, 0x00, 0x00
166
165
 
167
 
#endif /* not DOXYGEN */
 
166
#endif /* not __DOXYGEN__ */