Imported Upstream version 2.9.0
[debian/cc1111] / device / lib / _fscmp.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 #define SDCC_FLOAT_LIB
21 #include <float.h>
22
23
24 #ifdef FLOAT_ASM_MCS51
25
26 static void dummy(void) __naked
27 {
28         __asm
29
30         .globl  fs_compare_uint32
31 fs_compare_uint32:
32         mov     r1, #1
33         mov     r2, dpl
34         mov     a, @r0
35         mov     dpl, r7
36         cjne    a, dpl, compare32_done
37         dec     r0
38         mov     a, @r0
39         cjne    a, b, compare32_done
40         dec     r0
41         mov     a, @r0
42         cjne    a, dph, compare32_done
43         dec     r0
44         mov     a, @r0
45         mov     dpl, r2
46         cjne    a, dpl, compare32_done
47         mov     r1, #0
48 compare32_done:
49         ret
50
51
52         .globl  fs_check_negative_zeros
53 fs_check_negative_zeros:
54 a_check:
55         cjne    a, #0x80, a_not_neg_zero
56         mov     a, b
57         jnz     a_not_neg_zero_cleanup
58         mov     a, dph
59         jnz     a_not_neg_zero_cleanup
60         mov     a, dpl
61         jnz     a_not_neg_zero_cleanup
62         mov     r7, #0
63 a_not_neg_zero_cleanup:
64         mov     a, r7
65 a_not_neg_zero:
66
67 b_check:
68         cjne    @r0, #0x80, b_not_neg_zero
69         dec     r0
70         cjne    @r0, #0, b_not_neg_zero_cleanup_1
71         dec     r0
72         cjne    @r0, #0, b_not_neg_zero_cleanup_2
73         dec     r0
74         cjne    @r0, #0, b_not_neg_zero_cleanup_3
75         inc     r0
76         inc     r0
77         inc     r0
78         mov     @r0, #0
79         ret
80 b_not_neg_zero_cleanup_3:
81         inc     r0
82 b_not_neg_zero_cleanup_2:
83         inc     r0
84 b_not_neg_zero_cleanup_1:
85         inc     r0
86 b_not_neg_zero:
87         ret
88
89         __endasm;
90 }
91
92 #endif