320 lines
13 KiB
HTML
320 lines
13 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
|
|
|
<!--Converted with LaTeX2HTML 99.1 release (March 30, 1999)
|
|
original version by: Nikos Drakos, CBLU, University of Leeds
|
|
* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan
|
|
* with significant contributions from:
|
|
Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>4.3 <pending: this is messy and incomplete> Library Routines</TITLE>
|
|
<META NAME="description" CONTENT="4.3 <pending: this is messy and incomplete> Library Routines">
|
|
<META NAME="keywords" CONTENT="sdccman">
|
|
<META NAME="resource-type" CONTENT="document">
|
|
<META NAME="distribution" CONTENT="global">
|
|
|
|
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
|
|
<META NAME="Generator" CONTENT="LaTeX2HTML v99.1 release">
|
|
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
|
|
|
|
<LINK REL="STYLESHEET" HREF="sdccman.css">
|
|
|
|
<LINK REL="next" HREF="node42.html">
|
|
<LINK REL="previous" HREF="node40.html">
|
|
<LINK REL="up" HREF="node38.html">
|
|
<LINK REL="next" HREF="node42.html">
|
|
</HEAD>
|
|
|
|
<BODY >
|
|
<!--Navigation Panel-->
|
|
<A NAME="tex2html880"
|
|
HREF="node42.html">
|
|
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A>
|
|
<A NAME="tex2html874"
|
|
HREF="node38.html">
|
|
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A>
|
|
<A NAME="tex2html868"
|
|
HREF="node40.html">
|
|
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A>
|
|
<A NAME="tex2html876"
|
|
HREF="node1.html">
|
|
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A>
|
|
<A NAME="tex2html878"
|
|
HREF="node61.html">
|
|
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index_motif.gif"></A>
|
|
<BR>
|
|
<B> Next:</B> <A NAME="tex2html881"
|
|
HREF="node42.html">4.4 Interfacing with Assembly</A>
|
|
<B> Up:</B> <A NAME="tex2html875"
|
|
HREF="node38.html">4. SDCC Technical Data</A>
|
|
<B> Previous:</B> <A NAME="tex2html869"
|
|
HREF="node40.html">4.2 Pragmas</A>
|
|
  <B> <A NAME="tex2html877"
|
|
HREF="node1.html">Contents</A></B>
|
|
  <B> <A NAME="tex2html879"
|
|
HREF="node61.html">Index</A></B>
|
|
<BR>
|
|
<BR>
|
|
<!--End of Navigation Panel-->
|
|
|
|
<H2><A NAME="SECTION00053000000000000000">
|
|
4.3 <I><pending: this is messy and incomplete></I> Library Routines</A>
|
|
</H2>
|
|
|
|
<P>
|
|
The following library routines are provided for your convenience.
|
|
|
|
<P>
|
|
stdio.h - Contains the following functions printf & sprintf these
|
|
routines are developed by Martijn van Balen <balen@natlab.research.philips.com>.
|
|
|
|
<P>
|
|
|
|
%[flags][width][b|B|l|L]type
|
|
|
|
<P>
|
|
|
|
flags: - left justify output in
|
|
specified field width
|
|
<BR>
|
|
+ prefix output with
|
|
+/- sign if output is signed type
|
|
<BR>
|
|
space prefix output with a
|
|
blank if it's a signed positive value
|
|
<BR>
|
|
width: specifies minimum number
|
|
of characters outputted for numbers
|
|
<BR>
|
|
or strings.
|
|
<BR>
|
|
- For numbers,
|
|
spaces are added on the left when needed.
|
|
<BR>
|
|
If width starts
|
|
with a zero character, zeroes and used
|
|
<BR>
|
|
instead of
|
|
spaces.
|
|
<BR>
|
|
- For strings,
|
|
spaces are are added on the left or right (when
|
|
<BR>
|
|
flag '-' is
|
|
used) when needed.
|
|
<BR>
|
|
|
|
<BR>
|
|
b/B: byte argument (used
|
|
by d, u, o, x, X)
|
|
<BR>
|
|
l/L: long argument (used
|
|
by d, u, o, x, X)
|
|
<BR>
|
|
type: d decimal number
|
|
<BR>
|
|
u unsigned decimal
|
|
number
|
|
<BR>
|
|
o unsigned octal number
|
|
|
|
<BR>
|
|
x unsigned hexadecimal
|
|
number (0-9, a-f)
|
|
<BR>
|
|
X unsigned hexadecimal
|
|
number (0-9, A-F)
|
|
<BR>
|
|
c character
|
|
<BR>
|
|
s string (generic pointer)
|
|
|
|
<BR>
|
|
p generic pointer (I:data/idata,
|
|
C:code, X:xdata, P:paged)
|
|
<BR>
|
|
f float (still to be
|
|
implemented)
|
|
|
|
<P>
|
|
Also contains a very simple version of printf (printf_small). This
|
|
simplified version of printf supports only the following formats.
|
|
|
|
<P>
|
|
format output type argument-type
|
|
<BR>
|
|
%d decimal short/int
|
|
<BR>
|
|
%ld decimal long
|
|
<BR>
|
|
%hd decimal char
|
|
<BR>
|
|
%x hexadecimal short/int
|
|
<BR>
|
|
%lx hexadecimal long
|
|
<BR>
|
|
%hx hexadecimal char
|
|
<BR>
|
|
%o octal short/int
|
|
<BR>
|
|
%lo octal long
|
|
<BR>
|
|
%ho octal char
|
|
<BR>
|
|
%c character char
|
|
<BR>
|
|
%s character _generic pointer
|
|
|
|
<P>
|
|
The routine is 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.
|
|
|
|
<P>
|
|
printf_small(``my str %s, my int %d\n'',(char
|
|
_generic *)mystr,myint);
|
|
|
|
<P>
|
|
|
|
<UL>
|
|
<LI>stdarg.h - contains definition for the following macros to be used
|
|
for variable parameter list, note that a function can have a variable
|
|
parameter list if and only if it is 'reentrant'
|
|
|
|
<P>
|
|
va_list, va_start, va_arg, va_end.
|
|
|
|
<P>
|
|
</LI>
|
|
<LI>setjmp.h - contains defintion for ANSI setjmp & longjmp routines.
|
|
Note in this case setjmp & longjmp can be used between functions
|
|
executing within the same register bank, if long jmp is executed from
|
|
a function that is using a different register bank from the function
|
|
issuing the setjmp function, the results may be unpredictable. The
|
|
jump buffer requires 3 bytes of data (the stack pointer & a 16 byte
|
|
return address), and can be placed in any address space.</LI>
|
|
<LI>stdlib.h - contains the following functions.
|
|
|
|
<P>
|
|
atoi, atol.
|
|
|
|
<P>
|
|
</LI>
|
|
<LI>string.h - contains the following functions.
|
|
|
|
<P>
|
|
strcpy, strncpy, strcat, strncat, strcmp, strncmp, strchr, strrchr,
|
|
strspn, strcspn, strpbrk, strstr, strlen, strtok, memcpy, memcmp,
|
|
memset.
|
|
|
|
<P>
|
|
</LI>
|
|
<LI>ctype.h - contains the following routines.
|
|
|
|
<P>
|
|
iscntrl, isdigit, isgraph, islower, isupper, isprint, ispunct, isspace,
|
|
isxdigit, isalnum, isalpha.
|
|
|
|
<P>
|
|
</LI>
|
|
<LI>malloc.h - The malloc routines are developed by Dmitry S. Obukhov
|
|
(dso@usa.net). These routines will allocate memory from the external
|
|
ram. Here is a description on how to use them (as described by the
|
|
author).
|
|
|
|
<P>
|
|
|
|
//Example:
|
|
<BR>
|
|
// #define DYNAMIC_MEMORY_SIZE 0x2000
|
|
<BR>
|
|
// .....
|
|
<BR>
|
|
// unsigned char xdata dynamic_memory_pool[DYNAMIC_MEMORY_SIZE];
|
|
|
|
<BR>
|
|
// unsigned char xdata * current_buffer;
|
|
<BR>
|
|
// .....
|
|
<BR>
|
|
// void main(void)
|
|
<BR>
|
|
// {
|
|
<BR>
|
|
// ...
|
|
<BR>
|
|
// init_dynamic_memory(dynamic_memory_pool,DYNAMIC_MEMORY_SIZE);
|
|
|
|
<BR>
|
|
// //Now it's possible to use malloc.
|
|
<BR>
|
|
// ...
|
|
<BR>
|
|
// current_buffer = malloc(0x100);
|
|
<BR>
|
|
//
|
|
|
|
<P>
|
|
</LI>
|
|
<LI>serial.h - Serial IO routines are also developed by Dmitry S. Obukhov
|
|
(dso@usa.net). These routines are interrupt driven with a 256 byte
|
|
circular buffer, they also expect external ram to be present. Please
|
|
see documentation in file SDCCDIR/sdcc51lib/serial.c. Note the header
|
|
file ``serial.h'' MUST be included in the file containing the
|
|
'main' function.</LI>
|
|
<LI>ser.h - Alternate serial routine provided by Wolfgang Esslinger <wolfgang@WiredMinds.com>
|
|
these routines are more compact and faster. Please see documentation
|
|
in file SDCCDIR/sdcc51lib/ser.c</LI>
|
|
<LI>ser_ir.h - Another alternate set of serial routines provided by Josef
|
|
Wolf <jw@raven.inka.de>, these routines do not use the external ram.</LI>
|
|
<LI>reg51.h - contains register definitions for a standard 8051</LI>
|
|
<LI>float.h - contains min, max and other floating point related stuff.</LI>
|
|
</UL>
|
|
All library routines are compiled as -model-small, they are all non-reentrant,
|
|
if you plan to use the large model or want to make these routines
|
|
reentrant, then they will have to be recompiled with the appropriate
|
|
compiler option.
|
|
|
|
<P>
|
|
Have not had time to do the more involved routines like printf, will
|
|
get to them shortly.
|
|
|
|
<P>
|
|
<HR>
|
|
<!--Navigation Panel-->
|
|
<A NAME="tex2html880"
|
|
HREF="node42.html">
|
|
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A>
|
|
<A NAME="tex2html874"
|
|
HREF="node38.html">
|
|
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A>
|
|
<A NAME="tex2html868"
|
|
HREF="node40.html">
|
|
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A>
|
|
<A NAME="tex2html876"
|
|
HREF="node1.html">
|
|
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A>
|
|
<A NAME="tex2html878"
|
|
HREF="node61.html">
|
|
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index_motif.gif"></A>
|
|
<BR>
|
|
<B> Next:</B> <A NAME="tex2html881"
|
|
HREF="node42.html">4.4 Interfacing with Assembly</A>
|
|
<B> Up:</B> <A NAME="tex2html875"
|
|
HREF="node38.html">4. SDCC Technical Data</A>
|
|
<B> Previous:</B> <A NAME="tex2html869"
|
|
HREF="node40.html">4.2 Pragmas</A>
|
|
  <B> <A NAME="tex2html877"
|
|
HREF="node1.html">Contents</A></B>
|
|
  <B> <A NAME="tex2html879"
|
|
HREF="node61.html">Index</A></B>
|
|
<!--End of Navigation Panel-->
|
|
<ADDRESS>
|
|
<I>Johan Knol</I>
|
|
<BR><I>2001-07-13</I>
|
|
</ADDRESS>
|
|
</BODY>
|
|
</HTML>
|