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.
32 /* char x_ftoa(float, data char *, unsigned char, unsigned char); */
50 char x_cnvint_wrap(unsigned long num, data char *buffer)
56 movff _vv0x00, _POSTDEC1
57 movff _vv0x01, _POSTDEC1
58 movff _vv0x02, _POSTDEC1
59 movff _vv0x03, _POSTDEC1
62 movff _PLUSW2, _vv0x00
64 movff _PLUSW2, _vv0x01
66 movff _PLUSW2, _vv0x02
68 movff _PLUSW2, _vv0x03
77 /* return value is already in WREG */
79 movff _PREINC1, _vv0x03
80 movff _PREINC1, _vv0x02
81 movff _PREINC1, _vv0x01
82 movff _PREINC1, _vv0x00
86 char x_cnvfrac_wrap(unsigned long num, data char *buffer, unsigned char prec)
93 movff _vv0x00, _POSTDEC1
94 movff _vv0x01, _POSTDEC1
95 movff _vv0x02, _POSTDEC1
96 movff _vv0x03, _POSTDEC1
97 movff _vv0x04, _POSTDEC1
100 movff _PLUSW2, _vv0x00
102 movff _PLUSW2, _vv0x01
104 movff _PLUSW2, _vv0x02
106 movff _PLUSW2, _vv0x03
109 movff _PLUSW2, _FSR0L
111 movff _PLUSW2, _FSR0H
114 movff _PLUSW2, _vv0x04
118 /* return value is already in WREG */
120 movff _PREINC1, _vv0x04
121 movff _PREINC1, _vv0x03
122 movff _PREINC1, _vv0x02
123 movff _PREINC1, _vv0x01
124 movff _PREINC1, _vv0x00
135 char x_ftoa(float num, data char *buffer, unsigned char buflen, unsigned char prec)
142 union float_long f_l;
145 while(len--)buffer[len] = 0;
149 if((f_l.l & SIGNBIT) == SIGNBIT) {
155 expn = EXCESS - EXP(f_l.l); // - 24;
163 if(ll & 0x00800000UL)li |= 1;
173 len = x_cnvint_wrap(li, buffer);
175 *buffer = '0'; len = 1;
181 *buffer = '.'; len++;
184 len += x_cnvfrac_wrap(ll, buffer, 24-prec);
185 buffer[ prec ] = '\0';