]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gas/flonum-copy.c
* config/sh/tm-sh.h (BELIEVE_PCC_PROMOTION): Define, so that
[thirdparty/binutils-gdb.git] / gas / flonum-copy.c
1 /* flonum_copy.c - copy a flonum
2 Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc.
3
4 This file is part of GAS, the GNU Assembler.
5
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GAS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GAS; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20 #include "as.h"
21
22 #ifdef USG
23 #define bzero(s,n) memset(s,0,n)
24 #define bcopy(from,to,n) memcpy(to,from,n)
25 #endif
26
27 void
28 flonum_copy (in, out)
29 FLONUM_TYPE * in;
30 FLONUM_TYPE * out;
31 {
32 int in_length; /* 0 origin */
33 int out_length; /* 0 origin */
34
35 out -> sign = in -> sign;
36 in_length = in -> leader - in -> low;
37 if (in_length < 0)
38 {
39 out -> leader = out -> low - 1; /* 0.0 case */
40 }
41 else
42 {
43 out_length = out -> high - out -> low;
44 /*
45 * Assume no GAPS in packing of littlenums.
46 * I.e. sizeof(array) == sizeof(element) * number_of_elements.
47 */
48 if (in_length <= out_length)
49 {
50 {
51 /*
52 * For defensive programming, zero any high-order littlenums we don't need.
53 * This is destroying evidence and wasting time, so why bother???
54 */
55 if (in_length < out_length)
56 {
57 bzero ((char *)(out->low + in_length + 1), out_length - in_length);
58 }
59 }
60 bcopy ((char *)(in->low), (char *)(out->low), (int)((in_length + 1) * sizeof(LITTLENUM_TYPE)));
61 out -> exponent = in -> exponent;
62 out -> leader = in -> leader - in -> low + out -> low;
63 }
64 else
65 {
66 int shorten; /* 1-origin. Number of littlenums we drop. */
67
68 shorten = in_length - out_length;
69 /* Assume out_length >= 0 ! */
70 bcopy ((char *)(in->low + shorten),(char *)( out->low), (int)((out_length + 1) * sizeof(LITTLENUM_TYPE)));
71 out -> leader = out -> high;
72 out -> exponent = in -> exponent + shorten;
73 }
74 } /* if any significant bits */
75 }
76
77 /* end of flonum_copy.c */