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
32 %hd decimal short/char
35 %hx hexadecimal short/char
39 %c character char/short
40 %s character _generic pointer
50 static data volatile char ch;
51 static data char radix ;
52 static bit long_flag = 0;
53 static bit string_flag =0;
54 static bit short_flag = 0;
56 static char * data str ;
59 static void pval(void)
65 if (val < 0 && radix != 16)
70 else { sign = 0; lval = val;}
82 if(radix != 16) ch = (lval % radix) + '0';
83 else ch = "0123456789ABCDEF"[(unsigned short)lval & 0x0f];
84 _asm push _ch _endasm;
87 // This only looks more efficient, but isn't. see the .map
88 ch = (lval % radix) + '0';
90 _asm push _ch _endasm;
98 _asm push _ch _endasm;
102 _asm pop _ch _endasm;
107 void printf_small (char * fmt, ... ) reentrant
113 for (; *fmt ; fmt++ ) {
115 long_flag = string_flag = short_flag = 0;
146 str = va_arg(ap, char _generic *);
147 while (*str) putchar(*str++);
152 val = va_arg(ap,long);
155 val = va_arg(ap,short);
157 val = va_arg(ap,int);
160 else putchar((char)val);