Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utcs!mnetor!seismo!lll-crg!nike!ucbcad!ucbvax!hplabs!oliveb!3comvax!mykes From: mykes@3comvax.UUCP Newsgroups: net.micro.amiga,net.lang.c Subject: Re: printf() code size using Astartup.obj and AMIGA.LIB only Message-ID: <578@3comvax.UUCP> Date: Fri, 11-Jul-86 12:58:50 EDT Article-I.D.: 3comvax.578 Posted: Fri Jul 11 12:58:50 1986 Date-Received: Sun, 13-Jul-86 07:07:25 EDT References: <8606270438.AA07486@pavepaws> <426@oscvax.UUCP> Reply-To: mykes@3comvax.UUCP (Mike Schwartz) Organization: 3Com Corp; Mountain View, CA Lines: 46 Xref: utcs net.micro.amiga:3883 net.lang.c:9710 In article <4907@sun.uucp> guy@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@sun.com (or guy@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.