f404452cc8bfb82898c1eeab1d7b3180b784ac94
[fw/sdcc] / 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 static void dummy(void) _naked
25 {
26         _asm
27         .globl  fs_normalize_a
28 fs_normalize_a:
29 #ifdef FLOAT_SHIFT_SPEEDUP
30         mov     r0, #4
31 00001$:
32         mov     a, r4
33         jnz     00003$
34         xch     a, r1
35         xch     a, r2
36         xch     a, r3
37         mov     r4, a
38         //mov   r4, ar3
39         //mov   r3, ar2
40         //mov   r2, ar1
41         //mov   r1, #0
42         mov     a, exp_a
43         add     a, #248
44         mov     exp_a, a
45         djnz    r0, 00001$
46         ret
47 #else
48         mov     a, r4
49 #endif
50 00003$:
51         mov     r0, #32
52 00005$:
53         jb      acc.7, 00006$
54         dec     exp_a
55         clr     c
56         mov     a, r1
57         rlc     a
58         mov     r1, a
59         mov     a, r2
60         rlc     a
61         mov     r2, a
62         mov     a, r3
63         rlc     a
64         mov     r3, a
65         mov     a, r4
66         rlc     a
67         mov     r4, a
68         djnz    r0, 00005$
69 00006$:
70         ret
71         _endasm;
72 }