1 /*-----------------------------------------------------------------
2 printfl.c - source file for reduced version of printf
4 Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999)
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 This program 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 General Public License for more details.
16 You should have received a copy of the GNU 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!
23 -------------------------------------------------------------------------*/
25 /* following formats are supported :-
26 format output type argument-type
29 %hd decimal short/char
32 %hx hexadecimal short/char
36 %c character char/short
37 %s character _generic pointer
42 extern void putchar(char );
44 static data volatile char ch;
45 static data char radix ;
46 static bit long_flag = 0;
47 static bit string_flag =0;
48 static bit short_flag = 0;
50 static char * data str ;
53 static void pvalhex( long val)
55 volatile char sp = SP;
56 unsigned long lval = val;
65 ch = "0123456789ABCDEF"[(unsigned short)lval & 0x0f];
66 _asm push _ch _endasm;
77 static void pvaloct(long val)
96 ch = (lval % 8) + '0';
97 _asm push _ch _endasm;
103 _asm push _ch _endasm;
108 _asm pop _ch _endasm;
113 static void pvaldec(long val )
127 ch = (lval % 10) + '0';
128 _asm push _ch _endasm;
134 _asm push _ch _endasm;
139 _asm pop _ch _endasm;
144 void printf_small (char * fmt, ... ) reentrant
150 for (; *fmt ; fmt++ ) {
152 long_flag = string_flag = short_flag = 0;
183 str = va_arg(ap,char _generic *);
184 while (*str) putchar(*str++);
189 val = va_arg(ap,long);
192 val = va_arg(ap,short);
194 val = va_arg(ap,int);