xref: /openbsd-src/gnu/usr.bin/binutils-2.17/gas/config/atof-vax.c (revision 3d8817e467ea46cf4772788d6804dd293abfb01a)
1*3d8817e4Smiod /* atof_vax.c - turn a Flonum into a VAX floating point number
2*3d8817e4Smiod    Copyright 1987, 1992, 1993, 1995, 1997, 1999, 2000, 2005
3*3d8817e4Smiod    Free Software Foundation, Inc.
4*3d8817e4Smiod 
5*3d8817e4Smiod    This file is part of GAS, the GNU Assembler.
6*3d8817e4Smiod 
7*3d8817e4Smiod    GAS is free software; you can redistribute it and/or modify
8*3d8817e4Smiod    it under the terms of the GNU General Public License as published by
9*3d8817e4Smiod    the Free Software Foundation; either version 2, or (at your option)
10*3d8817e4Smiod    any later version.
11*3d8817e4Smiod 
12*3d8817e4Smiod    GAS is distributed in the hope that it will be useful,
13*3d8817e4Smiod    but WITHOUT ANY WARRANTY; without even the implied warranty of
14*3d8817e4Smiod    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*3d8817e4Smiod    GNU General Public License for more details.
16*3d8817e4Smiod 
17*3d8817e4Smiod    You should have received a copy of the GNU General Public License
18*3d8817e4Smiod    along with GAS; see the file COPYING.  If not, write to the Free
19*3d8817e4Smiod    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
20*3d8817e4Smiod    02110-1301, USA.  */
21*3d8817e4Smiod 
22*3d8817e4Smiod #include "as.h"
23*3d8817e4Smiod 
24*3d8817e4Smiod /* Precision in LittleNums.  */
25*3d8817e4Smiod #define MAX_PRECISION	8
26*3d8817e4Smiod #define H_PRECISION	8
27*3d8817e4Smiod #define G_PRECISION	4
28*3d8817e4Smiod #define D_PRECISION	4
29*3d8817e4Smiod #define F_PRECISION	2
30*3d8817e4Smiod 
31*3d8817e4Smiod /* Length in LittleNums of guard bits.  */
32*3d8817e4Smiod #define GUARD		2
33*3d8817e4Smiod 
34*3d8817e4Smiod int flonum_gen2vax (int, FLONUM_TYPE *, LITTLENUM_TYPE *);
35*3d8817e4Smiod 
36*3d8817e4Smiod /* Number of chars in flonum type 'letter'.  */
37*3d8817e4Smiod 
38*3d8817e4Smiod static int
atof_vax_sizeof(int letter)39*3d8817e4Smiod atof_vax_sizeof (int letter)
40*3d8817e4Smiod {
41*3d8817e4Smiod   int return_value;
42*3d8817e4Smiod 
43*3d8817e4Smiod   /* Permitting uppercase letters is probably a bad idea.
44*3d8817e4Smiod      Please use only lower-cased letters in case the upper-cased
45*3d8817e4Smiod      ones become unsupported!  */
46*3d8817e4Smiod   switch (letter)
47*3d8817e4Smiod     {
48*3d8817e4Smiod     case 'f':
49*3d8817e4Smiod     case 'F':
50*3d8817e4Smiod       return_value = 4;
51*3d8817e4Smiod       break;
52*3d8817e4Smiod 
53*3d8817e4Smiod     case 'd':
54*3d8817e4Smiod     case 'D':
55*3d8817e4Smiod     case 'g':
56*3d8817e4Smiod     case 'G':
57*3d8817e4Smiod       return_value = 8;
58*3d8817e4Smiod       break;
59*3d8817e4Smiod 
60*3d8817e4Smiod     case 'h':
61*3d8817e4Smiod     case 'H':
62*3d8817e4Smiod       return_value = 16;
63*3d8817e4Smiod       break;
64*3d8817e4Smiod 
65*3d8817e4Smiod     default:
66*3d8817e4Smiod       return_value = 0;
67*3d8817e4Smiod       break;
68*3d8817e4Smiod     }
69*3d8817e4Smiod 
70*3d8817e4Smiod   return return_value;
71*3d8817e4Smiod }
72*3d8817e4Smiod 
73*3d8817e4Smiod static const long mask[] =
74*3d8817e4Smiod {
75*3d8817e4Smiod   0x00000000,
76*3d8817e4Smiod   0x00000001,
77*3d8817e4Smiod   0x00000003,
78*3d8817e4Smiod   0x00000007,
79*3d8817e4Smiod   0x0000000f,
80*3d8817e4Smiod   0x0000001f,
81*3d8817e4Smiod   0x0000003f,
82*3d8817e4Smiod   0x0000007f,
83*3d8817e4Smiod   0x000000ff,
84*3d8817e4Smiod   0x000001ff,
85*3d8817e4Smiod   0x000003ff,
86*3d8817e4Smiod   0x000007ff,
87*3d8817e4Smiod   0x00000fff,
88*3d8817e4Smiod   0x00001fff,
89*3d8817e4Smiod   0x00003fff,
90*3d8817e4Smiod   0x00007fff,
91*3d8817e4Smiod   0x0000ffff,
92*3d8817e4Smiod   0x0001ffff,
93*3d8817e4Smiod   0x0003ffff,
94*3d8817e4Smiod   0x0007ffff,
95*3d8817e4Smiod   0x000fffff,
96*3d8817e4Smiod   0x001fffff,
97*3d8817e4Smiod   0x003fffff,
98*3d8817e4Smiod   0x007fffff,
99*3d8817e4Smiod   0x00ffffff,
100*3d8817e4Smiod   0x01ffffff,
101*3d8817e4Smiod   0x03ffffff,
102*3d8817e4Smiod   0x07ffffff,
103*3d8817e4Smiod   0x0fffffff,
104*3d8817e4Smiod   0x1fffffff,
105*3d8817e4Smiod   0x3fffffff,
106*3d8817e4Smiod   0x7fffffff,
107*3d8817e4Smiod   0xffffffff
108*3d8817e4Smiod };
109*3d8817e4Smiod 
110*3d8817e4Smiod 
111*3d8817e4Smiod /* Shared between flonum_gen2vax and next_bits.  */
112*3d8817e4Smiod static int bits_left_in_littlenum;
113*3d8817e4Smiod static LITTLENUM_TYPE *littlenum_pointer;
114*3d8817e4Smiod static LITTLENUM_TYPE *littlenum_end;
115*3d8817e4Smiod 
116*3d8817e4Smiod static int
next_bits(int number_of_bits)117*3d8817e4Smiod next_bits (int number_of_bits)
118*3d8817e4Smiod {
119*3d8817e4Smiod   int return_value;
120*3d8817e4Smiod 
121*3d8817e4Smiod   if (littlenum_pointer < littlenum_end)
122*3d8817e4Smiod     return 0;
123*3d8817e4Smiod   if (number_of_bits >= bits_left_in_littlenum)
124*3d8817e4Smiod     {
125*3d8817e4Smiod       return_value = mask[bits_left_in_littlenum] & *littlenum_pointer;
126*3d8817e4Smiod       number_of_bits -= bits_left_in_littlenum;
127*3d8817e4Smiod       return_value <<= number_of_bits;
128*3d8817e4Smiod       bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS - number_of_bits;
129*3d8817e4Smiod       littlenum_pointer--;
130*3d8817e4Smiod       if (littlenum_pointer >= littlenum_end)
131*3d8817e4Smiod 	return_value |= ((*littlenum_pointer) >> (bits_left_in_littlenum)) & mask[number_of_bits];
132*3d8817e4Smiod     }
133*3d8817e4Smiod   else
134*3d8817e4Smiod     {
135*3d8817e4Smiod       bits_left_in_littlenum -= number_of_bits;
136*3d8817e4Smiod       return_value = mask[number_of_bits] & ((*littlenum_pointer) >> bits_left_in_littlenum);
137*3d8817e4Smiod     }
138*3d8817e4Smiod   return return_value;
139*3d8817e4Smiod }
140*3d8817e4Smiod 
141*3d8817e4Smiod static void
make_invalid_floating_point_number(LITTLENUM_TYPE * words)142*3d8817e4Smiod make_invalid_floating_point_number (LITTLENUM_TYPE *words)
143*3d8817e4Smiod {
144*3d8817e4Smiod   *words = 0x8000;		/* Floating Reserved Operand Code.  */
145*3d8817e4Smiod }
146*3d8817e4Smiod 
147*3d8817e4Smiod 
148*3d8817e4Smiod static int			/* 0 means letter is OK.  */
what_kind_of_float(int letter,int * precisionP,long * exponent_bitsP)149*3d8817e4Smiod what_kind_of_float (int letter,			/* In: lowercase please. What kind of float?  */
150*3d8817e4Smiod 		    int *precisionP,		/* Number of 16-bit words in the float.  */
151*3d8817e4Smiod 		    long *exponent_bitsP)	/* Number of exponent bits.  */
152*3d8817e4Smiod {
153*3d8817e4Smiod   int retval;
154*3d8817e4Smiod 
155*3d8817e4Smiod   retval = 0;
156*3d8817e4Smiod   switch (letter)
157*3d8817e4Smiod     {
158*3d8817e4Smiod     case 'f':
159*3d8817e4Smiod       *precisionP = F_PRECISION;
160*3d8817e4Smiod       *exponent_bitsP = 8;
161*3d8817e4Smiod       break;
162*3d8817e4Smiod 
163*3d8817e4Smiod     case 'd':
164*3d8817e4Smiod       *precisionP = D_PRECISION;
165*3d8817e4Smiod       *exponent_bitsP = 8;
166*3d8817e4Smiod       break;
167*3d8817e4Smiod 
168*3d8817e4Smiod     case 'g':
169*3d8817e4Smiod       *precisionP = G_PRECISION;
170*3d8817e4Smiod       *exponent_bitsP = 11;
171*3d8817e4Smiod       break;
172*3d8817e4Smiod 
173*3d8817e4Smiod     case 'h':
174*3d8817e4Smiod       *precisionP = H_PRECISION;
175*3d8817e4Smiod       *exponent_bitsP = 15;
176*3d8817e4Smiod       break;
177*3d8817e4Smiod 
178*3d8817e4Smiod     default:
179*3d8817e4Smiod       retval = 69;
180*3d8817e4Smiod       break;
181*3d8817e4Smiod     }
182*3d8817e4Smiod   return retval;
183*3d8817e4Smiod }
184*3d8817e4Smiod 
185*3d8817e4Smiod /* Warning: this returns 16-bit LITTLENUMs, because that is
186*3d8817e4Smiod    what the VAX thinks in. It is up to the caller to figure
187*3d8817e4Smiod    out any alignment problems and to conspire for the bytes/word
188*3d8817e4Smiod    to be emitted in the right order. Bigendians beware!  */
189*3d8817e4Smiod 
190*3d8817e4Smiod static char *
atof_vax(char * str,int what_kind,LITTLENUM_TYPE * words)191*3d8817e4Smiod atof_vax (char *str,			/* Text to convert to binary.  */
192*3d8817e4Smiod 	  int what_kind,		/* 'd', 'f', 'g', 'h'  */
193*3d8817e4Smiod 	  LITTLENUM_TYPE *words)	/* Build the binary here.  */
194*3d8817e4Smiod {
195*3d8817e4Smiod   FLONUM_TYPE f;
196*3d8817e4Smiod   LITTLENUM_TYPE bits[MAX_PRECISION + MAX_PRECISION + GUARD];
197*3d8817e4Smiod   /* Extra bits for zeroed low-order bits.
198*3d8817e4Smiod      The 1st MAX_PRECISION are zeroed,
199*3d8817e4Smiod      the last contain flonum bits.  */
200*3d8817e4Smiod   char *return_value;
201*3d8817e4Smiod   int precision;		/* Number of 16-bit words in the format.  */
202*3d8817e4Smiod   long exponent_bits;
203*3d8817e4Smiod 
204*3d8817e4Smiod   return_value = str;
205*3d8817e4Smiod   f.low = bits + MAX_PRECISION;
206*3d8817e4Smiod   f.high = NULL;
207*3d8817e4Smiod   f.leader = NULL;
208*3d8817e4Smiod   f.exponent = 0;
209*3d8817e4Smiod   f.sign = '\0';
210*3d8817e4Smiod 
211*3d8817e4Smiod   if (what_kind_of_float (what_kind, &precision, &exponent_bits))
212*3d8817e4Smiod     {
213*3d8817e4Smiod       return_value = NULL;
214*3d8817e4Smiod       make_invalid_floating_point_number (words);
215*3d8817e4Smiod     }
216*3d8817e4Smiod 
217*3d8817e4Smiod   if (return_value)
218*3d8817e4Smiod     {
219*3d8817e4Smiod       memset (bits, '\0', sizeof (LITTLENUM_TYPE) * MAX_PRECISION);
220*3d8817e4Smiod 
221*3d8817e4Smiod       /* Use more LittleNums than seems
222*3d8817e4Smiod          necessary: the highest flonum may have
223*3d8817e4Smiod          15 leading 0 bits, so could be useless.  */
224*3d8817e4Smiod       f.high = f.low + precision - 1 + GUARD;
225*3d8817e4Smiod 
226*3d8817e4Smiod       if (atof_generic (&return_value, ".", "eE", &f))
227*3d8817e4Smiod 	{
228*3d8817e4Smiod 	  make_invalid_floating_point_number (words);
229*3d8817e4Smiod 	  return_value = NULL;
230*3d8817e4Smiod 	}
231*3d8817e4Smiod       else if (flonum_gen2vax (what_kind, &f, words))
232*3d8817e4Smiod 	return_value = NULL;
233*3d8817e4Smiod     }
234*3d8817e4Smiod 
235*3d8817e4Smiod   return return_value;
236*3d8817e4Smiod }
237*3d8817e4Smiod 
238*3d8817e4Smiod /* In: a flonum, a vax floating point format.
239*3d8817e4Smiod    Out: a vax floating-point bit pattern.  */
240*3d8817e4Smiod 
241*3d8817e4Smiod int
flonum_gen2vax(int format_letter,FLONUM_TYPE * f,LITTLENUM_TYPE * words)242*3d8817e4Smiod flonum_gen2vax (int format_letter,	/* One of 'd' 'f' 'g' 'h'.  */
243*3d8817e4Smiod 		FLONUM_TYPE *f,
244*3d8817e4Smiod 		LITTLENUM_TYPE *words)	/* Deliver answer here.  */
245*3d8817e4Smiod {
246*3d8817e4Smiod   LITTLENUM_TYPE *lp;
247*3d8817e4Smiod   int precision;
248*3d8817e4Smiod   long exponent_bits;
249*3d8817e4Smiod   int return_value;		/* 0 == OK.  */
250*3d8817e4Smiod 
251*3d8817e4Smiod   return_value = what_kind_of_float (format_letter, &precision, &exponent_bits);
252*3d8817e4Smiod 
253*3d8817e4Smiod   if (return_value != 0)
254*3d8817e4Smiod     make_invalid_floating_point_number (words);
255*3d8817e4Smiod 
256*3d8817e4Smiod   else
257*3d8817e4Smiod     {
258*3d8817e4Smiod       if (f->low > f->leader)
259*3d8817e4Smiod 	/* 0.0e0 seen.  */
260*3d8817e4Smiod 	memset (words, '\0', sizeof (LITTLENUM_TYPE) * precision);
261*3d8817e4Smiod 
262*3d8817e4Smiod       else
263*3d8817e4Smiod 	{
264*3d8817e4Smiod 	  long exponent_1;
265*3d8817e4Smiod 	  long exponent_2;
266*3d8817e4Smiod 	  long exponent_3;
267*3d8817e4Smiod 	  long exponent_4;
268*3d8817e4Smiod 	  int exponent_skippage;
269*3d8817e4Smiod 	  LITTLENUM_TYPE word1;
270*3d8817e4Smiod 
271*3d8817e4Smiod 	  /* JF: Deal with new Nan, +Inf and -Inf codes.  */
272*3d8817e4Smiod 	  if (f->sign != '-' && f->sign != '+')
273*3d8817e4Smiod 	    {
274*3d8817e4Smiod 	      make_invalid_floating_point_number (words);
275*3d8817e4Smiod 	      return return_value;
276*3d8817e4Smiod 	    }
277*3d8817e4Smiod 
278*3d8817e4Smiod 	  /* All vaxen floating_point formats (so far) have:
279*3d8817e4Smiod 	     Bit 15 is sign bit.
280*3d8817e4Smiod 	     Bits 14:n are excess-whatever exponent.
281*3d8817e4Smiod 	     Bits n-1:0 (if any) are most significant bits of fraction.
282*3d8817e4Smiod 	     Bits 15:0 of the next word are the next most significant bits.
283*3d8817e4Smiod 	     And so on for each other word.
284*3d8817e4Smiod 
285*3d8817e4Smiod 	     All this to be compatible with a KF11?? (Which is still faster
286*3d8817e4Smiod 	     than lots of vaxen I can think of, but it also has higher
287*3d8817e4Smiod 	     maintenance costs ... sigh).
288*3d8817e4Smiod 
289*3d8817e4Smiod 	     So we need: number of bits of exponent, number of bits of
290*3d8817e4Smiod 	     mantissa.  */
291*3d8817e4Smiod 
292*3d8817e4Smiod 	  bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS;
293*3d8817e4Smiod 	  littlenum_pointer = f->leader;
294*3d8817e4Smiod 	  littlenum_end = f->low;
295*3d8817e4Smiod 	  /* Seek (and forget) 1st significant bit.  */
296*3d8817e4Smiod 	  for (exponent_skippage = 0;
297*3d8817e4Smiod 	       !next_bits (1);
298*3d8817e4Smiod 	       exponent_skippage++);;
299*3d8817e4Smiod 
300*3d8817e4Smiod 	  exponent_1 = f->exponent + f->leader + 1 - f->low;
301*3d8817e4Smiod 	  /* Radix LITTLENUM_RADIX, point just higher than f->leader.  */
302*3d8817e4Smiod 	  exponent_2 = exponent_1 * LITTLENUM_NUMBER_OF_BITS;
303*3d8817e4Smiod 	  /* Radix 2.  */
304*3d8817e4Smiod 	  exponent_3 = exponent_2 - exponent_skippage;
305*3d8817e4Smiod 	  /* Forget leading zeros, forget 1st bit.  */
306*3d8817e4Smiod 	  exponent_4 = exponent_3 + (1 << (exponent_bits - 1));
307*3d8817e4Smiod 	  /* Offset exponent.  */
308*3d8817e4Smiod 
309*3d8817e4Smiod 	  if (exponent_4 & ~mask[exponent_bits])
310*3d8817e4Smiod 	    {
311*3d8817e4Smiod 	      /* Exponent overflow. Lose immediately.  */
312*3d8817e4Smiod 	      make_invalid_floating_point_number (words);
313*3d8817e4Smiod 
314*3d8817e4Smiod 	      /* We leave return_value alone: admit we read the
315*3d8817e4Smiod 	         number, but return a floating exception
316*3d8817e4Smiod 	         because we can't encode the number.  */
317*3d8817e4Smiod 	    }
318*3d8817e4Smiod 	  else
319*3d8817e4Smiod 	    {
320*3d8817e4Smiod 	      lp = words;
321*3d8817e4Smiod 
322*3d8817e4Smiod 	      /* Word 1. Sign, exponent and perhaps high bits.
323*3d8817e4Smiod 	         Assume 2's complement integers.  */
324*3d8817e4Smiod 	      word1 = (((exponent_4 & mask[exponent_bits]) << (15 - exponent_bits))
325*3d8817e4Smiod 		       | ((f->sign == '+') ? 0 : 0x8000)
326*3d8817e4Smiod 		       | next_bits (15 - exponent_bits));
327*3d8817e4Smiod 	      *lp++ = word1;
328*3d8817e4Smiod 
329*3d8817e4Smiod 	      /* The rest of the words are just mantissa bits.  */
330*3d8817e4Smiod 	      for (; lp < words + precision; lp++)
331*3d8817e4Smiod 		*lp = next_bits (LITTLENUM_NUMBER_OF_BITS);
332*3d8817e4Smiod 
333*3d8817e4Smiod 	      if (next_bits (1))
334*3d8817e4Smiod 		{
335*3d8817e4Smiod 		  /* Since the NEXT bit is a 1, round UP the mantissa.
336*3d8817e4Smiod 		     The cunning design of these hidden-1 floats permits
337*3d8817e4Smiod 		     us to let the mantissa overflow into the exponent, and
338*3d8817e4Smiod 		     it 'does the right thing'. However, we lose if the
339*3d8817e4Smiod 		     highest-order bit of the lowest-order word flips.
340*3d8817e4Smiod 		     Is that clear?  */
341*3d8817e4Smiod 		  unsigned long carry;
342*3d8817e4Smiod 
343*3d8817e4Smiod 		  /*
344*3d8817e4Smiod 		    #if (sizeof(carry)) < ((sizeof(bits[0]) * BITS_PER_CHAR) + 2)
345*3d8817e4Smiod 		    Please allow at least 1 more bit in carry than is in a LITTLENUM.
346*3d8817e4Smiod 		    We need that extra bit to hold a carry during a LITTLENUM carry
347*3d8817e4Smiod 		    propagation. Another extra bit (kept 0) will assure us that we
348*3d8817e4Smiod 		    don't get a sticky sign bit after shifting right, and that
349*3d8817e4Smiod 		    permits us to propagate the carry without any masking of bits.
350*3d8817e4Smiod 		    #endif   */
351*3d8817e4Smiod 		  for (carry = 1, lp--;
352*3d8817e4Smiod 		       carry && (lp >= words);
353*3d8817e4Smiod 		       lp--)
354*3d8817e4Smiod 		    {
355*3d8817e4Smiod 		      carry = *lp + carry;
356*3d8817e4Smiod 		      *lp = carry;
357*3d8817e4Smiod 		      carry >>= LITTLENUM_NUMBER_OF_BITS;
358*3d8817e4Smiod 		    }
359*3d8817e4Smiod 
360*3d8817e4Smiod 		  if ((word1 ^ *words) & (1 << (LITTLENUM_NUMBER_OF_BITS - 1)))
361*3d8817e4Smiod 		    {
362*3d8817e4Smiod 		      make_invalid_floating_point_number (words);
363*3d8817e4Smiod 		      /* We leave return_value alone: admit we read the
364*3d8817e4Smiod 		         number, but return a floating exception
365*3d8817e4Smiod 		         because we can't encode the number.  */
366*3d8817e4Smiod 		    }
367*3d8817e4Smiod 		}
368*3d8817e4Smiod 	    }
369*3d8817e4Smiod 	}
370*3d8817e4Smiod     }
371*3d8817e4Smiod   return return_value;
372*3d8817e4Smiod }
373*3d8817e4Smiod 
374*3d8817e4Smiod /* JF this used to be in vax.c but this looks like a better place for it.  */
375*3d8817e4Smiod 
376*3d8817e4Smiod /* In:	input_line_pointer->the 1st character of a floating-point
377*3d8817e4Smiod   		number.
378*3d8817e4Smiod   	1 letter denoting the type of statement that wants a
379*3d8817e4Smiod   		binary floating point number returned.
380*3d8817e4Smiod   	Address of where to build floating point literal.
381*3d8817e4Smiod   		Assumed to be 'big enough'.
382*3d8817e4Smiod   	Address of where to return size of literal (in chars).
383*3d8817e4Smiod 
384*3d8817e4Smiod    Out:	Input_line_pointer->of next char after floating number.
385*3d8817e4Smiod   	Error message, or 0.
386*3d8817e4Smiod   	Floating point literal.
387*3d8817e4Smiod   	Number of chars we used for the literal.  */
388*3d8817e4Smiod 
389*3d8817e4Smiod #define MAXIMUM_NUMBER_OF_LITTLENUMS  8 	/* For .hfloats.  */
390*3d8817e4Smiod 
391*3d8817e4Smiod char *
md_atof(int what_statement_type,char * literalP,int * sizeP)392*3d8817e4Smiod md_atof (int what_statement_type,
393*3d8817e4Smiod 	 char *literalP,
394*3d8817e4Smiod 	 int *sizeP)
395*3d8817e4Smiod {
396*3d8817e4Smiod   LITTLENUM_TYPE words[MAXIMUM_NUMBER_OF_LITTLENUMS];
397*3d8817e4Smiod   char kind_of_float;
398*3d8817e4Smiod   int number_of_chars;
399*3d8817e4Smiod   LITTLENUM_TYPE *littlenumP;
400*3d8817e4Smiod 
401*3d8817e4Smiod   switch (what_statement_type)
402*3d8817e4Smiod     {
403*3d8817e4Smiod     case 'F':
404*3d8817e4Smiod     case 'f':
405*3d8817e4Smiod       kind_of_float = 'f';
406*3d8817e4Smiod       break;
407*3d8817e4Smiod 
408*3d8817e4Smiod     case 'D':
409*3d8817e4Smiod     case 'd':
410*3d8817e4Smiod       kind_of_float = 'd';
411*3d8817e4Smiod       break;
412*3d8817e4Smiod 
413*3d8817e4Smiod     case 'g':
414*3d8817e4Smiod       kind_of_float = 'g';
415*3d8817e4Smiod       break;
416*3d8817e4Smiod 
417*3d8817e4Smiod     case 'h':
418*3d8817e4Smiod       kind_of_float = 'h';
419*3d8817e4Smiod       break;
420*3d8817e4Smiod 
421*3d8817e4Smiod     default:
422*3d8817e4Smiod       kind_of_float = 0;
423*3d8817e4Smiod       break;
424*3d8817e4Smiod     };
425*3d8817e4Smiod 
426*3d8817e4Smiod   if (kind_of_float)
427*3d8817e4Smiod     {
428*3d8817e4Smiod       LITTLENUM_TYPE *limit;
429*3d8817e4Smiod 
430*3d8817e4Smiod       input_line_pointer = atof_vax (input_line_pointer,
431*3d8817e4Smiod 				     kind_of_float,
432*3d8817e4Smiod 				     words);
433*3d8817e4Smiod       /* The atof_vax() builds up 16-bit numbers.
434*3d8817e4Smiod          Since the assembler may not be running on
435*3d8817e4Smiod          a little-endian machine, be very careful about
436*3d8817e4Smiod          converting words to chars.  */
437*3d8817e4Smiod       number_of_chars = atof_vax_sizeof (kind_of_float);
438*3d8817e4Smiod       know (number_of_chars <= MAXIMUM_NUMBER_OF_LITTLENUMS * sizeof (LITTLENUM_TYPE));
439*3d8817e4Smiod       limit = words + (number_of_chars / sizeof (LITTLENUM_TYPE));
440*3d8817e4Smiod       for (littlenumP = words; littlenumP < limit; littlenumP++)
441*3d8817e4Smiod 	{
442*3d8817e4Smiod 	  md_number_to_chars (literalP, *littlenumP, sizeof (LITTLENUM_TYPE));
443*3d8817e4Smiod 	  literalP += sizeof (LITTLENUM_TYPE);
444*3d8817e4Smiod 	};
445*3d8817e4Smiod     }
446*3d8817e4Smiod   else
447*3d8817e4Smiod     number_of_chars = 0;
448*3d8817e4Smiod 
449*3d8817e4Smiod   *sizeP = number_of_chars;
450*3d8817e4Smiod   return kind_of_float ? NULL : _("Bad call to md_atof()");
451*3d8817e4Smiod }
452