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