[comp.sys.ibm.pc] Need to optimize 8086 C code for size

nevin1@ihlpf.ATT.COM (00704a-Liber) (02/12/88)

I have a friend who is doing some development work for the 8086 PC market.
He needs to optimize for size, since the 640K limit is posing some almost
insurmountable problems.

Here are his experiences so far:

He is using Microsoft C 4.0 currently.  Unfortunately, when he turns the
optimizer on it produces incorrect (albiet shorter) code.  If he turns the
optimizer off the executable becomes too big.  He has tried Microsoft C 5.0,
but in his initial estimates 5.0 code optimized is about the same size as 4.0
unoptimized.  He is going to try Turbo C 1.5 to see if there are any
improvements.  BTW, he is using an 80386 machine for development, so size isn't
as important there; however, he needs to produce 8086 code that will run on a
640K PC.


What is the best C compiler on the market today for optimizing size?  Any
comparisons between compilers would be greatly apprieciated.

Thanks alot (in advance),
-- 
 _ __			NEVIN J. LIBER	..!ihnp4!ihlpf!nevin1	(312) 510-6194
' )  )				"The secret compartment of my ring I fill
 /  / _ , __o  ____		 with an Underdog super-energy pill."
/  (_</_\/ <__/ / <_	These are solely MY opinions, not AT&T's, blah blah blah

madd@bu-cs.BU.EDU (Jim Frost) (02/12/88)

In article <3680@ihlpf.ATT.COM> nevin1@ihlpf.UUCP (00704a-Liber,N.J.) writes:
>I have a friend who is doing some development work for the 8086 PC market.
>He needs to optimize for size, since the 640K limit is posing some almost
>insurmountable problems.
>
>He is using Microsoft C 4.0 currently [...] when he turns the
>optimizer on it produces incorrect (albiet shorter) code.  If he turns the
>optimizer off the executable becomes too big.  [...]
>He is going to try Turbo C 1.5 to see if there are any
>improvements. [...]

I'd say Turbo C is your best bet.  Even in its "optimize for speed"
mode it compiles significantly smaller than uSoft C, and in its
"optimize for size" mode it makes some really small code.  TC doesn't
make the fastest code, but it's pretty fast and REAL small.

And it seems that we have another person who's been bitten by the
uSoft optimization bugaboos.  Are you listening, Microsoft?  Or are
your ads just so much fluff?

BTW, what do you think uSoft is going to do with their ads now that
TC has graphics?  And I hear that there's soon to be a Borland
debugger.  Looks like the competition is heating up!

jim frost
madd@bu-it.bu.edu

bobmon@iuvax.UUCP (Bob...Mon) (02/13/88)

In article <3680@ihlpf.ATT.COM> nevin1@ihlpf.UUCP (00704a-Liber,N.J.) writes:
>
>What is the best C compiler on the market today for optimizing size?  Any
>comparisons between compilers would be greatly apprieciated.

One quick'n'dirty comparison from memory:  microEmacs v3.9e

Microsoft C:	~ 110k executable (MSC4 or MSC5?)
Turbo C:	~  90k    "       (TC1.0)
Aztec C:	~  70k    "       (the one that Dan Lawrence distributes)

-- 
You TOO Can Defeat The 4-Line .signature Limit And Be Obnoxious To Your Friends And Neighbours!!!!!								...---...									Charles Cabbage on the Difference Engine running SE grade 10W40 at UKnoWhere	Babble@diffEQ	bob,mon@iuvax.cs.indiana.edu	Chucky on Ada	The Slide Rules!"Spaceship Earth!  There IS no substitute!"

mac3n@babbage.acc.virginia.edu (Alex Colvin) (02/15/88)

Use medium or compact model.  Avoid always reloading segment registers.
The 80?*8[68] wasn't meant to be used in large/huge model.  See if you can
find a compiler that supports this.  More important, see if you can find a
linker.  And expect lots of nasty, obscure, nondeterministic bugs.

Another approach for getting extremely small, slow programs is to build an
interpreter for your problem domain, then interpret a program for your
problem.  Some BASIC programs will be considerably tighter than C.

nevin1@ihlpf.ATT.COM (00704a-Liber) (02/20/88)

In article <3680@ihlpf.ATT.COM> nevin1@ihlpf.UUCP I wrote:
>
>What is the best C compiler on the market today for optimizing size?

The results are in!!  According to the net, the best C compiler for optimizing
size is:

[insert drum roll here]

AZTEC C!!  Microsoft C producced the largest code, and Turbo C produced fairly
short code but not quite as short as Aztec C.

Also, many people suggested using overlays if there are memory problems.


Thanks to all who responded.  If you have any more info, please post it or
email it to mme.  Thanks again,
-- 
 _ __			NEVIN J. LIBER	..!ihnp4!ihlpf!nevin1	(312) 510-6194
' )  )				"The secret compartment of my ring I fill
 /  / _ , __o  ____		 with an Underdog super-energy pill."
/  (_</_\/ <__/ / <_	These are solely MY opinions, not AT&T's, blah blah blah