Remove ldgld.c, ldgld68k.c, ldm88k.c, since these are
[deliverable/binutils-gdb.git] / gas / bignum-copy.c
CommitLineData
fecd2382
RP
1/* bignum_copy.c - copy a bignum
2 Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc.
3
4This file is part of GAS, the GNU Assembler.
5
6GAS is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
6026cd06 8the Free Software Foundation; either version 2, or (at your option)
fecd2382
RP
9any later version.
10
11GAS is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GAS; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20/* static const char rcsid[] = "$Id$"; */
21
22#include "as.h"
23
24#ifdef USG
25#define bzero(s,n) memset(s,0,n)
26#define bcopy(from,to,n) memcpy(to,from,n)
27#endif
28
29/*
30 * bignum_copy ()
31 *
32 * Copy a bignum from in to out.
33 * If the output is shorter than the input, copy lower-order littlenums.
34 * Return 0 or the number of significant littlenums dropped.
35 * Assumes littlenum arrays are densely packed: no unused chars between
36 * the littlenums. Uses bcopy() to move littlenums, and wants to
37 * know length (in chars) of the input bignum.
38 */
39
40/* void */
41int
42bignum_copy (in, in_length, out, out_length)
43 register LITTLENUM_TYPE * in;
44 register int in_length; /* in sizeof(littlenum)s */
45 register LITTLENUM_TYPE * out;
46 register int out_length; /* in sizeof(littlenum)s */
47{
48 register int significant_littlenums_dropped;
49
50 if (out_length < in_length)
51 {
52 register LITTLENUM_TYPE * p; /* -> most significant (non-zero) input littlenum. */
53
54 bcopy ((char *)in, (char *)out, out_length << LITTLENUM_SHIFT);
55 for (p = in + in_length - 1; p >= in; -- p)
56 {
57 if (* p) break;
58 }
59 significant_littlenums_dropped = p - in - in_length + 1;
60 if (significant_littlenums_dropped < 0)
61 {
62 significant_littlenums_dropped = 0;
63 }
64 }
65 else
66 {
67 bcopy ((char *)in, (char *)out, in_length << LITTLENUM_SHIFT);
68 if (out_length > in_length)
69 {
70 bzero ((char *)(out + out_length), (out_length - in_length) << LITTLENUM_SHIFT);
71 }
72 significant_littlenums_dropped = 0;
73 }
74 return (significant_littlenums_dropped);
75}
76
77/* end: bignum_copy.c */
This page took 0.037432 seconds and 4 git commands to generate.