Imported Upstream version 2.9.0
[debian/cc1111] / device / lib / _fsnormalize.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_normalize_a
31 fs_normalize_a:
32 #ifdef FLOAT_SHIFT_SPEEDUP
33         mov     r0, #4
34 00001$:
35         mov     a, r4
36         jnz     00003$
37         xch     a, r1
38         xch     a, r2
39         xch     a, r3
40         mov     r4, a
41         //mov   r4, ar3
42         //mov   r3, ar2
43         //mov   r2, ar1
44         //mov   r1, #0
45         mov     a, exp_a
46         add     a, #248
47         mov     exp_a, a
48         djnz    r0, 00001$
49         ret
50 #else
51         mov     a, r4
52 #endif
53 00003$:
54         mov     r0, #32
55 00005$:
56         jb      acc.7, 00006$
57         dec     exp_a
58         clr     c
59         mov     a, r1
60         rlc     a
61         mov     r1, a
62         mov     a, r2
63         rlc     a
64         mov     r2, a
65         mov     a, r3
66         rlc     a
67         mov     r3, a
68         mov     a, r4
69         rlc     a
70         mov     r4, a
71         djnz    r0, 00005$
72 00006$:
73         ret
74         __endasm;
75 }
76
77 #endif