go to single .html
[fw/sdcc] / doc / SDCCUdoc-20.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2 <HTML>
3 <HEAD>
4  <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.7">
5  <TITLE>SDCC Compiler User Guide: Library routines.</TITLE>
6  <LINK HREF="SDCCUdoc-21.html" REL=next>
7  <LINK HREF="SDCCUdoc-19.html" REL=previous>
8  <LINK HREF="SDCCUdoc.html#toc20" REL=contents>
9 </HEAD>
10 <BODY>
11 <A HREF="SDCCUdoc-21.html">Next</A>
12 <A HREF="SDCCUdoc-19.html">Previous</A>
13 <A HREF="SDCCUdoc.html#toc20">Contents</A>
14 <HR>
15 <H2><A NAME="Library"></A> <A NAME="s20">20. Library routines.</A> </H2>
16
17 <P>The following library routines are provided for your convenience.
18 <P><B>stdio.h </B>- Contains the following functions printf &amp; sprintf these routines
19 are developed by Martijn van Balen &lt;balen@natlab.research.philips.com&gt;.
20 <P>
21 <P>
22 <PRE>
23 %[flags][width][b|B|l|L]type           flags: -        left justify output in specified field width
24  
25                  +        prefix output with +/- sign if output is signed
26  type 
27                  space    prefix output with a blank if it's a signed
28  positive value 
29           width:          specifies minimum number of characters
30  outputted for numbers 
31                           or strings. 
32                          
33  - For numbers, spaces are added on the left when needed. 
34                            
35  If width starts with a zero character, zeroes and used 
36                            
37  instead of spaces. 
38                           - For strings, spaces are are
39  added on the left or right (when 
40                             flag '-' is used)
41  when needed. 
42                           
43           b/B:            byte argument
44  (used by d, u, o, x, X) 
45           l/L:            long argument (used by d,
46  u, o, x, X)
47           type:  d        decimal number 
48                  u       
49  unsigned decimal number 
50                  o        unsigned octal number 
51                 
52  x        unsigned hexadecimal number (0-9, a-f) 
53                  X       
54  unsigned hexadecimal number (0-9, A-F) 
55                  c        character
56  
57                  s        string (generic pointer) 
58                  p       
59  generic pointer (I:data/idata, C:code, X:xdata, P:paged) 
60                 
61  f        float (still to be implemented)
62  
63 </PRE>
64 <P>Also contains a very simple version of printf (<B>printf_small</B>). This simplified
65 version of printf supports only the following formats.
66 <P>
67 <PRE>
68 format     output type     argument-type &lt;bf>
69 %d         decimal      
70  int 
71 %ld        decimal       long 
72 %hd        decimal       short/char
73  
74 %x        hexadecimal    int 
75 %lx       hexadecimal    long
76  
77 %hx       hexadecimal    short/char 
78 %o         octal         int
79  
80 %lo        octal         long 
81 %ho        octal         short/char
82  
83 %c        character      char/short 
84 %s        character     _generic
85  pointer
86  &lt;p>&lt;tt>The routine is &lt;tt>&lt;bf>very stack intesive , --stack-after-data parameter should
87  be used when using this routine, the routine also takes about 1K of code space
88  .It also expects an external function named putchar(char ) to be present (this
89  can be changed). When using the %s format the string / pointer should
90  be cast to a generic pointer. eg.
91  
92 </PRE>
93 <HR>
94 <A HREF="SDCCUdoc-21.html">Next</A>
95 <A HREF="SDCCUdoc-19.html">Previous</A>
96 <A HREF="SDCCUdoc.html#toc20">Contents</A>
97 </BODY>
98 </HTML>