1 /*-------------------------------------------------------------------------
2 _ulonglong2fs.c - Floating point library in optimized assembly for 8051
4 Copyright (c) 2004, Paul Stoffregen, paul@pjrc.com
7 This library is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this library; see the file COPYING. If not, write to the
19 Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
22 As a special exception, if you link this library with other files,
23 some of which are compiled with SDCC, to produce an executable,
24 this library does not by itself cause the resulting executable to
25 be covered by the GNU General Public License. This exception does
26 not however invalidate any other reasons why the executable file
27 might be covered by the GNU General Public License.
28 -------------------------------------------------------------------------*/
31 #define __SDCC_FLOAT_LIB
36 ** libgcc support for software floating point.
37 ** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved.
38 ** Permission is granted to do *anything* you want with this file,
39 ** commercial or otherwise, provided this message remains intact. So there!
40 ** I would appreciate receiving any updates/patches/changes that anyone
41 ** makes, and am willing to be the repository for said changes (am I
42 ** making a big mistake?).
45 ** Pipeline Associates, Inc.
46 ** pipeline!phw@motown.com or
47 ** sun!pipeline!phw or
48 ** uunet!motown!pipeline!phw
51 /* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
52 /* (c)2022: fix sdcc bug #3276 -- Benedikt Freisen */
53 /* ported from ulong to ulonglong -- Benedikt Freisen */
61 float __ulonglong2fs (unsigned long long a
) __SDCC_FLOAT_NONBANKED
63 unsigned char exp
= (unsigned char)24 + (unsigned char)EXCESS
;
64 volatile union float_long fl
;
71 if (a
== 0xffffffffffffffffull
)
73 return 18446744073709551616.0f
;
84 // we lose accuracy here
92 /* pack up and go home */
93 fl
.l
= PACK(0,(unsigned long)exp
, a
);