printf() code size using Astartup.obj and AMIGA.LIB only

mykes at 3comvax.UUCP mykes at 3comvax.UUCP
Sat Jul 12 02:58:50 AEST 1986


In article <4907 at sun.uucp> guy at sun.uucp (Guy Harris) writes:
>
>Which should always be 0.  As such, in the example given, 
>
>	if (var == NULL) ...
>
>is identical to
>
>	if (var == 0) ...
>
>and should generate the same code; as the author of the response to the
>above comment points out, there is NO reason to extend a 1-byte variable
>"var" to 4 bytes when doing this.
>-- 
>	Guy Harris
>	{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
>	guy at sun.com (or guy at sun.arpa)

As author of the original article, I would just like to point out that
the NULL in he case I described was NOT 0L (I removed all the Ls form the
include files - i use +l all the time so I dont need them).  I had hoped
that removing the Ls, this would make the "problem" go away but no luck.
Simple peephole optimization hould catch most of the stuff I see wrong
wit MANX.  I also acknowledge that the +l option was an "afterthought",
having been added maybe days before 3.20A shipped.  I still would rather
stick with their product for the next few years, because they do have the
better compiler, a head start on everyone else (at making a good Amiga
library), excellent support and a bright future.  I will probably pay for
updates forever...

This discussion has brought out a few interesting points: if you consider
the compiler a tool to generate the program you want (which  I do), then
you have to play some tricks and use a style that makes the compiler generate
better code.  On one hand, future compilers (versions of compilers) may not
generate optimal code for this style, but what you get today is closest to
the binary program that you want (i.e. fast, compact, etc.) as doable with
the current version of the compiler.  On the other hand, if you code for
portability, there are less of these tricks (there probably are a few though)
that work across all compilers and all machines.  Matt Dillon's comments 
about longs and shorts and ints are valid and his approach is valid, when
you consider his intentions (purism aside).  For now, I do use:
	if (!pointer) ...
instead of
	if (pointer == NULL) ...
because no matter how much RAM I have, I seem to always want more.  Coding
this way saves me RAM all the time.



More information about the Comp.lang.c mailing list