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

« back to all changes in this revision

Viewing changes to libm/fplib/exp.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: exp.S,v 1.7.2.1 2005/12/11 19:40:01 aesok Exp $ */
 
36
 
35
37
/*
36
38
    exp.S is part of     FPlib V 0.3.0       ported to avr-as
37
39
    for details see readme.fplib
41
43
 *      A = exp(A)
42
44
 */
43
45
 
44
 
#if !defined(DOXYGEN)
 
46
#if !defined(__DOXYGEN__)
45
47
 
46
48
#include "gasava.inc"
 
49
#include "macros.inc"
47
50
#include "fplib.inc"
48
51
 
49
52
          TEXT_SEG(fplib, exp)
55
58
GLOBAL(exp)
56
59
   MOV   rT0,rA3
57
60
   TST   rA3
58
 
   BRMI  _exp_100
 
61
   BRMI  1f
59
62
   LDI   rB3,0x42
60
63
   LDI   rB2,0xB1
61
64
   LDI   rB1,0x72
63
66
   CPC   rA1,rB1
64
67
   CPC   rA2,rB2
65
68
   CPC   rA3,rB3                ; compare with 88.72283935546875 = | ln(FLT_MAX) |
66
 
   BRCS  _exp_200               ; no overflow
 
69
   BRCS  2f                     ; no overflow
67
70
   RJMP  _U(__fp_nanERANGE)
68
71
 
69
 
 _exp_100: ; A < 0, check for underflow
 
72
1: ; A < 0, check for underflow
70
73
   ANDI  rA3,0x7F
71
74
   LDI   rB3,0x42
72
75
   LDI   rB2,0xAE
75
78
   CPC   rA1,rB1
76
79
   CPC   rA2,rB2
77
80
   CPC   rA3,rB3                ; compare with 87.3365478515625 = | ln(FLT_MIN) |
78
 
   BRCS  _exp_200               ; no underflow
 
81
   BRCS  2f                     ; no underflow
79
82
   RJMP  _U(__fp_zero)
80
83
 
81
 
 _exp_200:
 
84
2:
82
85
   PUSH  rT0                    ; push sign only
83
86
   LDI   rB3,0x3F
84
87
   LDI   rB2,0xB8
114
117
   SUB     rTI0,rB3     ;
115
118
   CLR     rB3
116
119
   ORI     rB2,0x80
117
 
   RJMP   _exp_300
118
 
 _exp_200_1:
 
120
   RJMP   2f
 
121
1:
119
122
   LSR    rB2
120
123
   ROR    rB1
121
124
   ROR    rB0
122
125
   ROR    rB3
123
 
 _exp_300:
 
126
2:
124
127
   DEC    rTI0
125
 
   BRPL   _exp_200_1
 
128
   BRPL   1b
126
129
                        ; now rB2::rB0:rB3 = long integer (only rB3 should be set)
127
130
   MOV    rB2,rB3
128
131
   ADD    rB3,rB3
138
141
 
139
142
        PGM_SECTION
140
143
 
141
 
        /* these constants are *no* IEEE float values:  exponent unpacked allready
142
 
         *                                              first byte : exponent
143
 
         *                                              2nd byte   : msb of mantissa with sign as bit 7
144
 
         *                                              3rd & 4th byte : mantissa
145
 
         */
146
 
 
147
144
 table_exp:  DCB 6 ; no of table entries - 1 (preload value)
148
 
             DCB 0x72, 0x65, 0x2C, 0x03     ; 0.000218555        E5 2C 02 FD 74 E4 30
149
 
             DCB 0x75, 0x22, 0x3B, 0x59     ; 0.00123773         A2 3B 59 0A 98 98 48
150
 
             DCB 0x78, 0x1E, 0xBA, 0xE0     ; 0.00968811         9E BA E0 18 C7 63 00
151
 
             DCB 0x7A, 0x63, 0x3B, 0xF4     ; 0.0554771          E3 3B F3 D9 EE 36 C8
152
 
             DCB 0x7C, 0x75, 0xFF, 0x4E     ; 0.240232           F5 FF 4D AD AC 35 08
153
 
             DCB 0x7E, 0x31, 0x72, 0x11     ; 0.693147           B1 72 11 69 BD 3D 90
154
 
             DCB 0x7F, 0x00, 0x00, 0x00     ; 1.0
 
145
             DCB 0x39, 0x65, 0x2C, 0x03     ; 0.000218555        E5 2C 02 FD 74 E4 30
 
146
             DCB 0x3A, 0xA2, 0x3B, 0x59     ; 0.00123773         A2 3B 59 0A 98 98 48
 
147
             DCB 0x3C, 0x1E, 0xBA, 0xE0     ; 0.00968811         9E BA E0 18 C7 63 00
 
148
             DCB 0x3D, 0x63, 0x3B, 0xF4     ; 0.0554771          E3 3B F3 D9 EE 36 C8
 
149
             DCB 0x3E, 0x75, 0xFF, 0x4E     ; 0.240232           F5 FF 4D AD AC 35 08
 
150
             DCB 0x3F, 0x31, 0x72, 0x11     ; 0.693147           B1 72 11 69 BD 3D 90
 
151
             DCB 0x3F, 0x80, 0x00, 0x00     ; 1.0
155
152
             DCB 0x00
156
153
 
157
 
#endif /* not DOXYGEN */
 
154
#endif /* not __DOXYGEN__ */