Article View: comp.sys.amiga.tech
Article #5526Re: Writing small code in SAS/C 5.10
From: Joe C.
Date: Sat, 29 Sep 1990 21:42
Date: Sat, 29 Sep 1990 21:42
38 lines
1851 bytes
1851 bytes
In article <12482@ogicse.ogi.edu> jmeissen@ogicse.ogi.edu (John Meissen) writes:
>In article <13148@leadsv.UUCP> lord@leadsv.UUCP (Parker Lord) writes:
[deleted]
>>program that does nothing more than a printf("Hello\n"); I compiled and linked
>>this using lc -L. This code came out at about 4.6K. In comparison, the
>[deleted]
>Aaaack! This is one of my pet peeves! Does anybody out there have ANY idea
>how much work printf() does and how large it is? If you want to write the
>largest program possible for printing a string, use printf()! Please,
>please, please don't use printf() for size comparisons.
Lattice (or is that SAS/C) has three different versions of printf(). If you
include <stdio.h> in the beginning, then the compiler will use
_writes() if you only have a string.
_tinyprintf() if all you have is %s,%s or %p.
This can result in a saving of > 2K in final code size.
Also, the main program itself is not the culprit, it is the linking process
that increases your size.
If you tried:
#include <stdio.h>
{ printf("Hello\n"); }
An compiled with lc -Lncd -O -v
Then the assembly output would be roughly
PEA 01.00000000(A4)
JSR __writes(PC)
ADDQW #4,A7
RTS
But if you look at the map file of the linker, it brings in lc.lib and uses
about 40 functions in there.
-jc
Technical Details
Message-ID:
<1990Sep29.214241.27653@agate.berkeley.edu>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!uwm.edu!bionet!agate!e260-2d!labb-2aeReferences:
<13148@leadsv.UUCP> <12482@ogicse.ogi.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!uwm.edu!bionet!agate!e260-2d!labb-2ae From: labb-2ae@e260-2d.berkeley.edu (Joe C.) Newsgroups: comp.sys.amiga.tech Subject: Re: Writing small code in SAS/C 5.10 Message-ID: <1990Sep29.214241.27653@agate.berkeley.edu> Date: 29 Sep 90 21:42:41 GMT References: <13148@leadsv.UUCP> <12482@ogicse.ogi.edu> Sender: usenet@agate.berkeley.edu (USENET Administrator) Organization: University of California, Berkeley Lines: 38