Next Previous Contents

## 20. Library routines.

The following library routines are provided for your convenience.

stdio.h - Contains the following functions printf & sprintf these routines are developed by Martijn van Balen <balen@natlab.research.philips.com>.

    %[flags][width][b|B|l|L]type           flags: -        left justify output in specified field width

                     +        prefix output with +/- sign if output is signed
     type
                     space    prefix output with a blank if it's a signed
     positive value
              width:          specifies minimum number of characters
     outputted for numbers
                              or strings.

     - For numbers, spaces are added on the left when needed.

     If width starts with a zero character, zeroes and used

     instead of spaces.
                              - For strings, spaces are are
     added on the left or right (when
                                flag '-' is used)
     when needed.

              b/B:            byte argument
     (used by d, u, o, x, X)
              l/L:            long argument (used by d,
     u, o, x, X)
              type:  d        decimal number
                     u
     unsigned decimal number
                     o        unsigned octal number

     x        unsigned hexadecimal number (0-9, a-f)
                     X
     unsigned hexadecimal number (0-9, A-F)
                     c        character

                     s        string (generic pointer)
                     p
     generic pointer (I:data/idata, C:code, X:xdata, P:paged)

     f        float (still to be implemented)

Also contains a very simple version of printf (printf_small). This simplified version of printf supports only the following formats.

    format     output type     argument-type <bf>
    %d         decimal
     int
    %ld        decimal       long
    %hd        decimal       short/char

    %x        hexadecimal    int
    %lx       hexadecimal    long

    %hx       hexadecimal    short/char
    %o         octal         int

    %lo        octal         long
    %ho        octal         short/char

    %c        character      char/short
    %s        character     _generic
     pointer
     <p><tt>The routine is <tt><bf>very stack intesive , --stack-after-data parameter should
     be used when using this routine, the routine also takes about 1K of code space
     .It also expects an external function named putchar(char ) to be present (this
     can be changed). When using the %s format the string / pointer should
     be cast to a generic pointer. eg.

Next Previous Contents