* config/tc-i386.c (struct _i386_insn): Rename disp_reloc to reloc.
[external/binutils.git] / gas / flonum-copy.c
1 /* flonum_copy.c - copy a flonum
2    Copyright (C) 1987, 1990, 1991, 1992, 2000 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 the Free
18    Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19    02111-1307, USA.  */
20
21 #include "as.h"
22
23 void
24 flonum_copy (in, out)
25      FLONUM_TYPE *in;
26      FLONUM_TYPE *out;
27 {
28   unsigned int in_length;       /* 0 origin */
29   unsigned int out_length;      /* 0 origin */
30
31   out->sign = in->sign;
32   in_length = in->leader - in->low;
33
34   if (in->leader < in->low)
35     {
36       out->leader = out->low - 1;       /* 0.0 case */
37     }
38   else
39     {
40       out_length = out->high - out->low;
41       /* Assume no GAPS in packing of littlenums.
42          I.e. sizeof(array) == sizeof(element) * number_of_elements.  */
43       if (in_length <= out_length)
44         {
45           {
46             /* For defensive programming, zero any high-order
47                littlenums we don't need.  This is destroying evidence
48                and wasting time, so why bother???  */
49             if (in_length < out_length)
50               {
51                 memset ((char *) (out->low + in_length + 1), '\0',
52                         out_length - in_length);
53               }
54           }
55           memcpy ((void *) (out->low), (void *) (in->low),
56                   ((in_length + 1) * sizeof (LITTLENUM_TYPE)));
57           out->exponent = in->exponent;
58           out->leader = in->leader - in->low + out->low;
59         }
60       else
61         {
62           int shorten;          /* 1-origin. Number of littlenums we drop.  */
63
64           shorten = in_length - out_length;
65           /* Assume out_length >= 0 ! */
66           memcpy ((void *) (out->low), (void *) (in->low + shorten),
67                   ((out_length + 1) * sizeof (LITTLENUM_TYPE)));
68           out->leader = out->high;
69           out->exponent = in->exponent + shorten;
70         }
71     }                           /* if any significant bits */
72 }