I am new to this SDCC compiler, I have used Keil C51 for small projects.
I can not compile C51 source using printf() function, as SDCC is also ANSI C
complier. Is there any way to use printf() function for 8051 to use serial
io of 8051.
Is there any compete library reference available for SDCC ?
Send instant messages to your online friends http://in.messenger.yahoo.com
From: Paul Stoffregen <paul@pj...> - 2005-08-24 09:53:35
> I am new to this SDCC compiler, I have used Keil C51 for small projects.
>I can not compile C51 source using printf() function,
Whenever you ask for help with code that "won't compile", always include
at least the portion of the code that you can't compile, and an exact
copy of the error message, and the version of SDCC you're using (use
sdcc -v to get the version info).
>as SDCC is also ANSI C
>complier. Is there any way to use printf() function for 8051 to use serial
>io of 8051.
The library has a few different printf functions. You must provide a
purchar() function that does the actual I/O. See the SDCC examples and
manuals for detailed information about how to do this. The SDCC printf
functions do not "know" how to do I/O. They just take all the inputs
you provide and make a bunch of calls to putchar() to output all the
characters. You must provide a putchar() that does the I/O specific to
your board. Using the normal 8051 uart, you can just copy one of the
The normal "printf" is a large, full-feature version. There is a
printf_small with fewer features, but smaller code size. On the 8051
(mcs51), there's also printf_fast (similar to printf_small, but runs
much faster), printf_fast_f (adds floating point support), and
printf_tiny (very minimal, under 300 bytes of code). Just "#include
<stdio.h>" and then you can use any of these. Of course, if you have a
"printf" in your code, the linker will build your code using your copy
rather than the one from the library with the same name.
Lately I've committed an often asked for feature on mcs51: returning
bit (or bool) from a function. This should work now except for function
I've also added functionality for passing bit parameters and using bit
local variables when --stack-auto is used. It's not working for functions
declared with "reentrant" and I haven't tested #pragma stack-auto
Have a look, try and test, report back, ...
Hope you enjoy it.