Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!think!nike!lll-crg!lll-lcc!well!ewhac From: ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) Newsgroups: net.micro.amiga Subject: Re: printf() code size using Astartup.obj and AMIGA.LIB only Message-ID: <1385@well.UUCP> Date: Thu, 3-Jul-86 02:06:31 EDT Article-I.D.: well.1385 Posted: Thu Jul 3 02:06:31 1986 Date-Received: Fri, 4-Jul-86 02:13:40 EDT References: <8606270438.AA07486@pavepaws> <426@oscvax.UUCP> <84@unisoft.UUCP> <566@3comvax.UUCP> Reply-To: ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) Organization: Whole Earth Lectronic Link, Sausalito CA Lines: 59 Summary: It's doing precisely what you told it to. [ Go ahead. Eat me. See if I care. ] In article <566@3comvax.UUCP> mykes@3comvax.UUCP (Mike Schwartz) writes: >Manx, using the +l option, is not a very good code generating compiler - >it just buries Lattice in terms of compiling speed, program size (the >size of the compiler, linker and assember is the size of LC1 alone). But >I cringe when I look at the code generated, I am amazed at how poor it is. >For example, the following statement: > if (var == NULL) ... >causes var to be first loaded, extended to a word, extended to a long, then >compared against 0, EVEN when var is declared as a UBYTE... > >Oh, well... I guess someone will make a good 'C' compiler someday... It never fails to amaze me just how many people do this: if (foo == NULL) { ... } or: if (foo == 0) { ... } The reason the compiler is exhibiting the behavior you describe is because you told it to. You are asking the compiler to compare an unsigned byte to the literal value of NULL. If you look in exec/types.h, you'll find NULL defined this way: #define NULL 0L So you're asking the compiler to compare a byte to a long. So it expands the byte to a long, then makes the comparison using a CMP instruction. That *IS* what you told it to do. What I can't understand is why more people don't do this: if (!foo) { ... } This will do what you want, which is TST the byte to see if it's non-zero. If you *really* care about optimized code, compile to an assembly source file and bang on it yourself. That's something Lettuce *definitely* won't let you do. --------I N T E R L U D E-------- I really hate this damn compiler. I wish that they would sell it. It never does just what I want, But only what I tell it. -------- Think about it (not too much; it's intended to be humorous). _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ Leo L. Schwab ihnp4!ptsfa!well!ewhac ..or.. "Work FOR? I don't work FOR well ---\ anybody! I'm just having fun." dual ----> !unicom!ewhac hplabs -/ ("AE-wack")