Imported Upstream version 2.9.0
[debian/cc1111] / device / lib / _fsget2args.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         // arg1: passed in a,b,dph,dpl
30         // arg2: passed on stack
31         __asm
32         .globl  fsgetargs
33 fsgetargs:
34         // extract the two inputs, placing them into:
35         //      sign     exponent   mantiassa
36         //      ----     --------   ---------
37         //  a:  sign_a   exp_a     r4/r3/r2
38         //  b:  sign_b   exp_b     r7/r6/r5
39         //
40         mov     r2, dpl
41         mov     r3, dph
42         mov     c, b.7
43         rlc     a
44         mov     sign_a, c
45         jz      00001$
46         setb    b.7
47 00001$:
48         mov     exp_a, a
49         mov     r4, b
50         // now extract the 2nd parameter from the stack
51         mov     a, sp
52         add     a, #249
53         mov     r0, a
54         mov     a, @r0
55         mov     r5, a
56         inc     r0
57         mov     a, @r0
58         mov     r6, a
59         inc     r0
60         mov     b, @r0
61         inc     r0
62         mov     a, @r0
63         mov     c, b.7
64         rlc     a
65         mov     sign_b, c
66         jz      00002$
67         setb    b.7
68 00002$:
69         mov     exp_b, a
70         mov     r7, b
71         ret
72         __endasm;
73 }
74
75 #endif