Re: [cc65] scanf ?

Date view Thread view Subject view

From: Ullrich von Bassewitz (
Date: 2001-02-23 08:15:21

On Thu, Feb 22, 2001 at 10:42:33PM -0500, troy silvey wrote:
> I havn't  found that printf adds much to my compiled code.
> In one my first sample programs (about 1.75k of code text) the
> compiled program was barley 3k. I'm still working with that
> first program, adding features and functions including printf
> andgetchar. The code text has grown to  5.7k  of code text while
> the executable is 5.8k. Would scanf immediatly add 8k to the
> compiled executable?

This is why I said "Before the rewrite for version 2.6". The first version of
printf was written completely in C, a hello world type program had a size of
about 5K. After some optimizations to the C code, this dropped to somewhat
more than 4K. For version 2.6, several functions (including printf) were
rewritten in assembler, a "hello world" program is now about 2.5K.

Since printf references lots of stuff that may get reused in larger programs
(ctype, strlen, strlower, ultoa, ...) the overhead is usually lower for larger
programs, since such programs tend to use these routines independent of

The 8K number for scanf is just an estimate for a first version written
completely in C. It's based on the fact that scanf is even more complex than
printf. But it's an estimate and it may be wrong. It may also be possible to
get lower numbers by size optimizations or a rewrite in assembler, but I
won't do that for the first version. It is usually easier to rewrite existing
C code in assembler, than to write it in assembler from scratch.



Ullrich von Bassewitz                        
To unsubscribe from the list send mail to with
the string "unsubscribe cc65" in the body(!) of the mail.

Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2001-12-14 22:05:39 CET