2003-11-22 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gas / flonum-copy.c
CommitLineData
252b5132 1/* flonum_copy.c - copy a flonum
f7e42eb4
NC
2 Copyright 1987, 1990, 1991, 1992, 1993, 2000
3 Free Software Foundation, Inc.
252b5132
RH
4
5 This file is part of GAS, the GNU Assembler.
6
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GAS 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.
16
17 You should have received a copy of the GNU General Public License
b041f888
KH
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA. */
252b5132
RH
21
22#include "as.h"
23
24void
25flonum_copy (in, out)
26 FLONUM_TYPE *in;
27 FLONUM_TYPE *out;
28{
b041f888
KH
29 unsigned int in_length; /* 0 origin */
30 unsigned int out_length; /* 0 origin */
252b5132
RH
31
32 out->sign = in->sign;
33 in_length = in->leader - in->low;
34
35 if (in->leader < in->low)
36 {
37 out->leader = out->low - 1; /* 0.0 case */
38 }
39 else
40 {
41 out_length = out->high - out->low;
b041f888
KH
42 /* Assume no GAPS in packing of littlenums.
43 I.e. sizeof(array) == sizeof(element) * number_of_elements. */
252b5132
RH
44 if (in_length <= out_length)
45 {
46 {
b041f888
KH
47 /* For defensive programming, zero any high-order
48 littlenums we don't need. This is destroying evidence
49 and wasting time, so why bother??? */
252b5132
RH
50 if (in_length < out_length)
51 {
b041f888
KH
52 memset ((char *) (out->low + in_length + 1), '\0',
53 out_length - in_length);
252b5132
RH
54 }
55 }
b041f888
KH
56 memcpy ((void *) (out->low), (void *) (in->low),
57 ((in_length + 1) * sizeof (LITTLENUM_TYPE)));
252b5132
RH
58 out->exponent = in->exponent;
59 out->leader = in->leader - in->low + out->low;
60 }
61 else
62 {
f0e652b4 63 int shorten; /* 1-origin. Number of littlenums we drop. */
252b5132
RH
64
65 shorten = in_length - out_length;
66 /* Assume out_length >= 0 ! */
b041f888
KH
67 memcpy ((void *) (out->low), (void *) (in->low + shorten),
68 ((out_length + 1) * sizeof (LITTLENUM_TYPE)));
252b5132
RH
69 out->leader = out->high;
70 out->exponent = in->exponent + shorten;
71 }
72 } /* if any significant bits */
b041f888 73}
This page took 0.268038 seconds and 4 git commands to generate.