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