1 /*-----------------------------------------------------------------
2 printfl.c - source file for reduced version of printf
4 Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999)
6 This library is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Library General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 In other words, you are welcome to use, share and improve this program.
21 You are forbidden to forbid anyone else to use, share and improve
22 what you give them. Help stamp out software-hoarding!
24 2001060401: Improved by was@icb.snz.chel.su
25 -------------------------------------------------------------------------*/
28 /* following formats are supported :-
29 format output type argument-type
40 %s character generic pointer
51 static data char radix ;
52 static bit long_flag = 0;
53 static bit string_flag =0;
54 static bit char_flag = 0;
55 static char * data str ;
58 /* This great loop fails with the ds390 port (2003-01-13).
60 At the beginning resp. end of the loop the compiler inserts a "push ar2"
61 resp. "pop ar2", which badly interfers with the push/pop in the source.
63 Library functions should be rock solid and portable. There's an _ltoa in
64 the library, so let's use it and don't reinvent the wheel.
69 #if NICE_LIFO_IMPLEMENTATION_BUT_NOT_PORTABLE
70 static data volatile char ch;
73 static void pval(void)
79 if (val < 0 && radix != 16)
84 else { sign = 0; lval = val;}
97 if(radix != 16) ch = (lval % radix) + '0';
98 else ch = "0123456789ABCDEF"[(unsigned char)lval & 0x0f];
99 _asm push _ch _endasm;
102 // This only looks more efficient, but isn't. see the .map
103 ch = (lval % radix) + '0';
105 _asm push _ch _endasm;
113 _asm push _ch _endasm;
117 _asm pop _ch _endasm;
123 void printf_small (char * fmt, ... ) reentrant
129 for (; *fmt ; fmt++ ) {
131 long_flag = string_flag = char_flag = 0;
162 str = va_arg(ap, char *);
163 while (*str) putchar(*str++);
168 val = va_arg(ap,long);
171 val = va_arg(ap,char);
173 val = va_arg(ap,int);
175 #if NICE_LIFO_IMPLEMENTATION_BUT_NOT_PORTABLE
180 static char data buffer[12], c;
182 _ltoa (val, buffer, radix);
184 while ((c = *str++) != '\0')