3 * wrapper function to use _convert_float
5 * written by Vangelis Rokas, 2004, <vrokas AT otenet.gr>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 * $Id: x_ftoa.c 3835 2005-08-07 20:09:11Z tecodev $
32 /* char x_ftoa(float, __data char *, unsigned char, unsigned char); */
50 /* do not warn about unreferenced arguments/missing return values */
52 #pragma disable_warning 59
53 #pragma disable_warning 85
55 char x_cnvint_wrap(unsigned long num, __data char *buffer)
58 movff _vv0x00, _POSTDEC1
59 movff _vv0x01, _POSTDEC1
60 movff _vv0x02, _POSTDEC1
61 movff _vv0x03, _POSTDEC1
64 movff _PLUSW2, _vv0x00
66 movff _PLUSW2, _vv0x01
68 movff _PLUSW2, _vv0x02
70 movff _PLUSW2, _vv0x03
79 /* return value is already in WREG */
81 movff _PREINC1, _vv0x03
82 movff _PREINC1, _vv0x02
83 movff _PREINC1, _vv0x01
84 movff _PREINC1, _vv0x00
88 char x_cnvfrac_wrap(unsigned long num, __data char *buffer, unsigned char prec)
95 movff _vv0x00, _POSTDEC1
96 movff _vv0x01, _POSTDEC1
97 movff _vv0x02, _POSTDEC1
98 movff _vv0x03, _POSTDEC1
99 movff _vv0x04, _POSTDEC1
102 movff _PLUSW2, _vv0x00
104 movff _PLUSW2, _vv0x01
106 movff _PLUSW2, _vv0x02
108 movff _PLUSW2, _vv0x03
111 movff _PLUSW2, _FSR0L
113 movff _PLUSW2, _FSR0H
116 movff _PLUSW2, _vv0x04
120 /* return value is already in WREG */
122 movff _PREINC1, _vv0x04
123 movff _PREINC1, _vv0x03
124 movff _PREINC1, _vv0x02
125 movff _PREINC1, _vv0x01
126 movff _PREINC1, _vv0x00
137 char x_ftoa(float num, __data char *buffer, unsigned char buflen, unsigned char prec)
144 union float_long f_l;
147 while(len--)buffer[len] = 0;
151 if((f_l.l & SIGNBIT) == SIGNBIT) {
157 expn = EXCESS - EXP(f_l.l); // - 24;
165 if(ll & 0x00800000UL)li |= 1;
175 len = x_cnvint_wrap(li, buffer);
177 *buffer = '0'; len = 1;
183 *buffer = '.'; len++;
186 len += x_cnvfrac_wrap(ll, buffer, 24-prec);
187 buffer[ prec ] = '\0';