Imported Upstream version 2.9.0
[debian/cc1111] / device / lib / _uchar2fs.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 // float long __uchar2fs (float x)
27 static void dummy(void) __naked
28 {
29         __asm
30         .globl  ___uchar2fs
31 ___uchar2fs:
32         clr     a
33         mov     r4, dpl
34         mov     r3, a
35         mov     r2, a
36         mov     r1, a
37         mov     a, #134
38         ljmp    ulong2fs_doit
39         __endasm;
40 }
41
42 #else
43
44 /* convert unsigned char to float */
45 float __uchar2fs (unsigned char uc) {
46   return __ulong2fs(uc);
47 }
48
49 #endif