Imported Upstream version 2.9.0
[debian/cc1111] / device / lib / _fsrshift.c
1 /* Floating point library in optimized assembly for 8051
2  * Copyright (c) 2004, Paul Stoffregen, paul@pjrc.com
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17  */
18
19
20
21 #define SDCC_FLOAT_LIB
22 #include <float.h>
23
24
25 #ifdef FLOAT_ASM_MCS51
26
27 static void dummy(void) __naked
28 {
29         __asm
30         .globl  fs_rshift_a
31 fs_rshift_a:
32         jz      00020$
33         mov     r0, a
34         add     a, exp_a        // adjust exponent
35         jnc     00001$
36         mov     a, #255         // don't roll over
37 00001$:
38         mov     exp_a, a
39 #ifdef FLOAT_SHIFT_SPEEDUP
40         mov     a, r0
41         add     a, #248
42         jnc     00003$
43         xch     a, r4
44         xch     a, r3
45         xch     a, r2
46         mov     r1, a
47         clr     a
48         xch     a, r4
49         //mov   r1, ar2         // avoid dependence on register bank
50         //mov   r2, ar3
51         //mov   r3, ar4
52         //mov   r4, #0
53         add     a, #248
54         jnc     00003$
55         xch     a, r3
56         xch     a, r2
57         mov     r1, a
58         clr     a
59         xch     a, r3
60         //mov   r1, ar2
61         //mov   r2, ar3
62         //mov   r3, #0
63         add     a, #248
64         jnc     00003$
65         xch     a, r2
66         mov     r1, a
67         clr     a
68         xch     a, r2
69         //mov   r1, ar2
70         //mov   r2, #0
71         add     a, #248
72         jnc     00003$
73         mov     r1, #0
74         ret
75 00003$:
76         add     a, #8
77         jz      00020$
78         mov     r0, a
79 #endif
80 00005$:
81         clr     c
82         mov     a, r4
83         rrc     a
84         mov     r4, a
85         mov     a, r3
86         rrc     a
87         mov     r3, a
88         mov     a, r2
89         rrc     a
90         mov     r2, a
91         mov     a, r1
92         rrc     a
93         mov     r1, a
94         djnz    r0, 00005$
95 00020$:
96         ret
97         __endasm;
98 }
99
100 #endif